Meaningless Drivel is fun!*
The moose likes JSF and the fly likes on change combo box not working. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "on change combo box not working." Watch "on change combo box not working." New topic
Author

on change combo box not working.

Kondal reddy
Greenhorn

Joined: Sep 23, 2003
Posts: 22
hi Iam trying to do onchange selectOneMenu is not working but if I put submit button it is working?(I am using valueChangeListener).
any body can help ...when I onchange my combo box, I want to change value in down side combo box ....actually when I select state combobox, only it has to disply cities in my down combobox.
Kondal reddy
Greenhorn

Joined: Sep 23, 2003
Posts: 22
this is my JSP:


<h:selectOneMenu styleClass="selectOneMenu" id="menu1" value="#{deemListBean.tempState}" onchange="submit();" valueChangeListener="#{deemListBean.listenerStateName}" >

<f:selectItems value = "#{deemListBean.getState}" />
</h:selectOneMenu>

<h:selectOneMenu styleClass="selectOneMenu" id="menu2" value="#{deemListBean.tempCity}" >

<f:selectItems value = "#{deemListBean.getCity}" />
</h:selectOneMenu>

<hx:commandExButton type="submit" value="Submit"
styleClass="commandExButton" id="button1"></hx:commandExButton>


And my Backing Bean is:


public void listenerStateName(ValueChangeEvent vce){


System.out.println("inside listenerStateName");
String value = "";

value = (String)vce.getNewValue();

System.out.println("********* The new Value is = "+value);
FacesContext fc = FacesContext.getCurrentInstance();
fc.renderResponse();
deemListBO= this.serviceLocator.getConcreteDeemListService().getCity(value);
setCity(deemListBO.getCity());
System.out.println("********* The new Value is = "+city);



}

any body can help.
Kondal reddy
Greenhorn

Joined: Sep 23, 2003
Posts: 22
this is my JSP:


<h:selectOneMenu styleClass="selectOneMenu" id="menu1" value="#{deemListBean.tempState}" onchange="submit();" valueChangeListener="#{deemListBean.listenerStateName}" >

<f:selectItems value = "#{deemListBean.getState}" />
</h:selectOneMenu>

<h:selectOneMenu styleClass="selectOneMenu" id="menu2" value="#{deemListBean.tempCity}" >

<f:selectItems value = "#{deemListBean.getCity}" />
</h:selectOneMenu>

<hx:commandExButton type="submit" value="Submit"
styleClass="commandExButton" id="button1"></hx:commandExButton>


And my Backing Bean is:


public void listenerStateName(ValueChangeEvent vce){


System.out.println("inside listenerStateName");
String value = "";

value = (String)vce.getNewValue();

System.out.println("********* The new Value is = "+value);
FacesContext fc = FacesContext.getCurrentInstance();
fc.renderResponse();
deemListBO= this.serviceLocator.getConcreteDeemListService().getCity(value);
setCity(deemListBO.getCity());
System.out.println("********* The new Value is = "+city);



}

any body can help.
Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
what is the scope of your managed bean?


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
JR Yalbets
Greenhorn

Joined: Oct 31, 2006
Posts: 5
Add



to the selectOneMenu tag and it should work. This will "short circuit" the lifecyle and be handled right away instead of being queued and processed later when submitted.
 
wood burning stoves
 
subject: on change combo box not working.
 
Similar Threads
regarding combobox in frame
How to insert at runtime using AJAX
How to Update multiple rows of a table in jsp
Can I make drop-down of JCombobox wider than text field?
html:select event issue - I am not sure which event to use to remove focus