jsf 2 - Adding dynamic drop down components in JSF -


my requirement this. have selectmenu values (examples: engineering, medicine, law etc..,) . suppose if select engineering in drop down, want dropdown menu created dynamically has values related engineering (example: electronics, computers, electricals etc..,). how achieve in jsf 2.0 ?

you need perform ajax request when first h:selectonemenu's selection change. request update selectable items in second h:selectonemenu. after ajax request, must render second h:selectonemenu again, updated values.

page:

<h:selectonemenu value="#{bean.selectedsubject}">     <f:ajax listener="#{bean.changesubject}" render="speciality_selection"} />     <f:selectitems value="#{bean.subject}" /> </h:selectonemenu>  <h:selectonemenu id="speciality_selection" value="#{bean.selectedspeciality}">     <f:selectitems value="#{bean.subjectspecialities}" /> </h:selectonemenu> 

managed bean:

public void changesubject(){     //loads specialities depending on selected subject     subjectspecialities = loadspecialitiesforsubject(selectedsubject); } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -