*
The moose likes JSF and the fly likes datatables and selectOneMenu default Value Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "datatables and selectOneMenu default Value Problem" Watch "datatables and selectOneMenu default Value Problem" New topic
Author

datatables and selectOneMenu default Value Problem

Tris debnam
Greenhorn

Joined: Apr 09, 2006
Posts: 3
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

Joined: Aug 03, 2002
Posts: 425
Does anybody has the answer to this problem.

Thanks,
Rahul


Rahul Juneja
ThoughtClicks - http://techlabs.thoughtclicks.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: datatables and selectOneMenu default Value Problem