• Post Reply Bookmark Topic Watch Topic
  • New Topic

Null first value in a SelectOneMenu  RSS feed

Anoop V. Kumar
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have implemented a SelectOneMenu which displays some ids as the label and the value contained are actual objects that I have created. The objects are my business objects and non-string. It works fine.

Now I wanted to include the first item in the SelectOneMenu as: "Choose one" with a null or "" value - but I get NullPointerException.

Here is the jsp:

<h:selectOneMenu id="selectedModel"
<f:selectItem itemLabel="Choose a model" itemValue=""/>
<f:selectItems value="#{modelBean.models}" />

I have made changes in my converter to return a null Model object if the value is "". (this was after I started getting ClassCastExceptions) But still doesnt work.

Also - in my logs I see that it is calling my converter's getAsString - should it not be calling the getAsObject method??

Has anybody managed to include a null value in a selectOneMenu which takes actual objects for the values?? Please let me know how you have done it

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!