Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dymaic SelectOnelist and Onchange event

 
chetan padhye
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic