Hi everybody,

I'd like to use a dropdown menu in my jsp page, therefor I added 

<h:selectOneMenu id="selectModifier" value="#{bean.currentItem}">
  <f:selectItems value="#{bean.itemList}" />
</h:selectOneMenu> 

to my page. The bean provides getter and setters for both properties, whereby
currentItem is of type SelectItem and itemList is an ArrayList containing
SelectItems. 

Just a static example copied from jsftags-guide into my bean class:

private SelectItem currentItem;
        
private ArrayList itemList;


public SelectItem getCurrentItem() {
  return new SelectItem("4runner","Toyota 4Runner","Toyota 4Runner - suv");
}

public void setCurrentItem(SelectItem currentItem) {
  this.currentItem = currentItem;
}

public ArrayList getItemList() {
  this.itemList=new ArrayList();
  this.itemList.add(new SelectItem("accord","Honda Accord","Honda Accord -
sedan"));
  this.itemList.add(new SelectItem("4runner","Toyota 4Runner","Toyota 4Runner -
suv"));
  this.itemList.add(new SelectItem("nissan-z","Nissan Z350","Nissan Z350 -
sports"));
  return itemList;
}

public void setItemList(ArrayList itemList) {
  this.itemList = itemList;
}

But whenever I try to render the page, I'll get an
'java.lang.IllegalArgumentException: Value is no String and component
treetestformdb:selectModifier does not have a Converter' Exception.
IMHO the returned SelectItem should be rendered as a String automatically
without the need to attach a custom converter.

What am I'm missing here? I'm banging my head for an hour now,

Kurt



Reply via email to