Saturday, September 19, 2009

Irena Sendler - War Hero

Have you heard of 'Irena Sendler'. I'm pretty sure most of us haven't. She's no superstar, great politician, a sportsperson or a media personality, besides she's not even among us now. She's dead for more than an year now. Why her story caught my attention was because she's known as a 'War Hero'. 'War Hero' - a term we heard so frequently and still continue to hear. She's a war-hero for the same reasons that could cast her as a 'traitor' in different times and circumstances...only time will tell.

Irena was a Polish aid-worker, activist during World War II in German occupied Warsaw, Porland. She had lead the smuggling of small children from the 'Ghetto' - Huge Jewish Villages (In reality those were high wall camps keeping Jews before they were taken for concentration camps for group execution). She got the chance to visit the Ghetto as a health worker and risked her life escaping children out. She together with her colleagues forged documents and planned escapes one after the other. Usually smuggling children after sedating them and putting them inside coffins, bags or helping them to crawl through sewers to reach outside world. It is said that she had a dog who traveled with her and trained it to bark at Gestapo. The barking sounds of the dog sometimes helped her to keep sounds of children unheard.

She was ultimately caught and was severely tortured and was given death sentence. Her hands and legs were broken. She somehow manage to escape on her way to death sentence by bribing the soldiers as they left her in the middle of a jungle. But she survived and lived and operated in hiding till the war was over.

She kept a jar full of names/details of all the children she rescued, hoping that someday she could reunite them with their parents. But it was later found that no one was able to find their parents as they were either killed or lost.

She was nominated to the Nobel along side Al-Gore (How much have we heard of Al-Gore and yet how Irena evaded us? Amazing isn't it?). All of us know that Al-Gore won it for creating a slide shore on global warming :).

Since we as Sri Lankas have also come across a long and dirty war there should be Sri Lankan 'Irena' personalities. But the media doesn't seem to be interested yet. They will be interested in 10-20 years time...I hope. (It took almost 50 years for the world to really know the heroics of Irena). But every time you come across a War-Hero or Freedom-Fighter who is so called since he's good at killing enemies don't forget to remind your self that there should be 'Irena's as well. It would be a great reminder of humanity left in us, however scarce that may be these days.

Friday, September 11, 2009

Passing Parameters to Silverlight 3 Components

When you go one level up from the typical test projects, you come in to a situation where you need to tweak the Silverlight client app based on some sever side logic. For this to work silverlight supports the concept of InitParams. InitParms allows a hosting aspx page to pass parameters to a Silverlight client application. All over the web this process is well explained, except for one little glitch. i.e It's explained for Silverlight 2, not for the latest Silverlight 3. This gap is critical, since a lot has changed from SL2 to SL3. Specifically the removal of <asp:silverlight ../>, <asp:mediaplayer ../> is pretty significant because most of variable passing information in web is related to <asp:silverlight> markup.

In SL 3 instead of <asp:silverlight> an object tag is used


<object data="data:application/x-silverlight-2," type="application/x-silverlight-2"width="100%"
height="100%">

<param name="source" value="{XAP_FILE}"/>

<param name="onerror" value="onSilverlightError"/>

<param name="background" value="white"/>

<param name="InitParams" value="showall=true"/>.....


Now the question is how to set InitParms dynamically. See here for InitParam explanations. The previous links discuss InitParam in detail, but fail to provide how it can be passed dynamically (by hosting aspx page). But I found a close to working solution here but it didn't work for some odd reason. Ultimately a link to a document from Silverlight team on specific changes due to <asp:silverlight> component been missing provided me with the working solution.

The solution is to use a Literal control as value and set the Literal text in the server side aspx code.

<object data="data:application/x-silverlight-2," type="application/x-silverlight-2" width="100%" height="100%">

<param name="source" value="{XAP_FILE}"/>

<param name="onerror" value="onSilverlightError"/>

<param name="background" value='<asp:Literal id="Color" runat="server"/>' />

<param name="InitParams" value="'<asp:Literal id="InitParams" runat="server"/>'"/>...

In the hosting aspx pages page load method we do the following;
protected void Page_Load(object sender, EventArgs e)
{
Color.Text = "White"; //You can call any server side code here
InitParams.Text = GetUrl(); //Implement any business logic to get url and return it according to InitParam standard, i.e url=urlvalue
}


Now that the InitParam is set you can use it in your silverlight application by initializing them during Application_Start of SL.
private void Application_Startup(object sender, StartupEventArgs e)
{
string broadcastUrl = e.InitParams["bcUrl"];
this.RootVisual = new MainPage(broadcastUrl );

}

Now you can use this dynamically generated value for any logic within the SL application.
eg: Set the source of media element control, suppose you have a media element with id=mplayer
mPlayer.Source = new Uri(broadcastUrl ); //BroadcastUrl variable should be passed somehow to SL app. (May be via constructor as above)