This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: on change combo box not working.
 
Similar Threads
html:select event issue - I am not sure which event to use to remove focus
regarding combobox in frame
Can I make drop-down of JCombobox wider than text field?
How to insert at runtime using AJAX
How to Update multiple rows of a table in jsp