Replace JSF tag

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;
...

}
 
L

Lew

I am using Tomcat and can[']t use JSF on our web container.
With no JSF I can[']t use the JSF valueChangeListener Tag [sic].

Why can't you use JSF?
Please advise what I can substitute for the below valueChangeListener
so I can get this to work for my dynamic drop downs:

You might be able to hack something Javascriptish together to do what you
want, or use your server-side handler logic to compare the values for changes.
Otherwise anything that would work like JSF would allow JSF itself to work,
only better.

<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;

Never, never, never use dynamic SQL.

Of course, I am assuming that this expression is intended to be SQL, an
assumption belied by the fact that the expression will not be valid SQL.

I don't understand why you say you can't use JSF, then look for idioms that
would require just as much support as JSF only a whole lot more effort, only
not to get the robustness, functionality or flexibility that JSF provides.
Please explain this further.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top