In JSF - What is the correct way to do this? Two dropdown lists with dependency.
- by Ben
Hi,
I'm making two dropdown lists in JSF which are dependent.
Specifically, one list has all the languages and the second list contains values that are displayed in the currently selected language.
I've implemented this by having the second list use information from a Hash and rebuilding that Hash in the setter of the currently selected language.
JSF Code Bit:
<rich:dropDownMenu value="#{bean.currentlySelectedLanguage}" id="languageSelector">
... (binding to languages hash) ...
<rich:dropDownMenu value="#{bean.currentlySelectedScript}" id="ScriptPullDown">
... (binding to scripts hash) ...
Backing Bean Code Bit:
setCurrentlySelectedLanguage(String lang){
this.currentlySelectedLanguage = lang;
rebuildScriptNames(lang);
}
I'm wondering if that's a good way of doing this or if theres a better method that I am not aware of.
Thank you!
EDIT - Adding info..
I used a a4j:support that with event="onchange" and ReRender="ScriptPullDown" to rerender the script pull down.
I could probably add an action expression to run a method when the value changes. But is there a benefit to doing this over using code in the setter function?