Thursday, February 28, 2013

Passing parameter in JSF

In JSF, there are several ways to pass data from the client (browser) to the server.

1. value binding
Which is the default in JSF
eg
value binding in JSF

2. f:param
eg,
passing parameter with f:param in JSF

to retrieve the value in managedBean, write the following codes.
passing parameter with f:param in JSF

3. f:setPropertyActionListener

eg,
passing parameter with f:setPropertyActionListener in JSF
in managedBean,
passing parameter with f:setPropertyActionListener in JSF
with setPropertyActionListener, setter of the property is invoked before action method (myAction), thus we can get the property value in the action method.
the disadvantage of f:setPropertyActionListener, it passed in value must be String type.

4. a4j:param (Richfaces 4 ONLY)
eg,
passing parameter with a4j:param in JSF
in managedBean
passing parameter with a4j:param in JSF
the usage of a4j:param is similar with f:setPropertyActionListener. But the advantage of a4j:param is, value other than String still can be passed.

5. JSF2 action 
eg,
passing parameter with JSF2 action
in managedBean,
passing parameter with JSF2 action



Done!!

LinkWithin

Related Posts Plugin for WordPress, Blogger...