You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Marcelo Romulo Fernandes <ma...@yahoo.com> on 2008/06/18 15:12:25 UTC
How to set null value to selectItem in myfaces 1.2
Hi everyone,
I used the following code to set "null" to the Boolean property filterCancelledStatus of userListPageBean. It worked well when i was working with myfaces 1.1, but when i migrate to myfaces 1.2, the value is set to False, why? The same problem occurs with Long properties because with myfaces 1.2 the value 0 is set.
<h:selectOneMenu id="filterCancelledStatus" styleClass="base-h-selectOneMenu" value="#{userListPageBean.filterCancelledStatus}">
<f:selectItem itemValue="" itemLabel="#{msg['label.all']}"/>
<f:selectItems value="#{userPageBean.cancelledStatusSelectItemList}" />
</h:selectOneMenu>
Any suggestions?
Thanks in advance.
´s marcelo
Re: How to set null value to selectItem in myfaces 1.2
Posted by Mike Kienenberger <mk...@gmail.com>.
Unless you have a converter, you're not setting the value to null,
you're setting the value to empty string. There's a variety of ways
to handle it. One way might be to use itemValue="#{someBean.null}"
and implement public Object someBean.getNull() { return null; }
Another way is to use a converter and convert empty string into null
values, or you can use a special placeholder value instead of empty
string.
On 6/18/08, Marcelo Romulo Fernandes <ma...@yahoo.com> wrote:
>
> Hi everyone,
>
> I used the following code to set "null" to the Boolean property
> filterCancelledStatus of userListPageBean. It worked well when i was working
> with myfaces 1.1, but when i migrate to myfaces 1.2, the value is set to
> False, why? The same problem occurs with Long properties because with
> myfaces 1.2 the value 0 is set.
>
> <h:selectOneMenu id="filterCancelledStatus"
> styleClass="base-h-selectOneMenu"
> value="#{userListPageBean.filterCancelledStatus}">
> <f:selectItem itemValue=""
> itemLabel="#{msg['label.all']}"/>
> <f:selectItems
> value="#{userPageBean.cancelledStatusSelectItemList}" />
> </h:selectOneMenu>
>
> Any suggestions?
> Thanks in advance.
>
> ´s marcelo
>
>