Flash, SWF and Silverlight in Web Client

Fellow Servoyans

As a comparative newbie, this might be a very silly question but here goes …
Is it possible to view Flash or Silverlight files within a web client. I have looked at ‘html area’ fields and html labels with no luck. Is this possible with Servoy, out of the box or with an add-on of some sort?

If so, I am wishing to create a swf which can be clicked on to generate some data which can be posted into Servoy. I’m not sure this is possible either?

Nick

this should be possible through a html area.
Just there have all the embed tags for your flash player/file

Thanks Johan…I seem to be getting somewhere in that I can now render a Silverlight file from within the web client. However it keeps disappearing when I restart the web client. It appears to be something quirky with the url. Here is my code:

When the file disappears, I change the url to ‘…/…/silverlight_file.xap’. and it appears temporarily, disappears, then appears when I change the url back. I reset the browser and databaseManager.saveData () before each test.

Sun claims “some” support for the object tag in “HTMLAreas”, but I don’t know exactly what that means.

" The tag is not supported, but some support is provided for the tag."

More info here: http://java.sun.com/j2se/1.5.0/docs/api … orKit.html?

can’t you make a full path to that file?
so

/servoy-webclient/xxxx

because you are filling there something really relative that is not going to work becaue the browser then makes it different depending how you start the solutution (arguments etc)

I have tried this method and also absolute paths without success. They work for a moment. I am also told that the embedding is different for each browser. I will look into this further and come back with my findings.

You can also try iframe - something like this inside the HTML area:

<html>
<iframe src="page that contains what you want to show"></iframe>
</html>

I’m getting there. I now have my SIlverLight object rendering in the web client. The object sits in an html field and has a button which I would like to call a Servoy method.

Now I know I can trigger a method (from the SilverLight object) in the HTML area if I do this…

<html>
<script>
function MethodInHTML ()
{
alert ("Hello Servoy World")
}
</script>
<object data="data:application/x-silverlight,"; type="application/x-silverlight-2" <param name="source" value="../servoy-webclient/slight_object.xap"/></object>
</html>

And I know I can trigger a SERVOY method FROM the HTML area if I do this…

<html>
<object data="data:application/x-silverlight,"; type="application/x-silverlight-2" ><param name="source" value="../servoy-webclient/slight_object.xap"/></object>
<a href="javascript:MethodInServoy()">BUTTONTEXT</a>
</html>

But how do I call a SERVOY method from the SilverLight button?

You should be able to do what you need in two ways:

Here is an example of HTML Area content you could use to play with these possibilities:

<html>
<body>
    <a href="http://localhost:8080/servoy-webclient/solutions/solution/nameOfYourSolution/method/nameOfYourGlobalMethod/argument/0">button</a>
    &nbsp
    <a id="bla" href="javascript:globals.nameOfYourGlobalMethod()">button</a>
    &nbsp
    <a onClick="document.getElementById('bla').onclick();" href="#">This simulates what you must do with the JS triggered from SilverLight</a>
</body>
</html>

This example works for me just fine :wink: .

Thanks Andrei

Does it have to be a global method and also how might I pass it an array?

Yes, it can only be a global method.
You can pass an array by serializing/deserializing it into/from String. For example: “1x2x3” <=> [1, 2, 3]

Not sure I follow?
The Silverlight object is passing the Servoy method an array of VARIABLE length. I am stuck as to pass this array to the Servoy method. I have watched the debugger and nothing seems to get passed by my method.

<script>
function triggeredBySLight()
{
for (i = 0; i < arguments.length; i++) 
{
document.getElementById("servoy").click(i); *** DO I PUT MY ARGUMENTS HERE***
}
}
</script>
<a id="servoy" href="http://localhost:8080/servoy-webclient/solutions/solution/solutionName/method/ServoyMethod/argument/0"></a> ***OR HERE***
<object data="data:application/x-silverlight,"; type="application/x-silverlight-2" width="100%" height="100%"><param name="source" value="../../../servoy-webclient/silverlightObject.xap"/></object>

The argument is specified in the URL. (In your case “0” is the argument)

http://localhost:8080/servoy-webclient/solutions/solution/solutionName/method/ServoyMethod/argument/***THIS IS WHERE YOU PUT THE ARGUMENT***

Can’t you construct the URL inside Silverlight and open it from there (I didn’t work in silverlight, so just asking)? (then you no longer need JS any more…)

This thread has been dead for over a year. I am curious if anyone was ever able to integrate Silverlight into a Servoy Smart Client and/or Servoy Web Client solution. If you have been successful, would you mind contacting me or posting some additional information on this thread?

TIA, J T

Smart client is out of the question unless Patrick can add another magic trick to his crazy cool browser bean:

viewtopic.php?f=15&t=13463

You can easily host silverlight from Servoy by dropping the necessary files into the webapps directory. The one change is that with tomcat you need to change the extension ```

``` to ``` " ``` to get silverlight to work.

This allows you to work with silverlight via headless or web client pretty easily.

For triggering servoy methods from within silverlight I would probably replace the technique outlined above (though it looks like it would work fine too) with Sean Devlin’s client-side plugin (which we have found quite effective with integrating with jquery) due to the fact that silverlight has a well defined javascript integration api:

viewtopic.php?f=26&t=12630&p=65074

To finish the round trip up sending data to the silver light app can be done via the usual silverlight data interfaces.

That’s my top level thoughts. The exact code implementation steps are a bit different depending on if you’re running headless or web client and how extensive your integration goals are. I would hesitate to do a full UI interface with silverlight this way (data broadcasting just one potentially significant coding task) but not much work to include silverlight widget type stuff.

Thanks for the reply David.

I acheived this in the end much the same way as David suggested.

The trick was to place the silverlight.xap object in the servoy/application_server/server/webapps folder.

I called it using:

<html><script>function silverlightobject(){for (i = 0; i < arguments.length; i++) {document.getElementById("servoy").click();}}</script><a id="servoy" href="http://localhost:8080/servoy-webclient/solutions/solution/evaluate/method/<<methodNameInsideSilverlight>>/argument/0"></a><object data="data:application/x-silverlight,"; type="application/x-silverlight-2" width="100%" height="100%"><param name="source" value="../../../servoy-webclient/<<silverlightObject.xap>>"/></object></html>';

The methodNameInsideSilverlight sends parameters to a method within the Servoy form which delivers the result I was after. Not sure it is the most eloquent way, but it works.