I may be missing something here but I'm quite sure that in some
situations Moharra will handle a null value in a SelectOne because I
use it in a number of situations in my applications. In my apps I'm
usually using f:selectItems and my values aren't "Long" so maybe that
is why null values work for me? Either way whether since the spec
doesn't explicitly say what to do with null selectItem values I think
the correct behavior should be to preserve and correctly select null
values. Especially since I'm pretty sure that in some situations that
is the current behavior so if nothing else I think we should be
consistent here.
Thoughts?
Mike
On Tue, Feb 12, 2008 at 12:20 PM, Roger Kitain <Roger.Kitain_at_sun.com> wrote:
> Hello Mark -
>
> The spec says nothing about f:selectItem with null values.
> So, I do not think it is a bug in Moharra.
> However, for that use case, you could assign some number "0" - so you
> would have something like:
>
>
> <h:selectOneMenu value="#{bean.count}"
> valueChangeListener="#{bean.valueChangeListener}">
> <f:selectItem itemValue="1"/>
> <f:selectItem itemValue="2"/>
> <f:selectItem itemValue="3"/>
> <f:selectItem itemValue="4"/>
> <f:selectItem itemValue="5"/>
> <f:selectItem itemValue="0" itemLabel="Not specified"/>
> </h:selectOneMenu>
>
> If you still feel the spec could be clarified in this area, you can
> always file a spec issue in our issue tracker:
>
> https://javaserverfaces-spec-public.dev.java.net/
>
> Ryan Lubke wrote:
>
>
> >
> >
> > -------- Original Message --------
> > Subject: h:selectOneMenu selection and f:selectItem with null
> > itemValue
> > Date: Wed, 06 Feb 2008 15:03:13 -0700
> > From: Mark Collette <mark.collette_at_icesoft.com>
> > Reply-To: dev_at_javaserverfaces.dev.java.net
> > To: dev_at_javaserverfaces.dev.java.net
> >
> >
> >
> > A user filed a bug report with ICEfaces about the behaviour of our
> > ice:selectOneMenu component, and when I went to investigate it versus
> > stock JSF behaviour, I found that the unexpected behaviour was
> > actually with stock JSF 1.2. So, I'm hoping that I can get some
> > guidance here.
> >
> > Basically, if you want to use h:selectOneMenu to select from a list of
> > Long values, but also want to accomodate selecting null, there's a
> > problem. You can not make an f:selectItem with itemValue="#{null}"
> > because it will then use the itemLabel as the itemValue, so you'll be
> > trying to match h:selectOneMenu's value value to "Not specified"
> > instead of null. So then if you use itemValue="" it has inconsistent
> > behaviour. If you select it, then the bean will actually get null, in
> > both the property setter and the ValueChangeEvent, as desired. But
> > when it renders, it will not make the "Not specified" option be
> > selected. Nothing will be selected. Well, the browser will select by
> > default the first thing in the menu, which will be "1" in this case.
> >
> > My questions are, what is the desired behaviour, selecting "Not
> > specified", or nothing at all? Is this a bug in Mojarra, or is this
> > what the spec desires?
> >
> > Here's the example code:
> >
> > <html xmlns="http://www.w3.org/1999/xhtml"
> > xmlns:f="http://java.sun.com/jsf/core"
> > xmlns:h="http://java.sun.com/jsf/html">
> > <body>
> > <h:form>
> > <h:selectOneMenu value="#{bean.count}"
> > valueChangeListener="#{bean.valueChangeListener}">
> > <f:selectItem itemValue="1"/>
> > <f:selectItem itemValue="2"/>
> > <f:selectItem itemValue="3"/>
> > <f:selectItem itemValue="4"/>
> > <f:selectItem itemValue="5"/>
> > <f:selectItem itemValue="" itemLabel="Not specified"/>
> > </h:selectOneMenu>
> > <h:commandButton value="Submit"/>
> > </h:form>
> > </body>
> > </html>
> >
> > public class Bean {
> > private Long count = null;
> > public Long getCount() { return count; }
> > public void setCount(Long c) { count = c; }
> >
> > public void valueChangeListener(ValueChangeEvent event) {
> > System.out.println("valueChangeListener() newValue: " +
> > event.getNewValue());
> > }
> > }
> >
> >
> > Mark Collette
> > http://mark-icefaces-reflections.blogspot.com/
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> > For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
>
>