Hi Experts Im new to JSF world and have come across the following scenarion.
I have following UI controlls on the jsp page: textfield, drop down.
The drop down has following values :Mercedes,BMW,GM,Ford.
So when the user selects any value, the selected value goes to the server and based on the response from the server, I have to show different UI controlls on the page for example lets say when the user selects Ford i have to show 2 textfields, 2 drop down, and 3 Check boxes and when the user selects Mercedes i have to show 4 textfields, 3 drop downs and 2 list.
Im struggling about the ways through which i can implement this.
Depending on how different the forms are from one choice to another, there are a couple of ways you could do this.
1: If the choices are very similar. For example, textfields 1 and 2 are the same for Ford and BMW but BMW just has an additional textfield, and so on with the other components, simple use the rendered attribute of the components with a or more boolean properties in your backing bean to turn them on or off depending on the selection.
2: If the textfields and other components are for the majority completely different for each choice, use panelGroup components (or somethind similar) to group all the components for each choice to a specific panel (DIV). Then use the rendered attribute on the panel to decide which to show.
If you are using MyFaces, they have a really nifty panelStack component that makes option #2 pretty simple.