This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSF and the fly likes Dymaic SelectOnelist and Onchange event Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Dymaic SelectOnelist and Onchange event " Watch "Dymaic SelectOnelist and Onchange event " New topic
Author

Dymaic SelectOnelist and Onchange event

chetan padhye
Greenhorn

Joined: Apr 17, 2008
Posts: 15
Hi ,


I made like this check box and below that the list checkbox select event changes the list of cars ...it works .
But now on select of car from list it calls changeCurrentProfile ( ) , valueChangeListener
but for the other list which comes after selecting check box on its select it is Not working ...

I have observed this IF i populate the SelectItem list in bean constructor then only for those items it work if dynamically added some select item on select of check box
these item value should be one value list have in constructor ...for other values added it gives validation error ...i dont have any validation on form


<h:selectBooleanCheckbox id="adminCheckBox" valueChangeListener="#{carProfileAction.changeCarListByType}"> Show Old
<a4j:support event="onclick" reRender="carProfileAction" ></a4j:support>
</h:selectBooleanCheckbox>


<h:selectOneListbox id="carProfileAction" valueChangeListener="#{carProfileAction.changeCurrentProfile}" >
<f:selectItems value="#{adminProfileAction.managersList}"/>
<a4j:support event="onchange" reRender="addNewCarGrid"></a4j:support>
</h:selectOneListbox>





public BeanConstructor()
{
managersList = new ArrayList<SelectItem>();
managersList.add(new SelectItem("car1"));
managersList.add(new SelectItem("Car2"));
managersList.add(new SelectItem("Hi"));
}

public void changeCarListByType(ValueChangeEvent e)
{

if(FALSE.equalsIgnoreCase(e.getNewValue().toString()))
{managersList = new ArrayList<SelectItem>();
managersList.add(new SelectItem("car1"));
managersList.add(new SelectItem("Car2"));
setmanagersList(managersList);
}else{
managersList = new ArrayList<SelectItem>();
managersList.add(new SelectItem("Hi"));
managersList.add(new SelectItem("bye"));
setmanagersList(managersList);
}
}


public void changeCurrentProfile (ValueChangeEvent e)
{

System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$:- Select value is :--- "+ e.getNewValue().toString());
}


In this case for onchange event changeCurrentProfile () receives value for car1, car2 and Hi ....... for select of 'bye' it gives validation error .... and no value in changeCurrentProfile (ValueChangeEvent e)

Please can anyone have any input on this issue ?

Thanks ...
vyjayanthi chander
Greenhorn

Joined: Jun 06, 2009
Posts: 1
HI,
I am having the similar problem. Did you Solve it? Please let me know if you have found any solution. I need it very urgently.

Thanks

chetan padhye wrote:Hi ,


I made like this check box and below that the list checkbox select event changes the list of cars ...it works .
But now on select of car from list it calls changeCurrentProfile ( ) , valueChangeListener
but for the other list which comes after selecting check box on its select it is Not working ...

I have observed this IF i populate the SelectItem list in bean constructor then only for those items it work if dynamically added some select item on select of check box
these item value should be one value list have in constructor ...for other values added it gives validation error ...i dont have any validation on form


<h:selectBooleanCheckbox id="adminCheckBox" valueChangeListener="#{carProfileAction.changeCarListByType}"> Show Old
<a4j:support event="onclick" reRender="carProfileAction" ></a4j:support>
</h:selectBooleanCheckbox>


<h:selectOneListbox id="carProfileAction" valueChangeListener="#{carProfileAction.changeCurrentProfile}" >
<f:selectItems value="#{adminProfileAction.managersList}"/>
<a4j:support event="onchange" reRender="addNewCarGrid"></a4j:support>
</h:selectOneListbox>





public BeanConstructor()
{
managersList = new ArrayList<SelectItem>();
managersList.add(new SelectItem("car1"));
managersList.add(new SelectItem("Car2"));
managersList.add(new SelectItem("Hi"));
}

public void changeCarListByType(ValueChangeEvent e)
{

if(FALSE.equalsIgnoreCase(e.getNewValue().toString()))
{managersList = new ArrayList<SelectItem>();
managersList.add(new SelectItem("car1"));
managersList.add(new SelectItem("Car2"));
setmanagersList(managersList);
}else{
managersList = new ArrayList<SelectItem>();
managersList.add(new SelectItem("Hi"));
managersList.add(new SelectItem("bye"));
setmanagersList(managersList);
}
}


public void changeCurrentProfile (ValueChangeEvent e)
{

System.out.println("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$:- Select value is :--- "+ e.getNewValue().toString());
}


In this case for onchange event changeCurrentProfile () receives value for car1, car2 and Hi ....... for select of 'bye' it gives validation error .... and no value in changeCurrentProfile (ValueChangeEvent e)

Please can anyone have any input on this issue ?

Thanks ...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dymaic SelectOnelist and Onchange event
 
Similar Threads
ValueChangeEvent not changing value
Use multiple scopes in a page?
Help - question on selectOneListbox and page reloads
h selectBooleanCheckbox valueChangeListener not working properly
noSuchElementException when using SelectoneMenu