dev@javaserverfaces.java.net

Re: [Fwd: h:selectOneMenu selection and f:selectItem with null itemValue]

From: Michael Youngstrom <youngm_at_gmail.com>
Date: Tue, 19 Feb 2008 13:55:35 -0700

> It actually does coerce to the empty String to null, for the Long bean
> property. If I select "Empty" then null goes into my bean. My problem is
> that the coercion is not consistent the other way. When it is deciding
> which item should be selected, "Empty" is not selected from value being
> null.

This is because for you the itemLabel was being rendered as the value right?

>
> ><h:selectOneMenu value="#{someBacking.value}">
> > <f:selectItem itemValue="10" itemLabel="10"/>
> > <f:selectItem itemLabel="Null"/>
> > <f:selectItem itemValue="" itemLabel="Empty"/>
> ></h:selectOneMenu>
> >
> Does "null" actually evaluate to null? Wouldn't one have to use "#{null}"?

"Null" is the itemLabel. You'll notice I didn't provide an itemValue
so I guess I was assuming the itemValue would be null if you didn't
provide one (not exactly sure off hand if that's how it works). But
for example purposes you can assume itemValue="#{null}"

Mike