F
francan00
I am using Tomcat and cant use JSF on our web container. With no JSF
I cant use the JSF valueChangeListener Tag.
Please advise what I can substitute for the below valueChangeListener
so I can get this to work for my dynamic drop downs:
<h:selectOneMenu value="#{Bean.selectedItem1}" valueChangeListener="#
{Bean.myValueChangeListener}" onchange="submit();">
<f:selectItems value="#{bean.list1}"
</h:selectOneMenu>
<h:selectOneMenu value="#{Bean.selectedItem2}">
<f:selectItems value="#{bean.list2}"
</h:selectOneMenu>
-----------------------------------------
Bean:
private String selectedItem1 = ""; //holds selected value from combo1
private String selectedItem2 = "";//holds selected value from combo2
private ArrayList list1 = null; //combo1 list
private ArrayList list2 = null; //combo2 list
public Bean(){
list1 = new ArrayList();
//add some SelectItems to list1
//it can be done somwhere else than this constructor
//
list2 = new ArrayList();//leave empty, or add one row informing
that you need to choose value from combo1 first
//ie.
list2.add(new SelectItem("","Choose combo1 value first 1));//
}
public void myValueChangeListener(ValueChangeEvent e) throws ... {
selectedItem1 = e.getNewValue();
fillList2(selectedItem1);
}
private void fillList2(String selectedItem1){
//this method fills list2
//ie from query
String query = "SELECT * FROM users WHERE group_id="+selectedItem1;
...
}
I cant use the JSF valueChangeListener Tag.
Please advise what I can substitute for the below valueChangeListener
so I can get this to work for my dynamic drop downs:
<h:selectOneMenu value="#{Bean.selectedItem1}" valueChangeListener="#
{Bean.myValueChangeListener}" onchange="submit();">
<f:selectItems value="#{bean.list1}"
</h:selectOneMenu>
<h:selectOneMenu value="#{Bean.selectedItem2}">
<f:selectItems value="#{bean.list2}"
</h:selectOneMenu>
-----------------------------------------
Bean:
private String selectedItem1 = ""; //holds selected value from combo1
private String selectedItem2 = "";//holds selected value from combo2
private ArrayList list1 = null; //combo1 list
private ArrayList list2 = null; //combo2 list
public Bean(){
list1 = new ArrayList();
//add some SelectItems to list1
//it can be done somwhere else than this constructor
//
list2 = new ArrayList();//leave empty, or add one row informing
that you need to choose value from combo1 first
//ie.
list2.add(new SelectItem("","Choose combo1 value first 1));//
}
public void myValueChangeListener(ValueChangeEvent e) throws ... {
selectedItem1 = e.getNewValue();
fillList2(selectedItem1);
}
private void fillList2(String selectedItem1){
//this method fills list2
//ie from query
String query = "SELECT * FROM users WHERE group_id="+selectedItem1;
...
}