• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

datatables and selectOneMenu default Value Problem

 
Tris debnam
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having trouble with a datatable and selectOneMenu's inside the datatable. Specifically the issue is that the selection of the value in the selectOneMenu is not selecting the specified value when it is within the datatable. The code works when the selectOneMenu is outside of the datatable but it fails to work when inside. Can anyone tell me why this is the case? Thanks in advance.

A cut and paste of the jsp file is:

<f:view>
<html>
<body><h:form>
<h ataTable value="#{TestMenuSelect.aldm}" var="testTable">
<h:column>
<h utputText value="#{testTable.x}"/>
</h:column>
<h:column>
<h:selectOneMenu id="menu" binding="#{TestMenuSelect.menu}">
<f:selectItems value="#{TestMenuSelect.items}"/>
</h:selectOneMenu>
</h:column>
</h ataTable>

<h utputLabel value="Outside of the dataTable the selectOneMenu is: "/>
<h:selectOneMenu id="out" binding="#{TestMenuSelect.menu}">
<f:selectItems value="#{TestMenuSelect.items}"/>
</h:selectOneMenu>
</h:form></body>
</html>
</f:view>

The ManagedBean is:

public class TestMenuSelect {
private HtmlSelectOneMenu menu = new HtmlSelectOneMenu();
private SelectItem [] items = null;
private ArrayDataModel aldm = new ArrayDataModel();

public TestMenuSelect() {
items = new SelectItem[]{
new SelectItem("0", ""),
new SelectItem("1", "brown"),
new SelectItem("2", "Green"),
new SelectItem("3", "Red")};
menu.setValue("2");
ArrayList al = new ArrayList();
al.add(new BeanIt("ZERO"));
al.add(new BeanIt("ONE"));
al.add(new BeanIt("TWO"));
aldm.setWrappedData(al.toArray());
}

public void setMenu(HtmlSelectOneMenu menu) {
this.menu = menu;
}

public HtmlSelectOneMenu getMenu() {
return menu;
}

public void setItems(SelectItem[] items) {
this.items = items;
}

public SelectItem[] getItems() {
return items;
}

public void setAldm(ArrayDataModel aldm) {
this.aldm = aldm;
}

public ArrayDataModel getAldm() {
return aldm;
}

public class BeanIt {
String x;
public BeanIt(String a) { x = a; }
public String getX() { return x; }
}
}
 
Rahul Juneja
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anybody has the answer to this problem.

Thanks,
Rahul
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic