• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

datatables and selectOneMenu default Value Problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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; }
}
}
 
Ranch Hand
Posts: 425
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does anybody has the answer to this problem.

Thanks,
Rahul
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic