Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

onclick event of command button change the state of radio button but onchange doe not

 
MuthuKumaraSamy Raja
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using JSF 1.2, I have a list of items in SelectManyMenu and one SelectOneRadio button saying ascending/descending.
I want to change the state of this radio button based on the value of Selectitems.
When I try this with actionListener of command button, it changes the state of the Radio buttons.
The same thing when I try with valueChangeListener of selectManyMenu nothing works for me.
Please help me to find out the reason and the solution for how to achieve this effect.
Attached my sample code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<body>
<hutputText value="Test" />
<f:view contentType="text/html">
<h:form>
<h:selectManyMenu id="rightSelectBox" style="margin-left: 5px; margin-top:2px; width: 200px; height: 250px; overflow: auto; " onchange ="this.form.submit();" valueChangeListener ="#{tableLayoutController.changeDirection}"> <f:selectItem itemValue="A" itemLabel="A" /> <f:selectItem itemValue="B" itemLabel="B" /> <f:selectItem itemValue="C" itemLabel="C" /> <f:selectItem itemValue="D" itemLabel="D" /> </h:selectManyMenu> <div style="height: 10px;"></div>
<h:commandButton value="Test" actionListener="#{tableLayoutController.change}"/>
<h:selectOneRadio id="sortOrderAsc" value="#{tableLayoutController.sortOrder}"> <f:selectItem itemValue="ascending" itemLabel="Ascending" /> <f:selectItem itemValue="descending" itemLabel="Descending" /> </h:selectOneRadio>

</h:form>
</f:view>
</body>
</html>

And the Bean class is doing the following


public void changeDirection(ValueChangeEvent pActionEvent)
{
System.out.println(" Test name " + getName());
if ("A".equals(getName()) || "C".equals(getName())) {
System.out.println(" ASC ");
setSortOrder("ascending");
} else {
System.out.println(" DESC ");
setSortOrder("descending");
}
change(null);
}

public void change(ActionEvent pActionEvent)
{
System.out.println(" Test name " + getName());
if ("A".equals(getName()) || "C".equals(getName())) {
System.out.println(" ASC ");
setSortOrder("ascending");
} else {
System.out.println(" DESC ");
setSortOrder("descending");
}
}

Can anyone help me to solve this problem
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic