Archive for the tag 'javaserver faces'

Feb 03 2009

An easy way to connect JSF with Adobe FLEX




Using Adobe Flex together with other technologys like JavaServer Faces, Struts or Spring Web Flow is not an easy task, because the embedded Flash-file interacts in its own world and from the sight of its surrounding JSF/JSP/HTML-Code, it is an foreign object. There exists some approaches to connect these different worlds like the jsf-flex project or the Exadel Fiji.

I am now showing you an another way, how you can connect Flex with JavaServer Faces. You are able to develop each Project (Flex and Java) separately.


Let’s take a look at this picture (click on the picture to enlarge it):

bild1


This is what we have. JSF-Code with an embedded Flex-Object. You can insert the firstname and the lastname with JSF-inputText -Fields, and the fields city and country with Flex. If you click submit, alle four values are saved inside the managed-bean.

bild2


Ok how is this possible? The solution is JavaScript! In some few words – if you enter some values for the city and country inside the Flash-Object, the ActionScript code is writing these values into JavaScript-Variables (which are declared in the JSF Code). If you hit submit, a JavaScript-Function is writing the values into the hidden tomahawk-inputFields which are bonded to the corresponding managed-bean (Page1Bean).

jsfwithflexdiagram bild4bild3


In ActionScript, you have to extend the class Proxy and overwrite flash_proxy function setProperty(..). You can see this here:

JSVariableProxy.as

Technorati Tags: actionscript, adobe flex, connect, javascript, javaserver faces, jsf, NetBeans

One response so far