views:

1272

answers:

2

I'm building a web application with JSF and ICEFaces. Now I've integrated a Java Applet into one of the JSF pages.

The Question is, how can I pass information stored in the backing bean to the applet? I don't think that I neeed a bidirectional communication. I'm collection data using ICEFaces input components. For instance, hitting a button is then to cause the applet to reload with the newly collected data.

Thanks

+1  A: 

Well in the end i guess your applet should represent some sort of view of your model. So in an MVC context your JSF would be your view/control, and you would have some backend model. Your applet is another view on this model, so you should have your applet be an observer or listener on your model, and when the JSF makes changes to the model you should fire an event/notify observers representing that the model changed.

takete.dk
Thanks for the answer, but this doesn't solve my problem. In your scenario I will need to get information from JSF/Backing Bean to the applet. That's though exactly what I don't know how to do ...
You could do it through an RMI connection. But as you suggest yourself it's also possible to do this by hitting a button, as the public methods of classes inheriting from JApplet are available through javascript. You just need to locate the DOM element containing your applet, and then call a method to refresh it. Eg. document.MyApplet.refresh()
takete.dk
+1  A: 

Something like the following within your Applet tag?

<param name="welcomeMessage" value="<h:outputText value="#welcomeMessage"/>">

(Excuse any JSF inaccuracies)

And then use getParameter as normal inside the applet.

Pool