JSF 2 passing parameters
|
|
|
Passing parameters in JSF 2
Let's take an example of a tab selection with his correspondent content rendered according to the tab selection.
We have two tabs. Clicking on the tab trigger the handleTabChange method on the tabBB backing bean.
In JSF 2, " f:param " tag allow you to pass a parameter to a component
We have two output panels corresponding to the tabs defined previously.
The two panels are rendered according to the current tab index selected using the expression #{tabBB.tabIndex == 1} where 1 is the tab index for the related content
Tab Backing Bean
The tab manager backing bean is a managed bean . It is defined as a session bean scope and�responsible to keep and dispatch the current tab index.
The JSF Backing bean has a a method called handleTabChange . This method is in charge to retrieve the paremeter defined using f:param and set the correponding value.
When the command link is sollicited the page is refreshed. The current tab index is updated and the correponding output panel is shown or hidden according to the current tabIndex.
That's it.
Feel free to send me your feedback or questions.
Related JSF articles
JSF 2 Param Tag
Add a child UIParameter component to the UIComponent associated with the closest parent UIComponent custom action.
| Tag Information | |
|---|---|
| Tag Class | com.sun.faces.taglib.jsf_core.ParameterTag |
| TagExtraInfo Class | None |
| Body Content | JSP |
| Display Name | None |