File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

datatables and selectOneMenu default Value Problem

Tris debnam

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:

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

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

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")};
ArrayList al = new ArrayList();
al.add(new BeanIt("ZERO"));
al.add(new BeanIt("ONE"));
al.add(new BeanIt("TWO"));

public void setMenu(HtmlSelectOneMenu 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.


Rahul Juneja
ThoughtClicks -
I agree. Here's the link:
subject: datatables and selectOneMenu default Value Problem
It's not a secret anymore!