You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Srinivas V <vu...@gmail.com> on 2007/02/22 05:47:51 UTC

ERROR: Value is not a valid option

Hi All,
Please help me!!
I am having an issue with SelectOneMenu.

I have installed JSF 1.1.5-SNAPSHOT,Tomahawk1.1.5- SNAPSHOT and
tomahawk-sandbox-1.1.5-SNAPSHOT.

Previously i had myfaces1.1 jar
I dint have issue with selectOneMenu before.

Now when I submit the page, I am getting this jsf validation error:
*Container:"Value is not a valid option"*
for a selectOneMenu even if i select some option.

code:
<h:panelGroup rendered="#{reportsBean.renderContainerType}">
   <x:outputLabel for="containerfilter" value="#{
msgBundle.EPCMgr_ContainerLbl}:" styleClass="standard_text_bold"/>
   <f:verbatim><br/></f:verbatim>
   <h:selectOneMenu id="containerfilter" value="#{reportsBean.containerType}"
immediate="true" disabled="#{ reportsBean.optionDisabled }"
styleClass="standard_input">
    <f:selectItem itemValue="" itemLabel=" " />
    <f:selectItems value="#{reportsBean.containerTypeList }"/>
   </h:selectOneMenu>
  </h:panelGroup>

Can anybody tell me why it is happening?

regards
srinivas

Re: [Solved] ERROR: Value is not a valid option

Posted by Mike Kienenberger <mk...@gmail.com>.
The log message was this:

URL: http://svn.apache.org/viewvc?view=rev&rev=449566
Log:
fix for MYFACES-1328 : UISelectOne and UISelectMany fail with custom
converter that returns java.lang.String from getAsObject() method.
Thanks to Nikolay Petrov for tracking this down.

http://issues.apache.org/jira/browse/MYFACES-1328


On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
> More info.  I took a look at the code.  Revision 449566, repo path...
>
> https://svn.apache.org/repos/asf/myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectOne.java
>
> The original code does the following:
>
> _ValueConverter converter = new _ValueConverter()
>         {
>             public Object getConvertedValue(FacesContext context, String
> value)
>             {
>                  return
> UISelectOne.this.getConvertedValue(context, value);
>             }
>         };
>
>         // selected value must match to one of the available options
>         if (!_SelectItemsUtil.matchValue(context, value,
> new _SelectItemsIterator(this), converter))
>
> In summary, inside 'matchValue', this attempts to convert the value based on
> the bound value type in the backing bean.  So, in my case, it recognizes a
> Short, and attempts to convert the string to a short.  r449566 looks like
> the following...
>
> // selected value must match to one of the available options
>         if (!_SelectItemsUtil.matchValue(value, new
> _SelectItemsIterator(this)))
>
> The converter isn't being used anymore.
>
> Now, this revision was checked in on 9/25/06.  That looks a little old to be
> showing up in 1.1.5-SNAPSHOT.  The file I have locally is 11/25/06.  I
> decompiled it and it does have the old version.  I think on 11/25 I did a
> local build of 1.1.5-SNAPSHOT and that may be insulating me from the change.
>
> Not sure.  Anyway, the select menu is going to be more strict in this
> version.  Is that "correct", or should it attempt the conversion?  I tried
> putting in a number converter, but it choked as well.  The message was very
> long, but it looked like it was putting out a Long, and failing with the
> attempted to setting of the Short.  I could write my own converter, but the
> old way was a lot easier.  Just want to make sure that's my only option
> before I start hacking away.
>
> Thanks,
> -Kevin
>
>
> On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
> > I'm having the same problem.  I had some code that was working for a long
> time with 1.1.5-SNAPSHOT, and now I'm getting that error.
> >
> > <h:selectOneMenu
> value="#{shared$FavoriteDocumentAdd.documentTypeId}"
> onchange="toggleInputRow()" id="documentTypeSelect"
> style="background-color:rgb(204,204,255)">
> >     <f:selectItem itemLabel="Website URL" itemValue="3"/>
> >     <f:selectItem itemLabel="File Upload" itemValue="1"/>
> >     <f:selectItem itemLabel="Description Only" itemValue="2"/>
> > </h:selectOneMenu>
> >
> > The value being set is a short.  Essentially it looks like the code was
> doing an automatic conversion before, but now chokes.
> >
> > I just reverted the code to 1.1.5-SNAPSHOT, and it works again.  I'm going
> to try to take a quick look at the differences between UISelectOne.java
> between those two versions, but in practice I've found with any large code
> base, it'll take a little time to really understand the layout.
> >
> >
> >
> > On 2/26/07, CarlHowarth <ca...@dlapiper.com> wrote:
> > >
> > > Hi,
> > >
> > > I am having this problem too. My select one is set up as follows:
> > >
> > > <h:selectOneMenu id="regionList" binding="#{Bean.regionListUI}"
> > > value="#{Bean.region}" >
> > >   <f:converter converterId=" myapp.Region"/>
> > >   <f:selectItem itemValue="0" itemLabel="(all)"/>
> > >   <t:selectItems var="r" itemLabel="#{ r.name}" itemValue="#{
> r.idString}"
> > > value="#{applicationBean.regionMap}" />
> > >   <f:attribute name="fieldRef" value="Region List"/>
> > > </h:selectOneMenu>
> > >
> > > - This was working fine with 1.1.4 but since the upgrade to 1.1.5 it now
> > > falls over.
> > > - The application bean is at application scope, so the values should
> always
> > > be available.
> > > - The converter changes an ID to a region and vice versa.
> > > - The page loads up fine, I only have the problem when I select a
> command
> > > button that runs an action listener.
> > > - I use a '<t:saveState value="#{Bean_track}"/>' for my request-scoped
> bean.
> > > - The region bean implements a working 'equals' method.
> > > - If I select the manually populated select item, (all), it works
> correctly.
> > >
> > > My converter is like this:
> > >
> > > public final static String CONVERTER_ID = "myapp.Region";
> > >     public Object getAsObject(FacesContext facesContext, UIComponent
> > > uiComponent, String string)
> > >             throws ConverterException {
> > >
> > >        return
> > >
> JSFUtils.getAppBackingBean().getRegionMap().get(Integer.parseInt(string));
> > >     }
> > >
> > >     public String getAsString(FacesContext facesContext, UIComponent
> > > uiComponent, Object object)
> > >             throws ConverterException {
> > >         if (object == null) {
> > >             return null;
> > >         } else if (object instanceof Region) {
> > >             final Region region = (Region) object;
> > >             return region.getId().toString();
> > >         }
> > >
> > >         return object.toString();
> > >     }
> > >
> > >
> > > I am at a complete loss at the moment, so any thoughts on what could be
> > > causing this error would be appreciated.
> > >
> > > Thanks, Carl
> > >
> > >
> > >
> > > Ernst Fastl wrote:
> > > >
> > > > Hi,
> > > >
> > > > I have had a similar problem recently. Generally happens if the
> > > > application is not able to find the selected value in the List of
> > > > selectItems.
> > > > This can be due to 2 possible situations:
> > > >
> > > > 1. The list is not available during validation
> > > > -> try using a <t:saveState value="#{reportsBean.containerTypeList }"
> />
> > > > to ensure it is
> > > >
> > > > 2. The values of the selectItems (getValue() and setValue()) do not
> > > > contain
> > > > Strings and there is no converter:
> > > >
> > > > -> use a corresponding converter e.g. for Long - LongConverter
> > > > for the selectOneMenu
> > > >
> > > > hope that helps
> > > >
> > > > regards
> > > >
> > > > Ernst
> > > >
> > > > On 2/22/07, Srinivas V <vu...@gmail.com> wrote:
> > > >> Hi All,
> > > >> Please help me!!
> > > >> I am having an issue with SelectOneMenu.
> > > >>
> > > >> I have installed JSF 1.1.5-SNAPSHOT,Tomahawk1.1.5- SNAPSHOT and
> > > >> tomahawk-sandbox-1.1.5-SNAPSHOT.
> > > >>
> > > >> Previously i had myfaces1.1 jar
> > > >> I dint have issue with selectOneMenu before.
> > > >>
> > > >> Now when I submit the page, I am getting this jsf validation error:
> > > >> Container:"Value is not a valid option"
> > > >> for a selectOneMenu even if i select some option.
> > > >>
> > > >> code:
> > > >> <h:panelGroup rendered="#{reportsBean.renderContainerType}">
> > > >>    <x:outputLabel for="containerfilter"
> > > >> value="#{msgBundle.EPCMgr_ContainerLbl }:"
> > > >> styleClass="standard_text_bold"/>
> > > >>    <f:verbatim><br/></f:verbatim>
> > > >>    <h:selectOneMenu id="containerfilter"
> > > >> value="#{ reportsBean.containerType}" immediate="true" disabled="#{
> > > >> reportsBean.optionDisabled }" styleClass="standard_input">
> > > >>     <f:selectItem itemValue="" itemLabel=" " />
> > > >>     <f:selectItems value="#{reportsBean.containerTypeList }"/>
> > > >>    </h:selectOneMenu>
> > > >>   </h:panelGroup>
> > > >>
> > > >> Can anybody tell me why it is happening?
> > > >>
> > > >> regards
> > > >> srinivas
> > > >>
> > > >
> > > >
> > >
> > > --
> > > View this message in context:
> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9155607
> > > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> > >
> > >
> >
> >
>
>

Re: [Solved] ERROR: Value is not a valid option

Posted by Kevin Galligan <kg...@gmail.com>.
More info.  I took a look at the code.  Revision 449566, repo path...

https://svn.apache.org/repos/asf/myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectOne.java

The original code does the following:

_ValueConverter converter = new _ValueConverter()
        {
            public Object getConvertedValue(FacesContext context, String
value)
            {
                return UISelectOne.this.getConvertedValue(context, value);
            }
        };

        // selected value must match to one of the available options
        if (!_SelectItemsUtil.matchValue(context, value, new
_SelectItemsIterator(this), converter))

In summary, inside 'matchValue', this attempts to convert the value based on
the bound value type in the backing bean.  So, in my case, it recognizes a
Short, and attempts to convert the string to a short.  r449566 looks like
the following...

// selected value must match to one of the available options
        if (!_SelectItemsUtil.matchValue(value, new
_SelectItemsIterator(this)))

The converter isn't being used anymore.

Now, this revision was checked in on 9/25/06.  That looks a little old to be
showing up in 1.1.5-SNAPSHOT.  The file I have locally is 11/25/06.  I
decompiled it and it does have the old version.  I think on 11/25 I did a
local build of 1.1.5-SNAPSHOT and that may be insulating me from the change.

Not sure.  Anyway, the select menu is going to be more strict in this
version.  Is that "correct", or should it attempt the conversion?  I tried
putting in a number converter, but it choked as well.  The message was very
long, but it looked like it was putting out a Long, and failing with the
attempted to setting of the Short.  I could write my own converter, but the
old way was a lot easier.  Just want to make sure that's my only option
before I start hacking away.

Thanks,
-Kevin

On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
>
> I'm having the same problem.  I had some code that was working for a long
> time with 1.1.5-SNAPSHOT, and now I'm getting that error.
>
> <h:selectOneMenu value="#{shared$FavoriteDocumentAdd.documentTypeId}"
> onchange="toggleInputRow()" id="documentTypeSelect"
> style="background-color:rgb(204,204,255)">
>     <f:selectItem itemLabel="Website URL" itemValue="3"/>
>     <f:selectItem itemLabel="File Upload" itemValue="1"/>
>     <f:selectItem itemLabel="Description Only" itemValue="2"/>
> </h:selectOneMenu>
>
> The value being set is a short.  Essentially it looks like the code was
> doing an automatic conversion before, but now chokes.
>
> I just reverted the code to 1.1.5-SNAPSHOT, and it works again.  I'm going
> to try to take a quick look at the differences between UISelectOne.javabetween those two versions, but in practice I've found with any large code
> base, it'll take a little time to really understand the layout.
>
> On 2/26/07, CarlHowarth <ca...@dlapiper.com> wrote:
> >
> >
> > Hi,
> >
> > I am having this problem too. My select one is set up as follows:
> >
> > <h:selectOneMenu id="regionList" binding="#{Bean.regionListUI}"
> > value="#{Bean.region}" >
> >   <f:converter converterId=" myapp.Region"/>
> >   <f:selectItem itemValue="0" itemLabel="(all)"/>
> >   <t:selectItems var="r" itemLabel="#{r.name}" itemValue="#{ r.idString
> > }"
> > value="#{applicationBean.regionMap}" />
> >   <f:attribute name="fieldRef" value="Region List"/>
> > </h:selectOneMenu>
> >
> > - This was working fine with 1.1.4 but since the upgrade to 1.1.5 it now
> > falls over.
> > - The application bean is at application scope, so the values should
> > always
> > be available.
> > - The converter changes an ID to a region and vice versa.
> > - The page loads up fine, I only have the problem when I select a
> > command
> > button that runs an action listener.
> > - I use a '<t:saveState value="#{Bean_track}"/>' for my request-scoped
> > bean.
> > - The region bean implements a working 'equals' method.
> > - If I select the manually populated select item, (all), it works
> > correctly.
> >
> > My converter is like this:
> >
> > public final static String CONVERTER_ID = "myapp.Region";
> >     public Object getAsObject(FacesContext facesContext, UIComponent
> > uiComponent, String string)
> >             throws ConverterException {
> >
> >        return
> > JSFUtils.getAppBackingBean().getRegionMap().get(Integer.parseInt
> > (string));
> >     }
> >
> >     public String getAsString(FacesContext facesContext, UIComponent
> > uiComponent, Object object)
> >             throws ConverterException {
> >         if (object == null) {
> >             return null;
> >         } else if (object instanceof Region) {
> >             final Region region = (Region) object;
> >             return region.getId().toString();
> >         }
> >
> >         return object.toString();
> >     }
> >
> >
> > I am at a complete loss at the moment, so any thoughts on what could be
> > causing this error would be appreciated.
> >
> > Thanks, Carl
> >
> >
> >
> > Ernst Fastl wrote:
> > >
> > > Hi,
> > >
> > > I have had a similar problem recently. Generally happens if the
> > > application is not able to find the selected value in the List of
> > > selectItems.
> > > This can be due to 2 possible situations:
> > >
> > > 1. The list is not available during validation
> > > -> try using a <t:saveState value="#{reportsBean.containerTypeList }"
> > />
> > > to ensure it is
> > >
> > > 2. The values of the selectItems (getValue() and setValue()) do not
> > > contain
> > > Strings and there is no converter:
> > >
> > > -> use a corresponding converter e.g. for Long - LongConverter
> > > for the selectOneMenu
> > >
> > > hope that helps
> > >
> > > regards
> > >
> > > Ernst
> > >
> > > On 2/22/07, Srinivas V <vu...@gmail.com> wrote:
> > >> Hi All,
> > >> Please help me!!
> > >> I am having an issue with SelectOneMenu.
> > >>
> > >> I have installed JSF 1.1.5-SNAPSHOT,Tomahawk1.1.5- SNAPSHOT and
> > >> tomahawk-sandbox-1.1.5-SNAPSHOT.
> > >>
> > >> Previously i had myfaces1.1 jar
> > >> I dint have issue with selectOneMenu before.
> > >>
> > >> Now when I submit the page, I am getting this jsf validation error:
> > >> Container:"Value is not a valid option"
> > >> for a selectOneMenu even if i select some option.
> > >>
> > >> code:
> > >> <h:panelGroup rendered="#{reportsBean.renderContainerType}">
> > >>    <x:outputLabel for="containerfilter"
> > >> value="#{msgBundle.EPCMgr_ContainerLbl }:"
> > >> styleClass="standard_text_bold"/>
> > >>    <f:verbatim><br/></f:verbatim>
> > >>    <h:selectOneMenu id="containerfilter"
> > >> value="#{ reportsBean.containerType}" immediate="true" disabled="#{
> > >> reportsBean.optionDisabled }" styleClass="standard_input">
> > >>     <f:selectItem itemValue="" itemLabel=" " />
> > >>     <f:selectItems value="#{reportsBean.containerTypeList }"/>
> > >>    </h:selectOneMenu>
> > >>   </h:panelGroup>
> > >>
> > >> Can anybody tell me why it is happening?
> > >>
> > >> regards
> > >> srinivas
> > >>
> > >
> > >
> >
> > --
> > View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9155607
> >
> > Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >
> >
>

Re: [Solved] ERROR: Value is not a valid option

Posted by Kevin Galligan <kg...@gmail.com>.
Thanks for the quick replies.  I think that clears it up.

On 2/26/07, Mike Kienenberger <mk...@gmail.com> wrote:
>
> Yes, that's how I would do it.  If you specify an itemValue, then that
> value must be of the correct type.  Ie, " " is not a containerType
> (Srinivas) and "0" is not a region (Carl).
>
> On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
> > I am using facelets.  Where would that function go?  Each f:selectItem
> > entry?
> >
> > <f:selectItem itemLabel="Website URL"
> > itemValue="#{myfn:convertStringToShort(3)}"/>
> >
> >
> >
> >
> >  On 2/26/07, Mike Kienenberger <mk...@gmail.com> wrote:
> > > Take a look at
> > http://issues.apache.org/jira/browse/MYFACES-1328.   It
> > > looks like the RI does not have this convenience conversion.   I don't
> > > know what the spec says, but that'd be the place to get a definitive
> > > answer.
> > >
> > > If you're using facelets, as a temporary workaround you could create a
> > > "convertStringToShort()" function (or whatever conversion you're
> > > expecting to have happen automatically).
> > >
> > >
> > > On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
> > > > I did try that and didn't have any luck.  I think that was due to
> the
> > fact
> > > > that I was using shorts rather than ints, but I'd have to try it
> again
> > now
> > > > that I have a better understanding of everything involved.
> > > >
> > > >  I looked at TOMAHAWK-152 briefly.  I'll have to sit down and take a
> > better
> > > > look at it.  It looks to be in the realm.  The string value of
> 'true'
> > not
> > > > matching with a boolean type value?
> > > >
> > > > I guess the bottom line is I'd like to find out if I should be using
> an
> > > > explicit converter to go from String to Short, or if the JSF api
> being
> > used
> > > > should be able to handle a simple[r] conversion like that.  It was
> doing
> > > > that conversion originally.  Does the JSF spec cover this?  Anybody
> > happen
> > > > to know what the reference implementation does?  I'd love to try it
> out,
> > but
> > > > we're trying to push this out the door, so for the near future I
> have to
> > > > focus on what's right in front of me.
> > > >
> > > >
> > > > On 2/26/07, Martin Grotzke < martin.grotzke@javakaffee.de> wrote:
> > > > > Does it work when you use itemValue="#{3}" as workaround?
> > > > >
> > > > > I also had the same problem with itemValue="true", what I think is
> > > > > http://issues.apache.org/jira/browse/TOMAHAWK-152 ...
> > > > >
> > > > > Cheers,
> > > > > Martin
> > > > >
> > > > >
> > > > > On Mon, 2007-02-26 at 11:23 -0500, Kevin Galligan wrote:
> > > > > > I'm having the same problem.  I had some code that was working
> for a
> > > > > > long time with 1.1.5-SNAPSHOT, and now I'm getting that error.
> > > > > >
> > > > > > <h:selectOneMenu
> > > > value="#{shared$FavoriteDocumentAdd.documentTypeId}"
> > > > > > onchange="toggleInputRow()" id="documentTypeSelect"
> > > > > > style="background-color:rgb(204,204,255)">
> > > > > >     <f:selectItem itemLabel="Website URL" itemValue="3"/>
> > > > > >     <f:selectItem itemLabel="File Upload" itemValue="1"/>
> > > > > >     <f:selectItem itemLabel="Description Only" itemValue="2"/>
> > > > > > </h:selectOneMenu>
> > > > > >
> > > > > > The value being set is a short.  Essentially it looks like the
> code
> > > > > > was doing an automatic conversion before, but now chokes.
> > > > > >
> > > > > > I just reverted the code to 1.1.5-SNAPSHOT, and it works
> again.  I'm
> > > > > > going to try to take a quick look at the differences between
> > > > > > UISelectOne.java between those two versions, but in practice
> I've
> > > > > > found with any large code base, it'll take a little time to
> really
> > > > > > understand the layout.
> > > > > >
> > > > > > On 2/26/07, CarlHowarth < carl.howarth@dlapiper.com> wrote:
> > > > > >
> > > > > >         Hi,
> > > > > >
> > > > > >         I am having this problem too. My select one is set up as
> > > > > >         follows:
> > > > > >
> > > > > >         <h:selectOneMenu id="regionList"
> > > > > >         binding="#{Bean.regionListUI}"
> > > > > >         value="#{ Bean.region}" >
> > > > > >           <f:converter converterId=" myapp.Region"/>
> > > > > >           <f:selectItem itemValue="0" itemLabel="(all)"/>
> > > > > >           <t:selectItems var="r" itemLabel="#{ r.name }"
> > > > > >         itemValue="#{ r.idString}"
> > > > > >         value="#{applicationBean.regionMap}" />
> > > > > >           <f:attribute name="fieldRef" value="Region List"/>
> > > > > >         </h:selectOneMenu>
> > > > > >
> > > > > >         - This was working fine with 1.1.4 but since the upgrade
> to
> > > > > >         1.1.5 it now
> > > > > >         falls over.
> > > > > >         - The application bean is at application scope, so the
> > values
> > > > > >         should always
> > > > > >         be available.
> > > > > >         - The converter changes an ID to a region and vice
> versa.
> > > > > >         - The page loads up fine, I only have the problem when I
> > > > > >         select a command
> > > > > >         button that runs an action listener.
> > > > > >         - I use a '<t:saveState value="#{Bean_track}"/>' for my
> > > > > >         request-scoped bean.
> > > > > >         - The region bean implements a working 'equals' method.
> > > > > >         - If I select the manually populated select item, (all),
> it
> > > > > >         works correctly.
> > > > > >
> > > > > >         My converter is like this:
> > > > > >
> > > > > >         public final static String CONVERTER_ID = " myapp.Region
> ";
> > > > > >             public Object getAsObject(FacesContext facesContext,
> > > > > >         UIComponent
> > > > > >         uiComponent, String string)
> > > > > >                     throws ConverterException {
> > > > > >
> > > > > >                return
> > > > > >
> > > >
> > JSFUtils.getAppBackingBean().getRegionMap().get(Integer.parseInt
> (string));
> > > > > >             }
> > > > > >
> > > > > >             public String getAsString(FacesContext facesContext,
> > > > > >         UIComponent
> > > > > >         uiComponent, Object object)
> > > > > >                     throws ConverterException {
> > > > > >                 if (object == null) {
> > > > > >                     return null;
> > > > > >                 } else if (object instanceof Region) {
> > > > > >                     final Region region = (Region) object;
> > > > > >                     return region.getId().toString();
> > > > > >                 }
> > > > > >
> > > > > >                 return object.toString();
> > > > > >             }
> > > > > >
> > > > > >
> > > > > >         I am at a complete loss at the moment, so any thoughts
> on
> > what
> > > > > >         could be
> > > > > >         causing this error would be appreciated.
> > > > > >
> > > > > >         Thanks, Carl
> > > > > >
> > > > > >
> > > > > >
> > > > > >         Ernst Fastl wrote:
> > > > > >         >
> > > > > >         > Hi,
> > > > > >         >
> > > > > >         > I have had a similar problem recently. Generally
> happens
> > if
> > > > > >         the
> > > > > >         > application is not able to find the selected value in
> the
> > > > > >         List of
> > > > > >         > selectItems.
> > > > > >         > This can be due to 2 possible situations:
> > > > > >         >
> > > > > >         > 1. The list is not available during validation
> > > > > >         > -> try using a <t:saveState
> > > > > >         value="#{reportsBean.containerTypeList }" />
> > > > > >         > to ensure it is
> > > > > >         >
> > > > > >         > 2. The values of the selectItems (getValue() and
> > setValue())
> > > > > >         do not
> > > > > >         > contain
> > > > > >         > Strings and there is no converter:
> > > > > >         >
> > > > > >         > -> use a corresponding converter e.g. for Long -
> > > > > >         LongConverter
> > > > > >         > for the selectOneMenu
> > > > > >         >
> > > > > >         > hope that helps
> > > > > >         >
> > > > > >         > regards
> > > > > >         >
> > > > > >         > Ernst
> > > > > >         >
> > > > > >         > On 2/22/07, Srinivas V <vuyyuru.srinivas@gmail.com >
> > wrote:
> > > > > >         >> Hi All,
> > > > > >         >> Please help me!!
> > > > > >         >> I am having an issue with SelectOneMenu.
> > > > > >         >>
> > > > > >         >> I have installed JSF 1.1.5-SNAPSHOT ,Tomahawk1.1.5-
> > SNAPSHOT
> > > > > >         and
> > > > > >         >> tomahawk-sandbox-1.1.5-SNAPSHOT.
> > > > > >         >>
> > > > > >         >> Previously i had myfaces1.1 jar
> > > > > >         >> I dint have issue with selectOneMenu before.
> > > > > >         >>
> > > > > >         >> Now when I submit the page, I am getting this jsf
> > > > > >         validation error:
> > > > > >         >> Container:"Value is not a valid option"
> > > > > >         >> for a selectOneMenu even if i select some option.
> > > > > >         >>
> > > > > >         >> code:
> > > > > >         >> <h:panelGroup
> > > > > >         rendered="#{reportsBean.renderContainerType}">
> > > > > >         >>    <x:outputLabel for="containerfilter"
> > > > > >         >> value="#{msgBundle.EPCMgr_ContainerLbl }:"
> > > > > >         >> styleClass="standard_text_bold"/>
> > > > > >         >>    <f:verbatim><br/></f:verbatim>
> > > > > >         >>    <h:selectOneMenu id="containerfilter"
> > > > > >         >> value="#{ reportsBean.containerType}"
> immediate="true"
> > > > > >         disabled="#{
> > > > > >         >> reportsBean.optionDisabled }"
> > styleClass="standard_input">
> > > > > >         >>     <f:selectItem itemValue="" itemLabel=" " />
> > > > > >         >>     <f:selectItems
> > > > > >         value="#{reportsBean.containerTypeList }"/>
> > > > > >         >>    </h:selectOneMenu>
> > > > > >         >>   </h:panelGroup>
> > > > > >         >>
> > > > > >         >> Can anybody tell me why it is happening?
> > > > > >         >>
> > > > > >         >> regards
> > > > > >         >> srinivas
> > > > > >         >>
> > > > > >         >
> > > > > >         >
> > > > > >
> > > > > >         --
> > > > > >         View this message in context:
> http://www.nabble.com/ERROR%
> > > > > >
> > > > 3A-Value-is-not-a-valid-option-tf3270984.html#a9155607
> > > > > >         Sent from the MyFaces - Users mailing list archive at
> > > > > >         Nabble.com.
> > > > > >
> > > > > >
> > > > > --
> > > > > Martin Grotzke
> > > > > http://www.javakaffee.de/blog/
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>

Re: [Solved] ERROR: Value is not a valid option

Posted by Wolf Benz <eu...@gmail.com>.
You can also use tr:selectOneChoice instead of h:selectOneMenu
With the same t:selectItems inside, h:... gives me errors; tr:... not  
at all!
-Wolf

On 27 Feb 2007, at 10:31, CarlHowarth wrote:

>
> Thanks very much Mike - all I needed to do to get this to work is  
> change the
> itemvalue of my t:selectitems from:
>
> "#{r.idString}"
>
> to:
>
> "#{r}"
>
> Thanks again - Carl
>
>
>
> Mike Kienenberger wrote:
>>
>> Yes, that's how I would do it.  If you specify an itemValue, then  
>> that
>> value must be of the correct type.  Ie, " " is not a containerType
>> (Srinivas) and "0" is not a region (Carl).
>>
>> On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
>>> I am using facelets.  Where would that function go?  Each  
>>> f:selectItem
>>> entry?
>>>
>>> <f:selectItem itemLabel="Website URL"
>>> itemValue="#{myfn:convertStringToShort(3)}"/>
>>>
>>>
>>>
>>>
>>> On 2/26/07, Mike Kienenberger <mk...@gmail.com> wrote:
>>>> Take a look at
>>> http://issues.apache.org/jira/browse/MYFACES-1328.   It
>>>> looks like the RI does not have this convenience conversion.   I  
>>>> don't
>>>> know what the spec says, but that'd be the place to get a  
>>>> definitive
>>>> answer.
>>>>
>>>> If you're using facelets, as a temporary workaround you could  
>>>> create a
>>>> "convertStringToShort()" function (or whatever conversion you're
>>>> expecting to have happen automatically).
>>>>
>>>>
>>>> On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
>>>>> I did try that and didn't have any luck.  I think that was due  
>>>>> to the
>>> fact
>>>>> that I was using shorts rather than ints, but I'd have to try it
>>> again
>>> now
>>>>> that I have a better understanding of everything involved.
>>>>>
>>>>> I looked at TOMAHAWK-152 briefly.  I'll have to sit down and  
>>>>> take a
>>> better
>>>>> look at it.  It looks to be in the realm.  The string value of  
>>>>> 'true'
>>> not
>>>>> matching with a boolean type value?
>>>>>
>>>>> I guess the bottom line is I'd like to find out if I should be  
>>>>> using
>>> an
>>>>> explicit converter to go from String to Short, or if the JSF api
>>> being
>>> used
>>>>> should be able to handle a simple[r] conversion like that.  It was
>>> doing
>>>>> that conversion originally.  Does the JSF spec cover this?   
>>>>> Anybody
>>> happen
>>>>> to know what the reference implementation does?  I'd love to try  
>>>>> it
>>> out,
>>> but
>>>>> we're trying to push this out the door, so for the near future I  
>>>>> have
>>> to
>>>>> focus on what's right in front of me.
>>>>>
>>>>>
>>>>> On 2/26/07, Martin Grotzke < martin.grotzke@javakaffee.de> wrote:
>>>>>> Does it work when you use itemValue="#{3}" as workaround?
>>>>>>
>>>>>> I also had the same problem with itemValue="true", what I think  
>>>>>> is
>>>>>> http://issues.apache.org/jira/browse/TOMAHAWK-152 ...
>>>>>>
>>>>>> Cheers,
>>>>>> Martin
>>>>>>
>>>>>>
>>>>>> On Mon, 2007-02-26 at 11:23 -0500, Kevin Galligan wrote:
>>>>>>> I'm having the same problem.  I had some code that was working
>>> for a
>>>>>>> long time with 1.1.5-SNAPSHOT, and now I'm getting that error.
>>>>>>>
>>>>>>> <h:selectOneMenu
>>>>> value="#{shared$FavoriteDocumentAdd.documentTypeId}"
>>>>>>> onchange="toggleInputRow()" id="documentTypeSelect"
>>>>>>> style="background-color:rgb(204,204,255)">
>>>>>>>   <f:selectItem itemLabel="Website URL" itemValue="3"/>
>>>>>>>   <f:selectItem itemLabel="File Upload" itemValue="1"/>
>>>>>>>   <f:selectItem itemLabel="Description Only" itemValue="2"/>
>>>>>>> </h:selectOneMenu>
>>>>>>>
>>>>>>> The value being set is a short.  Essentially it looks like the
>>> code
>>>>>>> was doing an automatic conversion before, but now chokes.
>>>>>>>
>>>>>>> I just reverted the code to 1.1.5-SNAPSHOT, and it works again.
>>> I'm
>>>>>>> going to try to take a quick look at the differences between
>>>>>>> UISelectOne.java between those two versions, but in practice  
>>>>>>> I've
>>>>>>> found with any large code base, it'll take a little time to
>>> really
>>>>>>> understand the layout.
>>>>>>>
>>>>>>> On 2/26/07, CarlHowarth < carl.howarth@dlapiper.com> wrote:
>>>>>>>
>>>>>>>       Hi,
>>>>>>>
>>>>>>>       I am having this problem too. My select one is set up as
>>>>>>>       follows:
>>>>>>>
>>>>>>>       <h:selectOneMenu id="regionList"
>>>>>>>       binding="#{Bean.regionListUI}"
>>>>>>>       value="#{ Bean.region}" >
>>>>>>>         <f:converter converterId=" myapp.Region"/>
>>>>>>>         <f:selectItem itemValue="0" itemLabel="(all)"/>
>>>>>>>         <t:selectItems var="r" itemLabel="#{ r.name }"
>>>>>>>       itemValue="#{ r.idString}"
>>>>>>>       value="#{applicationBean.regionMap}" />
>>>>>>>         <f:attribute name="fieldRef" value="Region List"/>
>>>>>>>       </h:selectOneMenu>
>>>>>>>
>>>>>>>       - This was working fine with 1.1.4 but since the upgrade
>>> to
>>>>>>>       1.1.5 it now
>>>>>>>       falls over.
>>>>>>>       - The application bean is at application scope, so the
>>> values
>>>>>>>       should always
>>>>>>>       be available.
>>>>>>>       - The converter changes an ID to a region and vice versa.
>>>>>>>       - The page loads up fine, I only have the problem when I
>>>>>>>       select a command
>>>>>>>       button that runs an action listener.
>>>>>>>       - I use a '<t:saveState value="#{Bean_track}"/>' for my
>>>>>>>       request-scoped bean.
>>>>>>>       - The region bean implements a working 'equals' method.
>>>>>>>       - If I select the manually populated select item, (all),
>>> it
>>>>>>>       works correctly.
>>>>>>>
>>>>>>>       My converter is like this:
>>>>>>>
>>>>>>>       public final static String CONVERTER_ID = "
>>> myapp.Region";
>>>>>>>           public Object getAsObject(FacesContext facesContext,
>>>>>>>       UIComponent
>>>>>>>       uiComponent, String string)
>>>>>>>                   throws ConverterException {
>>>>>>>
>>>>>>>              return
>>>>>>>
>>>>>
>>> JSFUtils 
>>> .getAppBackingBean().getRegionMap().get(Integer.parseInt(string));
>>>>>>>           }
>>>>>>>
>>>>>>>           public String getAsString(FacesContext facesContext,
>>>>>>>       UIComponent
>>>>>>>       uiComponent, Object object)
>>>>>>>                   throws ConverterException {
>>>>>>>               if (object == null) {
>>>>>>>                   return null;
>>>>>>>               } else if (object instanceof Region) {
>>>>>>>                   final Region region = (Region) object;
>>>>>>>                   return region.getId().toString();
>>>>>>>               }
>>>>>>>
>>>>>>>               return object.toString();
>>>>>>>           }
>>>>>>>
>>>>>>>
>>>>>>>       I am at a complete loss at the moment, so any thoughts on
>>> what
>>>>>>>       could be
>>>>>>>       causing this error would be appreciated.
>>>>>>>
>>>>>>>       Thanks, Carl
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>       Ernst Fastl wrote:
>>>>>>>>
>>>>>>>> Hi,
>>>>>>>>
>>>>>>>> I have had a similar problem recently. Generally
>>> happens
>>> if
>>>>>>>       the
>>>>>>>> application is not able to find the selected value in
>>> the
>>>>>>>       List of
>>>>>>>> selectItems.
>>>>>>>> This can be due to 2 possible situations:
>>>>>>>>
>>>>>>>> 1. The list is not available during validation
>>>>>>>> -> try using a <t:saveState
>>>>>>>       value="#{reportsBean.containerTypeList }" />
>>>>>>>> to ensure it is
>>>>>>>>
>>>>>>>> 2. The values of the selectItems (getValue() and
>>> setValue())
>>>>>>>       do not
>>>>>>>> contain
>>>>>>>> Strings and there is no converter:
>>>>>>>>
>>>>>>>> -> use a corresponding converter e.g. for Long -
>>>>>>>       LongConverter
>>>>>>>> for the selectOneMenu
>>>>>>>>
>>>>>>>> hope that helps
>>>>>>>>
>>>>>>>> regards
>>>>>>>>
>>>>>>>> Ernst
>>>>>>>>
>>>>>>>> On 2/22/07, Srinivas V <vuyyuru.srinivas@gmail.com >
>>> wrote:
>>>>>>>>> Hi All,
>>>>>>>>> Please help me!!
>>>>>>>>> I am having an issue with SelectOneMenu.
>>>>>>>>>
>>>>>>>>> I have installed JSF 1.1.5-SNAPSHOT ,Tomahawk1.1.5-
>>> SNAPSHOT
>>>>>>>       and
>>>>>>>>> tomahawk-sandbox-1.1.5-SNAPSHOT.
>>>>>>>>>
>>>>>>>>> Previously i had myfaces1.1 jar
>>>>>>>>> I dint have issue with selectOneMenu before.
>>>>>>>>>
>>>>>>>>> Now when I submit the page, I am getting this jsf
>>>>>>>       validation error:
>>>>>>>>> Container:"Value is not a valid option"
>>>>>>>>> for a selectOneMenu even if i select some option.
>>>>>>>>>
>>>>>>>>> code:
>>>>>>>>> <h:panelGroup
>>>>>>>       rendered="#{reportsBean.renderContainerType}">
>>>>>>>>>  <x:outputLabel for="containerfilter"
>>>>>>>>> value="#{msgBundle.EPCMgr_ContainerLbl }:"
>>>>>>>>> styleClass="standard_text_bold"/>
>>>>>>>>>  <f:verbatim><br/></f:verbatim>
>>>>>>>>>  <h:selectOneMenu id="containerfilter"
>>>>>>>>> value="#{ reportsBean.containerType}" immediate="true"
>>>>>>>       disabled="#{
>>>>>>>>> reportsBean.optionDisabled }"
>>> styleClass="standard_input">
>>>>>>>>>   <f:selectItem itemValue="" itemLabel=" " />
>>>>>>>>>   <f:selectItems
>>>>>>>       value="#{reportsBean.containerTypeList }"/>
>>>>>>>>>  </h:selectOneMenu>
>>>>>>>>> </h:panelGroup>
>>>>>>>>>
>>>>>>>>> Can anybody tell me why it is happening?
>>>>>>>>>
>>>>>>>>> regards
>>>>>>>>> srinivas
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>       --
>>>>>>>       View this message in context:
>>> http://www.nabble.com/ERROR%
>>>>>>>
>>>>> 3A-Value-is-not-a-valid-option-tf3270984.html#a9155607
>>>>>>>       Sent from the MyFaces - Users mailing list archive at
>>>>>>>       Nabble.com.
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> Martin Grotzke
>>>>>> http://www.javakaffee.de/blog/
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9178333
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>


Re: [Solved] ERROR: Value is not a valid option

Posted by CarlHowarth <ca...@dlapiper.com>.
Thanks very much Mike - all I needed to do to get this to work is change the
itemvalue of my t:selectitems from:

"#{r.idString}"

to:

"#{r}"

Thanks again - Carl



Mike Kienenberger wrote:
> 
> Yes, that's how I would do it.  If you specify an itemValue, then that
> value must be of the correct type.  Ie, " " is not a containerType
> (Srinivas) and "0" is not a region (Carl).
> 
> On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
>> I am using facelets.  Where would that function go?  Each f:selectItem
>> entry?
>>
>> <f:selectItem itemLabel="Website URL"
>> itemValue="#{myfn:convertStringToShort(3)}"/>
>>
>>
>>
>>
>>  On 2/26/07, Mike Kienenberger <mk...@gmail.com> wrote:
>> > Take a look at
>> http://issues.apache.org/jira/browse/MYFACES-1328.   It
>> > looks like the RI does not have this convenience conversion.   I don't
>> > know what the spec says, but that'd be the place to get a definitive
>> > answer.
>> >
>> > If you're using facelets, as a temporary workaround you could create a
>> > "convertStringToShort()" function (or whatever conversion you're
>> > expecting to have happen automatically).
>> >
>> >
>> > On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
>> > > I did try that and didn't have any luck.  I think that was due to the
>> fact
>> > > that I was using shorts rather than ints, but I'd have to try it
>> again
>> now
>> > > that I have a better understanding of everything involved.
>> > >
>> > >  I looked at TOMAHAWK-152 briefly.  I'll have to sit down and take a
>> better
>> > > look at it.  It looks to be in the realm.  The string value of 'true'
>> not
>> > > matching with a boolean type value?
>> > >
>> > > I guess the bottom line is I'd like to find out if I should be using
>> an
>> > > explicit converter to go from String to Short, or if the JSF api
>> being
>> used
>> > > should be able to handle a simple[r] conversion like that.  It was
>> doing
>> > > that conversion originally.  Does the JSF spec cover this?  Anybody
>> happen
>> > > to know what the reference implementation does?  I'd love to try it
>> out,
>> but
>> > > we're trying to push this out the door, so for the near future I have
>> to
>> > > focus on what's right in front of me.
>> > >
>> > >
>> > > On 2/26/07, Martin Grotzke < martin.grotzke@javakaffee.de> wrote:
>> > > > Does it work when you use itemValue="#{3}" as workaround?
>> > > >
>> > > > I also had the same problem with itemValue="true", what I think is
>> > > > http://issues.apache.org/jira/browse/TOMAHAWK-152 ...
>> > > >
>> > > > Cheers,
>> > > > Martin
>> > > >
>> > > >
>> > > > On Mon, 2007-02-26 at 11:23 -0500, Kevin Galligan wrote:
>> > > > > I'm having the same problem.  I had some code that was working
>> for a
>> > > > > long time with 1.1.5-SNAPSHOT, and now I'm getting that error.
>> > > > >
>> > > > > <h:selectOneMenu
>> > > value="#{shared$FavoriteDocumentAdd.documentTypeId}"
>> > > > > onchange="toggleInputRow()" id="documentTypeSelect"
>> > > > > style="background-color:rgb(204,204,255)">
>> > > > >     <f:selectItem itemLabel="Website URL" itemValue="3"/>
>> > > > >     <f:selectItem itemLabel="File Upload" itemValue="1"/>
>> > > > >     <f:selectItem itemLabel="Description Only" itemValue="2"/>
>> > > > > </h:selectOneMenu>
>> > > > >
>> > > > > The value being set is a short.  Essentially it looks like the
>> code
>> > > > > was doing an automatic conversion before, but now chokes.
>> > > > >
>> > > > > I just reverted the code to 1.1.5-SNAPSHOT, and it works again. 
>> I'm
>> > > > > going to try to take a quick look at the differences between
>> > > > > UISelectOne.java between those two versions, but in practice I've
>> > > > > found with any large code base, it'll take a little time to
>> really
>> > > > > understand the layout.
>> > > > >
>> > > > > On 2/26/07, CarlHowarth < carl.howarth@dlapiper.com> wrote:
>> > > > >
>> > > > >         Hi,
>> > > > >
>> > > > >         I am having this problem too. My select one is set up as
>> > > > >         follows:
>> > > > >
>> > > > >         <h:selectOneMenu id="regionList"
>> > > > >         binding="#{Bean.regionListUI}"
>> > > > >         value="#{ Bean.region}" >
>> > > > >           <f:converter converterId=" myapp.Region"/>
>> > > > >           <f:selectItem itemValue="0" itemLabel="(all)"/>
>> > > > >           <t:selectItems var="r" itemLabel="#{ r.name }"
>> > > > >         itemValue="#{ r.idString}"
>> > > > >         value="#{applicationBean.regionMap}" />
>> > > > >           <f:attribute name="fieldRef" value="Region List"/>
>> > > > >         </h:selectOneMenu>
>> > > > >
>> > > > >         - This was working fine with 1.1.4 but since the upgrade
>> to
>> > > > >         1.1.5 it now
>> > > > >         falls over.
>> > > > >         - The application bean is at application scope, so the
>> values
>> > > > >         should always
>> > > > >         be available.
>> > > > >         - The converter changes an ID to a region and vice versa.
>> > > > >         - The page loads up fine, I only have the problem when I
>> > > > >         select a command
>> > > > >         button that runs an action listener.
>> > > > >         - I use a '<t:saveState value="#{Bean_track}"/>' for my
>> > > > >         request-scoped bean.
>> > > > >         - The region bean implements a working 'equals' method.
>> > > > >         - If I select the manually populated select item, (all),
>> it
>> > > > >         works correctly.
>> > > > >
>> > > > >         My converter is like this:
>> > > > >
>> > > > >         public final static String CONVERTER_ID = "
>> myapp.Region";
>> > > > >             public Object getAsObject(FacesContext facesContext,
>> > > > >         UIComponent
>> > > > >         uiComponent, String string)
>> > > > >                     throws ConverterException {
>> > > > >
>> > > > >                return
>> > > > >
>> > >
>> JSFUtils.getAppBackingBean().getRegionMap().get(Integer.parseInt(string));
>> > > > >             }
>> > > > >
>> > > > >             public String getAsString(FacesContext facesContext,
>> > > > >         UIComponent
>> > > > >         uiComponent, Object object)
>> > > > >                     throws ConverterException {
>> > > > >                 if (object == null) {
>> > > > >                     return null;
>> > > > >                 } else if (object instanceof Region) {
>> > > > >                     final Region region = (Region) object;
>> > > > >                     return region.getId().toString();
>> > > > >                 }
>> > > > >
>> > > > >                 return object.toString();
>> > > > >             }
>> > > > >
>> > > > >
>> > > > >         I am at a complete loss at the moment, so any thoughts on
>> what
>> > > > >         could be
>> > > > >         causing this error would be appreciated.
>> > > > >
>> > > > >         Thanks, Carl
>> > > > >
>> > > > >
>> > > > >
>> > > > >         Ernst Fastl wrote:
>> > > > >         >
>> > > > >         > Hi,
>> > > > >         >
>> > > > >         > I have had a similar problem recently. Generally
>> happens
>> if
>> > > > >         the
>> > > > >         > application is not able to find the selected value in
>> the
>> > > > >         List of
>> > > > >         > selectItems.
>> > > > >         > This can be due to 2 possible situations:
>> > > > >         >
>> > > > >         > 1. The list is not available during validation
>> > > > >         > -> try using a <t:saveState
>> > > > >         value="#{reportsBean.containerTypeList }" />
>> > > > >         > to ensure it is
>> > > > >         >
>> > > > >         > 2. The values of the selectItems (getValue() and
>> setValue())
>> > > > >         do not
>> > > > >         > contain
>> > > > >         > Strings and there is no converter:
>> > > > >         >
>> > > > >         > -> use a corresponding converter e.g. for Long -
>> > > > >         LongConverter
>> > > > >         > for the selectOneMenu
>> > > > >         >
>> > > > >         > hope that helps
>> > > > >         >
>> > > > >         > regards
>> > > > >         >
>> > > > >         > Ernst
>> > > > >         >
>> > > > >         > On 2/22/07, Srinivas V <vuyyuru.srinivas@gmail.com >
>> wrote:
>> > > > >         >> Hi All,
>> > > > >         >> Please help me!!
>> > > > >         >> I am having an issue with SelectOneMenu.
>> > > > >         >>
>> > > > >         >> I have installed JSF 1.1.5-SNAPSHOT ,Tomahawk1.1.5-
>> SNAPSHOT
>> > > > >         and
>> > > > >         >> tomahawk-sandbox-1.1.5-SNAPSHOT.
>> > > > >         >>
>> > > > >         >> Previously i had myfaces1.1 jar
>> > > > >         >> I dint have issue with selectOneMenu before.
>> > > > >         >>
>> > > > >         >> Now when I submit the page, I am getting this jsf
>> > > > >         validation error:
>> > > > >         >> Container:"Value is not a valid option"
>> > > > >         >> for a selectOneMenu even if i select some option.
>> > > > >         >>
>> > > > >         >> code:
>> > > > >         >> <h:panelGroup
>> > > > >         rendered="#{reportsBean.renderContainerType}">
>> > > > >         >>    <x:outputLabel for="containerfilter"
>> > > > >         >> value="#{msgBundle.EPCMgr_ContainerLbl }:"
>> > > > >         >> styleClass="standard_text_bold"/>
>> > > > >         >>    <f:verbatim><br/></f:verbatim>
>> > > > >         >>    <h:selectOneMenu id="containerfilter"
>> > > > >         >> value="#{ reportsBean.containerType}" immediate="true"
>> > > > >         disabled="#{
>> > > > >         >> reportsBean.optionDisabled }"
>> styleClass="standard_input">
>> > > > >         >>     <f:selectItem itemValue="" itemLabel=" " />
>> > > > >         >>     <f:selectItems
>> > > > >         value="#{reportsBean.containerTypeList }"/>
>> > > > >         >>    </h:selectOneMenu>
>> > > > >         >>   </h:panelGroup>
>> > > > >         >>
>> > > > >         >> Can anybody tell me why it is happening?
>> > > > >         >>
>> > > > >         >> regards
>> > > > >         >> srinivas
>> > > > >         >>
>> > > > >         >
>> > > > >         >
>> > > > >
>> > > > >         --
>> > > > >         View this message in context:
>> http://www.nabble.com/ERROR%
>> > > > >
>> > > 3A-Value-is-not-a-valid-option-tf3270984.html#a9155607
>> > > > >         Sent from the MyFaces - Users mailing list archive at
>> > > > >         Nabble.com.
>> > > > >
>> > > > >
>> > > > --
>> > > > Martin Grotzke
>> > > > http://www.javakaffee.de/blog/
>> > > >
>> > > >
>> > >
>> > >
>> >
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9178333
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: ERROR: Value is not a valid option

Posted by fastbob <fa...@gmail.com>.
Certainly. But in this case it's a good match to the desired semantics,
reduces code, and reduces potential coupling between the model and
presentation. If it works again...

Jeff Bischoff wrote:
> 
> There are cases where I find the "required" attribute to be cumbersome. 
> Whenever that occurs, I just move that check to my action methods. Don't 
> know if that will make any difference in your case, but don't feel like 
> you *have* to use required just because the spec provides it to you as 
> an option. :)
> 
> fastbob wrote:
>> We want the
>> "nothing has been selected" representation to force an error, either
>> through
>> required="true" or some other mechanism.
>> 
> 
> 
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9821363
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: ERROR: Value is not a valid option

Posted by Jeff Bischoff <jb...@klkurz.com>.
There are cases where I find the "required" attribute to be cumbersome. 
Whenever that occurs, I just move that check to my action methods. Don't 
know if that will make any difference in your case, but don't feel like 
you *have* to use required just because the spec provides it to you as 
an option. :)

fastbob wrote:
> We want the
> "nothing has been selected" representation to force an error, either through
> required="true" or some other mechanism.
> 




Re: ERROR: Value is not a valid option

Posted by fastbob <fa...@gmail.com>.
I'll see if I can come up with a fairly self-contained example.

As far as the value set, I think I can argue that the set of values is
consistent, especially when taking into account the associated converter.
Matter of fact, we're expecting the serialization/deserialization of the
converter to *keep* the values consistent by only allowing valid EJB values
to be selected, and not even allowing null. Internally, the value is always
a non-null EJB. Externally, the value representations are the valid EJB's
plus one representation of a "nothing has been selected" state. We want the
"nothing has been selected" representation to force an error, either through
required="true" or some other mechanism.


Mike Kienenberger wrote:
> 
> Not really sure how much more I can add.   I've posted examples of
> similar code I have, but without seeing a simplified (but erroring)
> example demonstrating why your setup isn't working, I'm not sure what
> else to suggest.    getAsObject has to return a homogenious set of
> objects.   But as long as your converter translates the string values,
> I think you can have a heterogenious collection of SelectItem
> itemValues fed into the renderer.   I know I've mixed marker Strings
> (representing null and disabled selections) with actual
> ProjectTypeLocal-esque objects on my page code.
> 
> 
> On 4/2/07, fastbob <fa...@gmail.com> wrote:
>>
>> Usually the selectItem values are EJB's, but in a couple of instances
>> they
>> strings that just happen to be the serialized form of the EJB. The
>> prototypical code looks like:
>>
>>          ArrayList projectTypes = new ArrayList(
>> projectTypeHome.findAll()
>> );
>>          for( int i = 0; i < projectTypes.size(); i++ )
>>          {
>>             ProjectTypeLocal projectType =
>> (ProjectTypeLocal)projectTypes.get( i );
>>             m_projectTypes.add( new SelectItem( projectType,
>> projectType.getName() ) );
>>          }
>>
>> What this means is when we get to the following lines in
>> _SelectItemsUtil,
>> the equals() method of the EJB is called with the empty ("") string (in
>> 1.1.5):
>>
>>                  [item is class SelectItem]
>>                  Object itemValue = item.getValue();
>>                  if (value==itemValue || value.equals(itemValue))
>>
>> It appears that the 1.1.3 code handled the case of any String being
>> passed.
>> Since our converters look for an empty string, this results in the EJB
>> equals() being passed null:
>>
>>                 Object itemValue = item.getValue();
>>                 if(converter != null && itemValue instanceof String)
>>                 {
>>                     itemValue = converter.getConvertedValue(context,
>> (String)itemValue);
>>                 }
>>                 if (value==itemValue || value.equals(itemValue))
>>
>> But I guess this circles back to non-standard conversion that was taken
>> out.
>>
>> I'm pretty ignorant of all the JSF lifecycle semantics, but since this
>> practice is always used with required="true", would an earlier check for
>> a
>> non-null, non-empty string fix this?
>>
>> I'm open to suggestions.
>>
>>
>> Mike Kienenberger wrote:
>> >
>> > Yes, I think you're right.  It's not the form String -> Object that's
>> > causing the issue.
>> > It looks like it's the contents of the selectItem values.  What are
>> > you initializing the selectItem value fields with?
>> >
>> > What's the contents of selectItem.value when it's of type String?
>> >
>> > On 3/30/07, fastbob <fa...@gmail.com> wrote:
>> >>
>> >> Hmmm. I must be missing something. Other than parameterization,
>> including
>> >> your use of disable and null values, I don't see any significant
>> >> differences
>> >> (I also tried moving the converter into the h:selectOneMenu - no
>> effect).
>> >> In
>> >> fact, the Tomahawk example uses "" as a nothing -selected value, just
>> as
>> >> we
>> >> do. And the converter code is essentially identical - we start with:
>> >>
>> >>       if( string == null || string.trim().length() == 0 )
>> >>          return null;
>> >>
>> >> So why are we getting an exception during the validation phase?
>> >>
>> >> Bob
>> >>
>> >>
>> >> Mike Kienenberger wrote:
>> >> >
>> >> > Here's how the tomahawk examples do it:
>> >> >
>> >> >                 <h:selectOneMenu id="selone_menu_colors"
>> >> > value="#{carconf.color}" styleClass="selectOneMenu"
>> >> > converter="#{carconf.colorConverter}">
>> >> >                     <f:selectItem itemValue=""
>> >> > itemLabel="#{example_messages['empty_selitem']}" />
>> >> >
>> >> >
>> >> >
>> >> >         public Object getAsObject(FacesContext facesContext,
>> >> > UIComponent component, String string) throws ConverterException
>> >> >         {
>> >> >             if(string==null)
>> >> >                 return null;
>> >> >
>> >> >
>> >> > Here's how I do it on my own projects:
>> >> >
>> >> >     public final static String DISABLED_OPTION_VALUE =
>> >> > "com.xyz.utilities.web.jsf.converter.DISABLED_OPTION_VALUE";
>> >> >     public final static String NULL_OPTION_VALUE =
>> >> > "com.xyz.utilities.web.jsf.converter.NULL_OPTION_VALUE";
>> >> >
>> >> >     public String getNullSelectItemOptionValue() {
>> >> >         return
>> >> >
>> com.xyz.utilities.web.jsf.converter.ConverterOptions.NULL_OPTION_VALUE;
>> >> >     }
>> >> >
>> >> > <f:selectItem
>> >> >       itemValue="#{myPage.nullSelectItemOptionValue}"
>> >> >       itemLabel="&lt;No selection&gt;" />
>> >> >
>> >> >     public Object getAsObject(FacesContext context, UIComponent
>> >> > component, String value) throws ConverterException
>> >> >     {
>> >> >       if (null == value)  return null;
>> >> >         if (ConverterOptions.DISABLED_OPTION_VALUE.equals(value))
>> >> return
>> >> > null;
>> >> >         if (ConverterOptions.NULL_OPTION_VALUE.equals(value)) 
>> return
>> >> > null;
>> >> >
>> >> > On 3/30/07, fastbob <fa...@gmail.com> wrote:
>> >> >>
>> >> >>
>> >> >> Mike Kienenberger wrote:
>> >> >> >
>> >> >> > Yes, that's how I would do it.  If you specify an itemValue, then
>> >> that
>> >> >> > value must be of the correct type.  Ie, " " is not a
>> containerType
>> >> >> > (Srinivas) and "0" is not a region (Carl).
>> >> >> >
>> >> >> Ouch. The assumption is that there is a one-one correspondence
>> between
>> >> >> the
>> >> >> list items and the type in the model. This isn't always the case.
>> >> >>
>> >> >> We had a number of JSP's under 1.1.3 with the following sequence,
>> for
>> >> >> several different types of lists:
>> >> >>
>> >> >>          <h:selectOneMenu id="client"
>> value="#{myPage.projectType}">
>> >> >>              <f:converter converterId="x.y.ProjectTypeConverter"/>
>> >> >>              <f:selectItem itemValue="" itemLabel="--- Select
>> Project
>> >> >> Type---"/>
>> >> >>              <f:selectItems value="#{myPage.projectTypeList}"/>
>> >> >>          </h:selectOneMenu>
>> >> >>
>> >> >> The values in the type are fixed (essentially an enumeration, but
>> not
>> >> >> implemented that way), and there is no "empty" value available.
>> >> Instead,
>> >> >> if
>> >> >> the converters are passed a null or empty string for conversion to
>> the
>> >> >> underlying type, they immediately return null. So in this case null
>> is
>> >> >> used
>> >> >> to indicate no value has been selected by the user, and they get an
>> >> >> error.
>> >> >>
>> >> >> With 1.1.5, we get the following exception:
>> >> >>
>> >> >> java.lang.ClassCastException: java.lang.String cannot be cast to
>> >> >> javax.ejb.EJBLocalObject
>> >> >>             at
>> >> >>
>> >>
>> org.jboss.ejb.plugins.local.LocalProxy.isIdentical(LocalProxy.java:124)
>> >> >>             at
>> >> >> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:174)
>> >> >>             at
>> >> >> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
>> >> >>             at
>> >> >> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:155)
>> >> >>             at
>> >> >> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
>> >> >>            at $Proxy262.equals(Unknown Source)
>> >> >>             at
>> >> >>
>> >>
>> javax.faces.component._SelectItemsUtil.matchValue(_SelectItemsUtil.java:65)
>> >> >>             at
>> >> >>
>> javax.faces.component.UISelectOne.validateValue(UISelectOne.java:56)
>> >> >>             at
>> >> javax.faces.component.UIInput.validate(UIInput.java:354)
>> >> >>             at
>> >> >> javax.faces.component.UIInput.processValidators(UIInput.java:184)
>> >> >>             […]
>> >> >>
>> >> >> Here are the relevant lines from _SelectItemsUtil.MatchValue():
>> >> >>
>> >> >>                 [item is class SelectItem]
>> >> >>                 Object itemValue = item.getValue();
>> >> >>                 if (value==itemValue || value.equals(itemValue))
>> >> >>
>> >> >> The exception is thrown by the call to equals in an EJB.
>> >> >>
>> >> >> I haven't come up with a low-cost way to fix this.
>> >> >>
>> >> >> Bob
>> >> >> --
>> >> >> View this message in context:
>> >> >>
>> >>
>> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762021
>> >> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762503
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9797466
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9798897
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: ERROR: Value is not a valid option

Posted by Mike Kienenberger <mk...@gmail.com>.
Not really sure how much more I can add.   I've posted examples of
similar code I have, but without seeing a simplified (but erroring)
example demonstrating why your setup isn't working, I'm not sure what
else to suggest.    getAsObject has to return a homogenious set of
objects.   But as long as your converter translates the string values,
I think you can have a heterogenious collection of SelectItem
itemValues fed into the renderer.   I know I've mixed marker Strings
(representing null and disabled selections) with actual
ProjectTypeLocal-esque objects on my page code.


On 4/2/07, fastbob <fa...@gmail.com> wrote:
>
> Usually the selectItem values are EJB's, but in a couple of instances they
> strings that just happen to be the serialized form of the EJB. The
> prototypical code looks like:
>
>          ArrayList projectTypes = new ArrayList( projectTypeHome.findAll()
> );
>          for( int i = 0; i < projectTypes.size(); i++ )
>          {
>             ProjectTypeLocal projectType =
> (ProjectTypeLocal)projectTypes.get( i );
>             m_projectTypes.add( new SelectItem( projectType,
> projectType.getName() ) );
>          }
>
> What this means is when we get to the following lines in _SelectItemsUtil,
> the equals() method of the EJB is called with the empty ("") string (in
> 1.1.5):
>
>                  [item is class SelectItem]
>                  Object itemValue = item.getValue();
>                  if (value==itemValue || value.equals(itemValue))
>
> It appears that the 1.1.3 code handled the case of any String being passed.
> Since our converters look for an empty string, this results in the EJB
> equals() being passed null:
>
>                 Object itemValue = item.getValue();
>                 if(converter != null && itemValue instanceof String)
>                 {
>                     itemValue = converter.getConvertedValue(context,
> (String)itemValue);
>                 }
>                 if (value==itemValue || value.equals(itemValue))
>
> But I guess this circles back to non-standard conversion that was taken out.
>
> I'm pretty ignorant of all the JSF lifecycle semantics, but since this
> practice is always used with required="true", would an earlier check for a
> non-null, non-empty string fix this?
>
> I'm open to suggestions.
>
>
> Mike Kienenberger wrote:
> >
> > Yes, I think you're right.  It's not the form String -> Object that's
> > causing the issue.
> > It looks like it's the contents of the selectItem values.  What are
> > you initializing the selectItem value fields with?
> >
> > What's the contents of selectItem.value when it's of type String?
> >
> > On 3/30/07, fastbob <fa...@gmail.com> wrote:
> >>
> >> Hmmm. I must be missing something. Other than parameterization, including
> >> your use of disable and null values, I don't see any significant
> >> differences
> >> (I also tried moving the converter into the h:selectOneMenu - no effect).
> >> In
> >> fact, the Tomahawk example uses "" as a nothing -selected value, just as
> >> we
> >> do. And the converter code is essentially identical - we start with:
> >>
> >>       if( string == null || string.trim().length() == 0 )
> >>          return null;
> >>
> >> So why are we getting an exception during the validation phase?
> >>
> >> Bob
> >>
> >>
> >> Mike Kienenberger wrote:
> >> >
> >> > Here's how the tomahawk examples do it:
> >> >
> >> >                 <h:selectOneMenu id="selone_menu_colors"
> >> > value="#{carconf.color}" styleClass="selectOneMenu"
> >> > converter="#{carconf.colorConverter}">
> >> >                     <f:selectItem itemValue=""
> >> > itemLabel="#{example_messages['empty_selitem']}" />
> >> >
> >> >
> >> >
> >> >         public Object getAsObject(FacesContext facesContext,
> >> > UIComponent component, String string) throws ConverterException
> >> >         {
> >> >             if(string==null)
> >> >                 return null;
> >> >
> >> >
> >> > Here's how I do it on my own projects:
> >> >
> >> >     public final static String DISABLED_OPTION_VALUE =
> >> > "com.xyz.utilities.web.jsf.converter.DISABLED_OPTION_VALUE";
> >> >     public final static String NULL_OPTION_VALUE =
> >> > "com.xyz.utilities.web.jsf.converter.NULL_OPTION_VALUE";
> >> >
> >> >     public String getNullSelectItemOptionValue() {
> >> >         return
> >> > com.xyz.utilities.web.jsf.converter.ConverterOptions.NULL_OPTION_VALUE;
> >> >     }
> >> >
> >> > <f:selectItem
> >> >       itemValue="#{myPage.nullSelectItemOptionValue}"
> >> >       itemLabel="&lt;No selection&gt;" />
> >> >
> >> >     public Object getAsObject(FacesContext context, UIComponent
> >> > component, String value) throws ConverterException
> >> >     {
> >> >       if (null == value)  return null;
> >> >         if (ConverterOptions.DISABLED_OPTION_VALUE.equals(value))
> >> return
> >> > null;
> >> >         if (ConverterOptions.NULL_OPTION_VALUE.equals(value))  return
> >> > null;
> >> >
> >> > On 3/30/07, fastbob <fa...@gmail.com> wrote:
> >> >>
> >> >>
> >> >> Mike Kienenberger wrote:
> >> >> >
> >> >> > Yes, that's how I would do it.  If you specify an itemValue, then
> >> that
> >> >> > value must be of the correct type.  Ie, " " is not a containerType
> >> >> > (Srinivas) and "0" is not a region (Carl).
> >> >> >
> >> >> Ouch. The assumption is that there is a one-one correspondence between
> >> >> the
> >> >> list items and the type in the model. This isn't always the case.
> >> >>
> >> >> We had a number of JSP's under 1.1.3 with the following sequence, for
> >> >> several different types of lists:
> >> >>
> >> >>          <h:selectOneMenu id="client" value="#{myPage.projectType}">
> >> >>              <f:converter converterId="x.y.ProjectTypeConverter"/>
> >> >>              <f:selectItem itemValue="" itemLabel="--- Select Project
> >> >> Type---"/>
> >> >>              <f:selectItems value="#{myPage.projectTypeList}"/>
> >> >>          </h:selectOneMenu>
> >> >>
> >> >> The values in the type are fixed (essentially an enumeration, but not
> >> >> implemented that way), and there is no "empty" value available.
> >> Instead,
> >> >> if
> >> >> the converters are passed a null or empty string for conversion to the
> >> >> underlying type, they immediately return null. So in this case null is
> >> >> used
> >> >> to indicate no value has been selected by the user, and they get an
> >> >> error.
> >> >>
> >> >> With 1.1.5, we get the following exception:
> >> >>
> >> >> java.lang.ClassCastException: java.lang.String cannot be cast to
> >> >> javax.ejb.EJBLocalObject
> >> >>             at
> >> >>
> >> org.jboss.ejb.plugins.local.LocalProxy.isIdentical(LocalProxy.java:124)
> >> >>             at
> >> >> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:174)
> >> >>             at
> >> >> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
> >> >>             at
> >> >> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:155)
> >> >>             at
> >> >> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
> >> >>            at $Proxy262.equals(Unknown Source)
> >> >>             at
> >> >>
> >> javax.faces.component._SelectItemsUtil.matchValue(_SelectItemsUtil.java:65)
> >> >>             at
> >> >> javax.faces.component.UISelectOne.validateValue(UISelectOne.java:56)
> >> >>             at
> >> javax.faces.component.UIInput.validate(UIInput.java:354)
> >> >>             at
> >> >> javax.faces.component.UIInput.processValidators(UIInput.java:184)
> >> >>             […]
> >> >>
> >> >> Here are the relevant lines from _SelectItemsUtil.MatchValue():
> >> >>
> >> >>                 [item is class SelectItem]
> >> >>                 Object itemValue = item.getValue();
> >> >>                 if (value==itemValue || value.equals(itemValue))
> >> >>
> >> >> The exception is thrown by the call to equals in an EJB.
> >> >>
> >> >> I haven't come up with a low-cost way to fix this.
> >> >>
> >> >> Bob
> >> >> --
> >> >> View this message in context:
> >> >>
> >> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762021
> >> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762503
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9797466
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Schedule component - recurring entries

Posted by "Brindamour, Michael" <mb...@enterasys.com>.
Has anyone tried to override the schedule component to handle
ScheduleEntries that recur based on a pattern set in the entry?  I've
got my ScheduleEntry class set up to do so, but am realizing that the
renderer just calls getStartTime & getEndTime to figure out where to
paint them...  I haven't overridden a renderer yet... Has anyone already
done this or have any thoughts?

Mike 


--
Michael Brindamour
NetSight Engineering, Enterasys Networks, Inc.
Office: (978) 684-1332
Fax: (call above before faxing) (978) 684-1691
Cell: (603) 682-0014
Email: mbrindam@enterasys.com

Re: ERROR: Value is not a valid option

Posted by fastbob <fa...@gmail.com>.
I agree this does not fix the case where equals() has been implemented
incorrectly, nor should it. But it reduces the likelihood of an exception
for EJB's. The default equals() calls isIdentical(), which gets the
exception, at least in the JBoss 4.0.1 and 4.0.4 implementations. But thanks
for the fix.

Mike Kienenberger wrote:
> 
> Yes, I finally figured that out.
> 
> Unfortunately, it does mean the equality method on the object is
> incorrect since equals() requires symmetric-ness.
> 
> http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object)
> ==================
> It is symmetric: for any non-null reference values x and y,
> x.equals(y)  should return true if and only if y.equals(x) returns
> true.
> ==================
> 
> Even if I committed this change, it still wouldn't work in all cases.
>  As soon as two different  classes with broken equals()
> implementations were involved, you'd get the same error.   All it's
> doing is counting on the fact that String.equals() is written
> correctly and that you're only mixing MyObject classes and String
> classes.
> 
> On 4/4/07, fastbob <fa...@gmail.com> wrote:
>>
>> Sorry I wasn't clear. The null check is incidental, and can be eliminated
>> if
>> any of the itemValues can never be null. The key change is the object
>> order
>> of the second clause, relying on equality being symmetric. Originally it
>> was
>> "value.equals(itemValue)"; now it is "itemValue.equals(value)". So when
>> itemValue is the empty string, String equals() will be invoked, rather
>> than
>> EJB equals. The String equals() will return false, not an exception.
>>
>> Mike Kienenberger wrote:
>> >
>> > I'm not seeing how this will fix the problem.   In the test case you
>> > posted, the value is not null -- it's empty string.  So checking
>> > against null won't change the behavior.   The ClassCastException will
>> > still occur.
>> >
>> >
>> > On 4/3/07, fastbob <fa...@gmail.com> wrote:
>> >>
>> >> After doing a bit of research, I'm convinced the problem only occurs
>> when
>> >> SelectItem.itemValue is an EJB. Given that 1.1.3 and the RI (1.2_04)
>> do
>> >> not
>> >> have this problem, I suggest the current implementation be changed. If
>> >> I'm
>> >> wrong, please help me understand. Otherwise, I'll submit a change
>> >> request.
>> >>
>> >> JSP contents:
>> >>          <h:selectOneMenu id="client" value="#{myPage.projectType}"
>> >> required="true">
>> >>              <f:converter converterId="x.y.ProjectTypeConverter"/>
>> >>              <f:selectItem itemValue="" itemLabel="--- Select Project
>> >> Type---"/>
>> >>              <f:selectItems value="#{myPage.projectTypeList}"/>
>> >>          </h:selectOneMenu>
>> >>
>> >> Where ProjectTypeConverter returns null for "" on input and
>> >> myPage.projectTypeList is a list of SelectItem created in the
>> following
>> >> manner:
>> >>
>> >>          ArrayList projectTypes = new ArrayList(
>> >> projectTypeHome.findAll()
>> >> );
>> >>          for( int i = 0; i < projectTypes.size(); i++ )
>> >>          {
>> >>             ProjectTypeLocal projectType =
>> >> (ProjectTypeLocal)projectTypes.get( i );
>> >>             m_projectTypes.add( new SelectItem( projectType,
>> >> projectType.getName() ) );
>> >>          }
>> >>
>> >> Note that the SelectItem.itemValue is an EJB.
>> >>
>> >> The intent is to force the user to select a value from the list. If no
>> >> action is taken by the user, generate an error. This is directly
>> >> analogous
>> >> to a Tomahawk example, except the values are EJB's.
>> >>
>> >> The problem:
>> >> This worked fine under MyFaces 1.1.3 and appears that it would work
>> under
>> >> RI
>> >> 1.2_04. Under release 1.1.5, however, a ClassCastException occurs
>> during
>> >> the
>> >> validation phase, but only if a list item is selected and the item is
>> an
>> >> EJB.
>> >>
>> >> Analysis (based on 1.1.5 release):
>> >> During the validation phase, UISelectOne.validateValue is invoked with
>> >> the
>> >> selected EJB. This causes the following lines in
>> >> _SelectItemsUtil.matchValue() to be invoked:
>> >>
>> >>                 [item is class SelectItem]
>> >>                 Object itemValue = item.getValue();
>> >>                 if (value==itemValue || value.equals(itemValue))
>> >>
>> >> This is fine for the SelectItem values that are EJB's, but not for "".
>> >> Since
>> >> EJB equality requires identity, the EJB equals() method calls
>> >> isIdentical()
>> >> and immediately encounters an exception casting to EJBLocalObject
>> (code
>> >> here
>> >> from JBoss 4.0.4GA LocalProxy):
>> >>
>> >>    Boolean isIdentical(final Object a, final Object b)
>> >>    {
>> >>       final EJBLocalObject ejb = (EJBLocalObject)a;
>> >>       Boolean isIdentical = Boolean.FALSE;
>> >>       if( ejb != null )
>> >>       {
>> >>          isIdentical = new Boolean(ejb.toString().equals(b));
>> >>       }
>> >>       return isIdentical;
>> >>    }
>> >>
>> >> Possible solution:
>> >> Iin _SelectItemsUtil.matchValue() change the lines above to:
>> >>
>> >>                 [item is class SelectItem]
>> >>                 Object itemValue = item.getValue();
>> >>                 if (value==itemValue || ( itemValue != null &&
>> >> itemValue.equals(value)))
>> >>
>> >>
>> >>
>> >>
>> >> fastbob wrote:
>> >> >
>> >> > Usually the selectItem values are EJB's, but in a couple of
>> instances
>> >> they
>> >> > strings that just happen to be the serialized form of the EJB. The
>> >> > prototypical code looks like:
>> >> >
>> >> >          ArrayList projectTypes = new ArrayList(
>> >> projectTypeHome.findAll()
>> >> > );
>> >> >          for( int i = 0; i < projectTypes.size(); i++ )
>> >> >          {
>> >> >             ProjectTypeLocal projectType =
>> >> > (ProjectTypeLocal)projectTypes.get( i );
>> >> >             m_projectTypes.add( new SelectItem( projectType,
>> >> > projectType.getName() ) );
>> >> >          }
>> >> >
>> >> > What this means is when we get to the following lines in
>> >> _SelectItemsUtil,
>> >> > the equals() method of the EJB is called with the empty ("") string
>> (in
>> >> > 1.1.5):
>> >> >
>> >> >                  [item is class SelectItem]
>> >> >                  Object itemValue = item.getValue();
>> >> >                  if (value==itemValue || value.equals(itemValue))
>> >> >
>> >> > It appears that the 1.1.3 code handled the case of any String being
>> >> > passed. Since our converters look for an empty string, this results
>> in
>> >> the
>> >> > EJB equals() being passed null:
>> >> >
>> >> >                 Object itemValue = item.getValue();
>> >> >                 if(converter != null && itemValue instanceof String)
>> >> >                 {
>> >> >                     itemValue = converter.getConvertedValue(context,
>> >> > (String)itemValue);
>> >> >                 }
>> >> >                 if (value==itemValue || value.equals(itemValue))
>> >> >
>> >> > But I guess this circles back to non-standard conversion that was
>> taken
>> >> > out.
>> >> >
>> >> > I'm pretty ignorant of all the JSF lifecycle semantics, but since
>> this
>> >> > practice is always used with required="true", would an earlier check
>> >> for a
>> >> > non-null, non-empty string fix this?
>> >> >
>> >> > I'm open to suggestions.
>> >> >
>> >> >
>> >> > Mike Kienenberger wrote:
>> >> >>
>> >> >> Yes, I think you're right.  It's not the form String -> Object
>> that's
>> >> >> causing the issue.
>> >> >> It looks like it's the contents of the selectItem values.  What are
>> >> >> you initializing the selectItem value fields with?
>> >> >>
>> >> >> What's the contents of selectItem.value when it's of type String?
>> >> >>
>> >> >>
>> >> >
>> >> >
>> >>
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9826625
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9841526
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9843207
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: ERROR: Value is not a valid option

Posted by Mike Kienenberger <mk...@gmail.com>.
Yes, I finally figured that out.

Unfortunately, it does mean the equality method on the object is
incorrect since equals() requires symmetric-ness.

http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Object.html#equals(java.lang.Object)
==================
It is symmetric: for any non-null reference values x and y,
x.equals(y)  should return true if and only if y.equals(x) returns
true.
==================

Even if I committed this change, it still wouldn't work in all cases.
 As soon as two different  classes with broken equals()
implementations were involved, you'd get the same error.   All it's
doing is counting on the fact that String.equals() is written
correctly and that you're only mixing MyObject classes and String
classes.

On 4/4/07, fastbob <fa...@gmail.com> wrote:
>
> Sorry I wasn't clear. The null check is incidental, and can be eliminated if
> any of the itemValues can never be null. The key change is the object order
> of the second clause, relying on equality being symmetric. Originally it was
> "value.equals(itemValue)"; now it is "itemValue.equals(value)". So when
> itemValue is the empty string, String equals() will be invoked, rather than
> EJB equals. The String equals() will return false, not an exception.
>
> Mike Kienenberger wrote:
> >
> > I'm not seeing how this will fix the problem.   In the test case you
> > posted, the value is not null -- it's empty string.  So checking
> > against null won't change the behavior.   The ClassCastException will
> > still occur.
> >
> >
> > On 4/3/07, fastbob <fa...@gmail.com> wrote:
> >>
> >> After doing a bit of research, I'm convinced the problem only occurs when
> >> SelectItem.itemValue is an EJB. Given that 1.1.3 and the RI (1.2_04) do
> >> not
> >> have this problem, I suggest the current implementation be changed. If
> >> I'm
> >> wrong, please help me understand. Otherwise, I'll submit a change
> >> request.
> >>
> >> JSP contents:
> >>          <h:selectOneMenu id="client" value="#{myPage.projectType}"
> >> required="true">
> >>              <f:converter converterId="x.y.ProjectTypeConverter"/>
> >>              <f:selectItem itemValue="" itemLabel="--- Select Project
> >> Type---"/>
> >>              <f:selectItems value="#{myPage.projectTypeList}"/>
> >>          </h:selectOneMenu>
> >>
> >> Where ProjectTypeConverter returns null for "" on input and
> >> myPage.projectTypeList is a list of SelectItem created in the following
> >> manner:
> >>
> >>          ArrayList projectTypes = new ArrayList(
> >> projectTypeHome.findAll()
> >> );
> >>          for( int i = 0; i < projectTypes.size(); i++ )
> >>          {
> >>             ProjectTypeLocal projectType =
> >> (ProjectTypeLocal)projectTypes.get( i );
> >>             m_projectTypes.add( new SelectItem( projectType,
> >> projectType.getName() ) );
> >>          }
> >>
> >> Note that the SelectItem.itemValue is an EJB.
> >>
> >> The intent is to force the user to select a value from the list. If no
> >> action is taken by the user, generate an error. This is directly
> >> analogous
> >> to a Tomahawk example, except the values are EJB's.
> >>
> >> The problem:
> >> This worked fine under MyFaces 1.1.3 and appears that it would work under
> >> RI
> >> 1.2_04. Under release 1.1.5, however, a ClassCastException occurs during
> >> the
> >> validation phase, but only if a list item is selected and the item is an
> >> EJB.
> >>
> >> Analysis (based on 1.1.5 release):
> >> During the validation phase, UISelectOne.validateValue is invoked with
> >> the
> >> selected EJB. This causes the following lines in
> >> _SelectItemsUtil.matchValue() to be invoked:
> >>
> >>                 [item is class SelectItem]
> >>                 Object itemValue = item.getValue();
> >>                 if (value==itemValue || value.equals(itemValue))
> >>
> >> This is fine for the SelectItem values that are EJB's, but not for "".
> >> Since
> >> EJB equality requires identity, the EJB equals() method calls
> >> isIdentical()
> >> and immediately encounters an exception casting to EJBLocalObject (code
> >> here
> >> from JBoss 4.0.4GA LocalProxy):
> >>
> >>    Boolean isIdentical(final Object a, final Object b)
> >>    {
> >>       final EJBLocalObject ejb = (EJBLocalObject)a;
> >>       Boolean isIdentical = Boolean.FALSE;
> >>       if( ejb != null )
> >>       {
> >>          isIdentical = new Boolean(ejb.toString().equals(b));
> >>       }
> >>       return isIdentical;
> >>    }
> >>
> >> Possible solution:
> >> Iin _SelectItemsUtil.matchValue() change the lines above to:
> >>
> >>                 [item is class SelectItem]
> >>                 Object itemValue = item.getValue();
> >>                 if (value==itemValue || ( itemValue != null &&
> >> itemValue.equals(value)))
> >>
> >>
> >>
> >>
> >> fastbob wrote:
> >> >
> >> > Usually the selectItem values are EJB's, but in a couple of instances
> >> they
> >> > strings that just happen to be the serialized form of the EJB. The
> >> > prototypical code looks like:
> >> >
> >> >          ArrayList projectTypes = new ArrayList(
> >> projectTypeHome.findAll()
> >> > );
> >> >          for( int i = 0; i < projectTypes.size(); i++ )
> >> >          {
> >> >             ProjectTypeLocal projectType =
> >> > (ProjectTypeLocal)projectTypes.get( i );
> >> >             m_projectTypes.add( new SelectItem( projectType,
> >> > projectType.getName() ) );
> >> >          }
> >> >
> >> > What this means is when we get to the following lines in
> >> _SelectItemsUtil,
> >> > the equals() method of the EJB is called with the empty ("") string (in
> >> > 1.1.5):
> >> >
> >> >                  [item is class SelectItem]
> >> >                  Object itemValue = item.getValue();
> >> >                  if (value==itemValue || value.equals(itemValue))
> >> >
> >> > It appears that the 1.1.3 code handled the case of any String being
> >> > passed. Since our converters look for an empty string, this results in
> >> the
> >> > EJB equals() being passed null:
> >> >
> >> >                 Object itemValue = item.getValue();
> >> >                 if(converter != null && itemValue instanceof String)
> >> >                 {
> >> >                     itemValue = converter.getConvertedValue(context,
> >> > (String)itemValue);
> >> >                 }
> >> >                 if (value==itemValue || value.equals(itemValue))
> >> >
> >> > But I guess this circles back to non-standard conversion that was taken
> >> > out.
> >> >
> >> > I'm pretty ignorant of all the JSF lifecycle semantics, but since this
> >> > practice is always used with required="true", would an earlier check
> >> for a
> >> > non-null, non-empty string fix this?
> >> >
> >> > I'm open to suggestions.
> >> >
> >> >
> >> > Mike Kienenberger wrote:
> >> >>
> >> >> Yes, I think you're right.  It's not the form String -> Object that's
> >> >> causing the issue.
> >> >> It looks like it's the contents of the selectItem values.  What are
> >> >> you initializing the selectItem value fields with?
> >> >>
> >> >> What's the contents of selectItem.value when it's of type String?
> >> >>
> >> >>
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9826625
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9841526
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: ERROR: Value is not a valid option

Posted by fastbob <fa...@gmail.com>.
Sorry I wasn't clear. The null check is incidental, and can be eliminated if
any of the itemValues can never be null. The key change is the object order
of the second clause, relying on equality being symmetric. Originally it was
"value.equals(itemValue)"; now it is "itemValue.equals(value)". So when
itemValue is the empty string, String equals() will be invoked, rather than
EJB equals. The String equals() will return false, not an exception. 

Mike Kienenberger wrote:
> 
> I'm not seeing how this will fix the problem.   In the test case you
> posted, the value is not null -- it's empty string.  So checking
> against null won't change the behavior.   The ClassCastException will
> still occur.
> 
> 
> On 4/3/07, fastbob <fa...@gmail.com> wrote:
>>
>> After doing a bit of research, I'm convinced the problem only occurs when
>> SelectItem.itemValue is an EJB. Given that 1.1.3 and the RI (1.2_04) do
>> not
>> have this problem, I suggest the current implementation be changed. If
>> I'm
>> wrong, please help me understand. Otherwise, I'll submit a change
>> request.
>>
>> JSP contents:
>>          <h:selectOneMenu id="client" value="#{myPage.projectType}"
>> required="true">
>>              <f:converter converterId="x.y.ProjectTypeConverter"/>
>>              <f:selectItem itemValue="" itemLabel="--- Select Project
>> Type---"/>
>>              <f:selectItems value="#{myPage.projectTypeList}"/>
>>          </h:selectOneMenu>
>>
>> Where ProjectTypeConverter returns null for "" on input and
>> myPage.projectTypeList is a list of SelectItem created in the following
>> manner:
>>
>>          ArrayList projectTypes = new ArrayList(
>> projectTypeHome.findAll()
>> );
>>          for( int i = 0; i < projectTypes.size(); i++ )
>>          {
>>             ProjectTypeLocal projectType =
>> (ProjectTypeLocal)projectTypes.get( i );
>>             m_projectTypes.add( new SelectItem( projectType,
>> projectType.getName() ) );
>>          }
>>
>> Note that the SelectItem.itemValue is an EJB.
>>
>> The intent is to force the user to select a value from the list. If no
>> action is taken by the user, generate an error. This is directly
>> analogous
>> to a Tomahawk example, except the values are EJB's.
>>
>> The problem:
>> This worked fine under MyFaces 1.1.3 and appears that it would work under
>> RI
>> 1.2_04. Under release 1.1.5, however, a ClassCastException occurs during
>> the
>> validation phase, but only if a list item is selected and the item is an
>> EJB.
>>
>> Analysis (based on 1.1.5 release):
>> During the validation phase, UISelectOne.validateValue is invoked with
>> the
>> selected EJB. This causes the following lines in
>> _SelectItemsUtil.matchValue() to be invoked:
>>
>>                 [item is class SelectItem]
>>                 Object itemValue = item.getValue();
>>                 if (value==itemValue || value.equals(itemValue))
>>
>> This is fine for the SelectItem values that are EJB's, but not for "".
>> Since
>> EJB equality requires identity, the EJB equals() method calls
>> isIdentical()
>> and immediately encounters an exception casting to EJBLocalObject (code
>> here
>> from JBoss 4.0.4GA LocalProxy):
>>
>>    Boolean isIdentical(final Object a, final Object b)
>>    {
>>       final EJBLocalObject ejb = (EJBLocalObject)a;
>>       Boolean isIdentical = Boolean.FALSE;
>>       if( ejb != null )
>>       {
>>          isIdentical = new Boolean(ejb.toString().equals(b));
>>       }
>>       return isIdentical;
>>    }
>>
>> Possible solution:
>> Iin _SelectItemsUtil.matchValue() change the lines above to:
>>
>>                 [item is class SelectItem]
>>                 Object itemValue = item.getValue();
>>                 if (value==itemValue || ( itemValue != null &&
>> itemValue.equals(value)))
>>
>>
>>
>>
>> fastbob wrote:
>> >
>> > Usually the selectItem values are EJB's, but in a couple of instances
>> they
>> > strings that just happen to be the serialized form of the EJB. The
>> > prototypical code looks like:
>> >
>> >          ArrayList projectTypes = new ArrayList(
>> projectTypeHome.findAll()
>> > );
>> >          for( int i = 0; i < projectTypes.size(); i++ )
>> >          {
>> >             ProjectTypeLocal projectType =
>> > (ProjectTypeLocal)projectTypes.get( i );
>> >             m_projectTypes.add( new SelectItem( projectType,
>> > projectType.getName() ) );
>> >          }
>> >
>> > What this means is when we get to the following lines in
>> _SelectItemsUtil,
>> > the equals() method of the EJB is called with the empty ("") string (in
>> > 1.1.5):
>> >
>> >                  [item is class SelectItem]
>> >                  Object itemValue = item.getValue();
>> >                  if (value==itemValue || value.equals(itemValue))
>> >
>> > It appears that the 1.1.3 code handled the case of any String being
>> > passed. Since our converters look for an empty string, this results in
>> the
>> > EJB equals() being passed null:
>> >
>> >                 Object itemValue = item.getValue();
>> >                 if(converter != null && itemValue instanceof String)
>> >                 {
>> >                     itemValue = converter.getConvertedValue(context,
>> > (String)itemValue);
>> >                 }
>> >                 if (value==itemValue || value.equals(itemValue))
>> >
>> > But I guess this circles back to non-standard conversion that was taken
>> > out.
>> >
>> > I'm pretty ignorant of all the JSF lifecycle semantics, but since this
>> > practice is always used with required="true", would an earlier check
>> for a
>> > non-null, non-empty string fix this?
>> >
>> > I'm open to suggestions.
>> >
>> >
>> > Mike Kienenberger wrote:
>> >>
>> >> Yes, I think you're right.  It's not the form String -> Object that's
>> >> causing the issue.
>> >> It looks like it's the contents of the selectItem values.  What are
>> >> you initializing the selectItem value fields with?
>> >>
>> >> What's the contents of selectItem.value when it's of type String?
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9826625
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9841526
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: ERROR: Value is not a valid option

Posted by Mike Kienenberger <mk...@gmail.com>.
I'm not seeing how this will fix the problem.   In the test case you
posted, the value is not null -- it's empty string.  So checking
against null won't change the behavior.   The ClassCastException will
still occur.


On 4/3/07, fastbob <fa...@gmail.com> wrote:
>
> After doing a bit of research, I'm convinced the problem only occurs when
> SelectItem.itemValue is an EJB. Given that 1.1.3 and the RI (1.2_04) do not
> have this problem, I suggest the current implementation be changed. If I'm
> wrong, please help me understand. Otherwise, I'll submit a change request.
>
> JSP contents:
>          <h:selectOneMenu id="client" value="#{myPage.projectType}"
> required="true">
>              <f:converter converterId="x.y.ProjectTypeConverter"/>
>              <f:selectItem itemValue="" itemLabel="--- Select Project
> Type---"/>
>              <f:selectItems value="#{myPage.projectTypeList}"/>
>          </h:selectOneMenu>
>
> Where ProjectTypeConverter returns null for "" on input and
> myPage.projectTypeList is a list of SelectItem created in the following
> manner:
>
>          ArrayList projectTypes = new ArrayList( projectTypeHome.findAll()
> );
>          for( int i = 0; i < projectTypes.size(); i++ )
>          {
>             ProjectTypeLocal projectType =
> (ProjectTypeLocal)projectTypes.get( i );
>             m_projectTypes.add( new SelectItem( projectType,
> projectType.getName() ) );
>          }
>
> Note that the SelectItem.itemValue is an EJB.
>
> The intent is to force the user to select a value from the list. If no
> action is taken by the user, generate an error. This is directly analogous
> to a Tomahawk example, except the values are EJB's.
>
> The problem:
> This worked fine under MyFaces 1.1.3 and appears that it would work under RI
> 1.2_04. Under release 1.1.5, however, a ClassCastException occurs during the
> validation phase, but only if a list item is selected and the item is an
> EJB.
>
> Analysis (based on 1.1.5 release):
> During the validation phase, UISelectOne.validateValue is invoked with the
> selected EJB. This causes the following lines in
> _SelectItemsUtil.matchValue() to be invoked:
>
>                 [item is class SelectItem]
>                 Object itemValue = item.getValue();
>                 if (value==itemValue || value.equals(itemValue))
>
> This is fine for the SelectItem values that are EJB's, but not for "". Since
> EJB equality requires identity, the EJB equals() method calls isIdentical()
> and immediately encounters an exception casting to EJBLocalObject (code here
> from JBoss 4.0.4GA LocalProxy):
>
>    Boolean isIdentical(final Object a, final Object b)
>    {
>       final EJBLocalObject ejb = (EJBLocalObject)a;
>       Boolean isIdentical = Boolean.FALSE;
>       if( ejb != null )
>       {
>          isIdentical = new Boolean(ejb.toString().equals(b));
>       }
>       return isIdentical;
>    }
>
> Possible solution:
> Iin _SelectItemsUtil.matchValue() change the lines above to:
>
>                 [item is class SelectItem]
>                 Object itemValue = item.getValue();
>                 if (value==itemValue || ( itemValue != null &&
> itemValue.equals(value)))
>
>
>
>
> fastbob wrote:
> >
> > Usually the selectItem values are EJB's, but in a couple of instances they
> > strings that just happen to be the serialized form of the EJB. The
> > prototypical code looks like:
> >
> >          ArrayList projectTypes = new ArrayList( projectTypeHome.findAll()
> > );
> >          for( int i = 0; i < projectTypes.size(); i++ )
> >          {
> >             ProjectTypeLocal projectType =
> > (ProjectTypeLocal)projectTypes.get( i );
> >             m_projectTypes.add( new SelectItem( projectType,
> > projectType.getName() ) );
> >          }
> >
> > What this means is when we get to the following lines in _SelectItemsUtil,
> > the equals() method of the EJB is called with the empty ("") string (in
> > 1.1.5):
> >
> >                  [item is class SelectItem]
> >                  Object itemValue = item.getValue();
> >                  if (value==itemValue || value.equals(itemValue))
> >
> > It appears that the 1.1.3 code handled the case of any String being
> > passed. Since our converters look for an empty string, this results in the
> > EJB equals() being passed null:
> >
> >                 Object itemValue = item.getValue();
> >                 if(converter != null && itemValue instanceof String)
> >                 {
> >                     itemValue = converter.getConvertedValue(context,
> > (String)itemValue);
> >                 }
> >                 if (value==itemValue || value.equals(itemValue))
> >
> > But I guess this circles back to non-standard conversion that was taken
> > out.
> >
> > I'm pretty ignorant of all the JSF lifecycle semantics, but since this
> > practice is always used with required="true", would an earlier check for a
> > non-null, non-empty string fix this?
> >
> > I'm open to suggestions.
> >
> >
> > Mike Kienenberger wrote:
> >>
> >> Yes, I think you're right.  It's not the form String -> Object that's
> >> causing the issue.
> >> It looks like it's the contents of the selectItem values.  What are
> >> you initializing the selectItem value fields with?
> >>
> >> What's the contents of selectItem.value when it's of type String?
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9826625
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: ERROR: Value is not a valid option

Posted by Mike Kienenberger <mk...@gmail.com>.
Open a JIRA with a simple example, and I'll take a look (unless
someone else beats me to it).

At first glance, I think you're probably right -- we need to handle
the case that itemValue might be null.  I wonder why I haven't hit an
issue with this yet?




On 4/3/07, fastbob <fa...@gmail.com> wrote:
>
> After doing a bit of research, I'm convinced the problem only occurs when
> SelectItem.itemValue is an EJB. Given that 1.1.3 and the RI (1.2_04) do not
> have this problem, I suggest the current implementation be changed. If I'm
> wrong, please help me understand. Otherwise, I'll submit a change request.
>
> JSP contents:
>          <h:selectOneMenu id="client" value="#{myPage.projectType}"
> required="true">
>              <f:converter converterId="x.y.ProjectTypeConverter"/>
>              <f:selectItem itemValue="" itemLabel="--- Select Project
> Type---"/>
>              <f:selectItems value="#{myPage.projectTypeList}"/>
>          </h:selectOneMenu>
>
> Where ProjectTypeConverter returns null for "" on input and
> myPage.projectTypeList is a list of SelectItem created in the following
> manner:
>
>          ArrayList projectTypes = new ArrayList( projectTypeHome.findAll()
> );
>          for( int i = 0; i < projectTypes.size(); i++ )
>          {
>             ProjectTypeLocal projectType =
> (ProjectTypeLocal)projectTypes.get( i );
>             m_projectTypes.add( new SelectItem( projectType,
> projectType.getName() ) );
>          }
>
> Note that the SelectItem.itemValue is an EJB.
>
> The intent is to force the user to select a value from the list. If no
> action is taken by the user, generate an error. This is directly analogous
> to a Tomahawk example, except the values are EJB's.
>
> The problem:
> This worked fine under MyFaces 1.1.3 and appears that it would work under RI
> 1.2_04. Under release 1.1.5, however, a ClassCastException occurs during the
> validation phase, but only if a list item is selected and the item is an
> EJB.
>
> Analysis (based on 1.1.5 release):
> During the validation phase, UISelectOne.validateValue is invoked with the
> selected EJB. This causes the following lines in
> _SelectItemsUtil.matchValue() to be invoked:
>
>                 [item is class SelectItem]
>                 Object itemValue = item.getValue();
>                 if (value==itemValue || value.equals(itemValue))
>
> This is fine for the SelectItem values that are EJB's, but not for "". Since
> EJB equality requires identity, the EJB equals() method calls isIdentical()
> and immediately encounters an exception casting to EJBLocalObject (code here
> from JBoss 4.0.4GA LocalProxy):
>
>    Boolean isIdentical(final Object a, final Object b)
>    {
>       final EJBLocalObject ejb = (EJBLocalObject)a;
>       Boolean isIdentical = Boolean.FALSE;
>       if( ejb != null )
>       {
>          isIdentical = new Boolean(ejb.toString().equals(b));
>       }
>       return isIdentical;
>    }
>
> Possible solution:
> Iin _SelectItemsUtil.matchValue() change the lines above to:
>
>                 [item is class SelectItem]
>                 Object itemValue = item.getValue();
>                 if (value==itemValue || ( itemValue != null &&
> itemValue.equals(value)))
>
>
>
>
> fastbob wrote:
> >
> > Usually the selectItem values are EJB's, but in a couple of instances they
> > strings that just happen to be the serialized form of the EJB. The
> > prototypical code looks like:
> >
> >          ArrayList projectTypes = new ArrayList( projectTypeHome.findAll()
> > );
> >          for( int i = 0; i < projectTypes.size(); i++ )
> >          {
> >             ProjectTypeLocal projectType =
> > (ProjectTypeLocal)projectTypes.get( i );
> >             m_projectTypes.add( new SelectItem( projectType,
> > projectType.getName() ) );
> >          }
> >
> > What this means is when we get to the following lines in _SelectItemsUtil,
> > the equals() method of the EJB is called with the empty ("") string (in
> > 1.1.5):
> >
> >                  [item is class SelectItem]
> >                  Object itemValue = item.getValue();
> >                  if (value==itemValue || value.equals(itemValue))
> >
> > It appears that the 1.1.3 code handled the case of any String being
> > passed. Since our converters look for an empty string, this results in the
> > EJB equals() being passed null:
> >
> >                 Object itemValue = item.getValue();
> >                 if(converter != null && itemValue instanceof String)
> >                 {
> >                     itemValue = converter.getConvertedValue(context,
> > (String)itemValue);
> >                 }
> >                 if (value==itemValue || value.equals(itemValue))
> >
> > But I guess this circles back to non-standard conversion that was taken
> > out.
> >
> > I'm pretty ignorant of all the JSF lifecycle semantics, but since this
> > practice is always used with required="true", would an earlier check for a
> > non-null, non-empty string fix this?
> >
> > I'm open to suggestions.
> >
> >
> > Mike Kienenberger wrote:
> >>
> >> Yes, I think you're right.  It's not the form String -> Object that's
> >> causing the issue.
> >> It looks like it's the contents of the selectItem values.  What are
> >> you initializing the selectItem value fields with?
> >>
> >> What's the contents of selectItem.value when it's of type String?
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9826625
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: ERROR: Value is not a valid option

Posted by fastbob <fa...@gmail.com>.
After doing a bit of research, I'm convinced the problem only occurs when
SelectItem.itemValue is an EJB. Given that 1.1.3 and the RI (1.2_04) do not
have this problem, I suggest the current implementation be changed. If I'm
wrong, please help me understand. Otherwise, I'll submit a change request.

JSP contents:
         <h:selectOneMenu id="client" value="#{myPage.projectType}"
required="true"> 
             <f:converter converterId="x.y.ProjectTypeConverter"/> 
             <f:selectItem itemValue="" itemLabel="--- Select Project
Type---"/> 
             <f:selectItems value="#{myPage.projectTypeList}"/> 
         </h:selectOneMenu> 

Where ProjectTypeConverter returns null for "" on input and
myPage.projectTypeList is a list of SelectItem created in the following
manner:

         ArrayList projectTypes = new ArrayList( projectTypeHome.findAll()
);
         for( int i = 0; i < projectTypes.size(); i++ )
         {
            ProjectTypeLocal projectType =
(ProjectTypeLocal)projectTypes.get( i );
            m_projectTypes.add( new SelectItem( projectType,
projectType.getName() ) );
         }

Note that the SelectItem.itemValue is an EJB. 

The intent is to force the user to select a value from the list. If no
action is taken by the user, generate an error. This is directly analogous
to a Tomahawk example, except the values are EJB's.

The problem:
This worked fine under MyFaces 1.1.3 and appears that it would work under RI
1.2_04. Under release 1.1.5, however, a ClassCastException occurs during the
validation phase, but only if a list item is selected and the item is an
EJB.

Analysis (based on 1.1.5 release):
During the validation phase, UISelectOne.validateValue is invoked with the
selected EJB. This causes the following lines in
_SelectItemsUtil.matchValue() to be invoked:

                [item is class SelectItem] 
                Object itemValue = item.getValue(); 
                if (value==itemValue || value.equals(itemValue)) 

This is fine for the SelectItem values that are EJB's, but not for "". Since
EJB equality requires identity, the EJB equals() method calls isIdentical()
and immediately encounters an exception casting to EJBLocalObject (code here
from JBoss 4.0.4GA LocalProxy):

   Boolean isIdentical(final Object a, final Object b)
   {
      final EJBLocalObject ejb = (EJBLocalObject)a;
      Boolean isIdentical = Boolean.FALSE;
      if( ejb != null )
      {
         isIdentical = new Boolean(ejb.toString().equals(b));
      }
      return isIdentical;
   }

Possible solution:
Iin _SelectItemsUtil.matchValue() change the lines above to:

                [item is class SelectItem] 
                Object itemValue = item.getValue(); 
                if (value==itemValue || ( itemValue != null &&
itemValue.equals(value))) 




fastbob wrote:
> 
> Usually the selectItem values are EJB's, but in a couple of instances they
> strings that just happen to be the serialized form of the EJB. The
> prototypical code looks like:
> 
>          ArrayList projectTypes = new ArrayList( projectTypeHome.findAll()
> );
>          for( int i = 0; i < projectTypes.size(); i++ )
>          {
>             ProjectTypeLocal projectType =
> (ProjectTypeLocal)projectTypes.get( i );
>             m_projectTypes.add( new SelectItem( projectType,
> projectType.getName() ) );
>          }
> 
> What this means is when we get to the following lines in _SelectItemsUtil,
> the equals() method of the EJB is called with the empty ("") string (in
> 1.1.5):
> 
>                  [item is class SelectItem]
>                  Object itemValue = item.getValue();
>                  if (value==itemValue || value.equals(itemValue))
> 
> It appears that the 1.1.3 code handled the case of any String being
> passed. Since our converters look for an empty string, this results in the
> EJB equals() being passed null:
> 
>                 Object itemValue = item.getValue();
>                 if(converter != null && itemValue instanceof String)
>                 {
>                     itemValue = converter.getConvertedValue(context,
> (String)itemValue);
>                 }
>                 if (value==itemValue || value.equals(itemValue))
> 
> But I guess this circles back to non-standard conversion that was taken
> out.
> 
> I'm pretty ignorant of all the JSF lifecycle semantics, but since this
> practice is always used with required="true", would an earlier check for a
> non-null, non-empty string fix this?
> 
> I'm open to suggestions.
> 
> 
> Mike Kienenberger wrote:
>> 
>> Yes, I think you're right.  It's not the form String -> Object that's
>> causing the issue.
>> It looks like it's the contents of the selectItem values.  What are
>> you initializing the selectItem value fields with?
>> 
>> What's the contents of selectItem.value when it's of type String?
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9826625
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: ERROR: Value is not a valid option

Posted by fastbob <fa...@gmail.com>.
Usually the selectItem values are EJB's, but in a couple of instances they
strings that just happen to be the serialized form of the EJB. The
prototypical code looks like:

         ArrayList projectTypes = new ArrayList( projectTypeHome.findAll()
);
         for( int i = 0; i < projectTypes.size(); i++ )
         {
            ProjectTypeLocal projectType =
(ProjectTypeLocal)projectTypes.get( i );
            m_projectTypes.add( new SelectItem( projectType,
projectType.getName() ) );
         }

What this means is when we get to the following lines in _SelectItemsUtil,
the equals() method of the EJB is called with the empty ("") string (in
1.1.5):

                 [item is class SelectItem]
                 Object itemValue = item.getValue();
                 if (value==itemValue || value.equals(itemValue))

It appears that the 1.1.3 code handled the case of any String being passed.
Since our converters look for an empty string, this results in the EJB
equals() being passed null:

                Object itemValue = item.getValue();
                if(converter != null && itemValue instanceof String)
                {
                    itemValue = converter.getConvertedValue(context,
(String)itemValue);
                }
                if (value==itemValue || value.equals(itemValue))

But I guess this circles back to non-standard conversion that was taken out.

I'm pretty ignorant of all the JSF lifecycle semantics, but since this
practice is always used with required="true", would an earlier check for a
non-null, non-empty string fix this?

I'm open to suggestions.


Mike Kienenberger wrote:
> 
> Yes, I think you're right.  It's not the form String -> Object that's
> causing the issue.
> It looks like it's the contents of the selectItem values.  What are
> you initializing the selectItem value fields with?
> 
> What's the contents of selectItem.value when it's of type String?
> 
> On 3/30/07, fastbob <fa...@gmail.com> wrote:
>>
>> Hmmm. I must be missing something. Other than parameterization, including
>> your use of disable and null values, I don't see any significant
>> differences
>> (I also tried moving the converter into the h:selectOneMenu - no effect).
>> In
>> fact, the Tomahawk example uses "" as a nothing -selected value, just as
>> we
>> do. And the converter code is essentially identical - we start with:
>>
>>       if( string == null || string.trim().length() == 0 )
>>          return null;
>>
>> So why are we getting an exception during the validation phase?
>>
>> Bob
>>
>>
>> Mike Kienenberger wrote:
>> >
>> > Here's how the tomahawk examples do it:
>> >
>> >                 <h:selectOneMenu id="selone_menu_colors"
>> > value="#{carconf.color}" styleClass="selectOneMenu"
>> > converter="#{carconf.colorConverter}">
>> >                     <f:selectItem itemValue=""
>> > itemLabel="#{example_messages['empty_selitem']}" />
>> >
>> >
>> >
>> >         public Object getAsObject(FacesContext facesContext,
>> > UIComponent component, String string) throws ConverterException
>> >         {
>> >             if(string==null)
>> >                 return null;
>> >
>> >
>> > Here's how I do it on my own projects:
>> >
>> >     public final static String DISABLED_OPTION_VALUE =
>> > "com.xyz.utilities.web.jsf.converter.DISABLED_OPTION_VALUE";
>> >     public final static String NULL_OPTION_VALUE =
>> > "com.xyz.utilities.web.jsf.converter.NULL_OPTION_VALUE";
>> >
>> >     public String getNullSelectItemOptionValue() {
>> >         return
>> > com.xyz.utilities.web.jsf.converter.ConverterOptions.NULL_OPTION_VALUE;
>> >     }
>> >
>> > <f:selectItem
>> >       itemValue="#{myPage.nullSelectItemOptionValue}"
>> >       itemLabel="&lt;No selection&gt;" />
>> >
>> >     public Object getAsObject(FacesContext context, UIComponent
>> > component, String value) throws ConverterException
>> >     {
>> >       if (null == value)  return null;
>> >         if (ConverterOptions.DISABLED_OPTION_VALUE.equals(value)) 
>> return
>> > null;
>> >         if (ConverterOptions.NULL_OPTION_VALUE.equals(value))  return
>> > null;
>> >
>> > On 3/30/07, fastbob <fa...@gmail.com> wrote:
>> >>
>> >>
>> >> Mike Kienenberger wrote:
>> >> >
>> >> > Yes, that's how I would do it.  If you specify an itemValue, then
>> that
>> >> > value must be of the correct type.  Ie, " " is not a containerType
>> >> > (Srinivas) and "0" is not a region (Carl).
>> >> >
>> >> Ouch. The assumption is that there is a one-one correspondence between
>> >> the
>> >> list items and the type in the model. This isn't always the case.
>> >>
>> >> We had a number of JSP's under 1.1.3 with the following sequence, for
>> >> several different types of lists:
>> >>
>> >>          <h:selectOneMenu id="client" value="#{myPage.projectType}">
>> >>              <f:converter converterId="x.y.ProjectTypeConverter"/>
>> >>              <f:selectItem itemValue="" itemLabel="--- Select Project
>> >> Type---"/>
>> >>              <f:selectItems value="#{myPage.projectTypeList}"/>
>> >>          </h:selectOneMenu>
>> >>
>> >> The values in the type are fixed (essentially an enumeration, but not
>> >> implemented that way), and there is no "empty" value available.
>> Instead,
>> >> if
>> >> the converters are passed a null or empty string for conversion to the
>> >> underlying type, they immediately return null. So in this case null is
>> >> used
>> >> to indicate no value has been selected by the user, and they get an
>> >> error.
>> >>
>> >> With 1.1.5, we get the following exception:
>> >>
>> >> java.lang.ClassCastException: java.lang.String cannot be cast to
>> >> javax.ejb.EJBLocalObject
>> >>             at
>> >>
>> org.jboss.ejb.plugins.local.LocalProxy.isIdentical(LocalProxy.java:124)
>> >>             at
>> >> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:174)
>> >>             at
>> >> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
>> >>             at
>> >> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:155)
>> >>             at
>> >> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
>> >>            at $Proxy262.equals(Unknown Source)
>> >>             at
>> >>
>> javax.faces.component._SelectItemsUtil.matchValue(_SelectItemsUtil.java:65)
>> >>             at
>> >> javax.faces.component.UISelectOne.validateValue(UISelectOne.java:56)
>> >>             at
>> javax.faces.component.UIInput.validate(UIInput.java:354)
>> >>             at
>> >> javax.faces.component.UIInput.processValidators(UIInput.java:184)
>> >>             […]
>> >>
>> >> Here are the relevant lines from _SelectItemsUtil.MatchValue():
>> >>
>> >>                 [item is class SelectItem]
>> >>                 Object itemValue = item.getValue();
>> >>                 if (value==itemValue || value.equals(itemValue))
>> >>
>> >> The exception is thrown by the call to equals in an EJB.
>> >>
>> >> I haven't come up with a low-cost way to fix this.
>> >>
>> >> Bob
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762021
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762503
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9797466
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: ERROR: Value is not a valid option

Posted by Mike Kienenberger <mk...@gmail.com>.
Yes, I think you're right.  It's not the form String -> Object that's
causing the issue.
It looks like it's the contents of the selectItem values.  What are
you initializing the selectItem value fields with?

What's the contents of selectItem.value when it's of type String?

On 3/30/07, fastbob <fa...@gmail.com> wrote:
>
> Hmmm. I must be missing something. Other than parameterization, including
> your use of disable and null values, I don't see any significant differences
> (I also tried moving the converter into the h:selectOneMenu - no effect). In
> fact, the Tomahawk example uses "" as a nothing -selected value, just as we
> do. And the converter code is essentially identical - we start with:
>
>       if( string == null || string.trim().length() == 0 )
>          return null;
>
> So why are we getting an exception during the validation phase?
>
> Bob
>
>
> Mike Kienenberger wrote:
> >
> > Here's how the tomahawk examples do it:
> >
> >                 <h:selectOneMenu id="selone_menu_colors"
> > value="#{carconf.color}" styleClass="selectOneMenu"
> > converter="#{carconf.colorConverter}">
> >                     <f:selectItem itemValue=""
> > itemLabel="#{example_messages['empty_selitem']}" />
> >
> >
> >
> >         public Object getAsObject(FacesContext facesContext,
> > UIComponent component, String string) throws ConverterException
> >         {
> >             if(string==null)
> >                 return null;
> >
> >
> > Here's how I do it on my own projects:
> >
> >     public final static String DISABLED_OPTION_VALUE =
> > "com.xyz.utilities.web.jsf.converter.DISABLED_OPTION_VALUE";
> >     public final static String NULL_OPTION_VALUE =
> > "com.xyz.utilities.web.jsf.converter.NULL_OPTION_VALUE";
> >
> >     public String getNullSelectItemOptionValue() {
> >         return
> > com.xyz.utilities.web.jsf.converter.ConverterOptions.NULL_OPTION_VALUE;
> >     }
> >
> > <f:selectItem
> >       itemValue="#{myPage.nullSelectItemOptionValue}"
> >       itemLabel="&lt;No selection&gt;" />
> >
> >     public Object getAsObject(FacesContext context, UIComponent
> > component, String value) throws ConverterException
> >     {
> >       if (null == value)  return null;
> >         if (ConverterOptions.DISABLED_OPTION_VALUE.equals(value))  return
> > null;
> >         if (ConverterOptions.NULL_OPTION_VALUE.equals(value))  return
> > null;
> >
> > On 3/30/07, fastbob <fa...@gmail.com> wrote:
> >>
> >>
> >> Mike Kienenberger wrote:
> >> >
> >> > Yes, that's how I would do it.  If you specify an itemValue, then that
> >> > value must be of the correct type.  Ie, " " is not a containerType
> >> > (Srinivas) and "0" is not a region (Carl).
> >> >
> >> Ouch. The assumption is that there is a one-one correspondence between
> >> the
> >> list items and the type in the model. This isn't always the case.
> >>
> >> We had a number of JSP's under 1.1.3 with the following sequence, for
> >> several different types of lists:
> >>
> >>          <h:selectOneMenu id="client" value="#{myPage.projectType}">
> >>              <f:converter converterId="x.y.ProjectTypeConverter"/>
> >>              <f:selectItem itemValue="" itemLabel="--- Select Project
> >> Type---"/>
> >>              <f:selectItems value="#{myPage.projectTypeList}"/>
> >>          </h:selectOneMenu>
> >>
> >> The values in the type are fixed (essentially an enumeration, but not
> >> implemented that way), and there is no "empty" value available. Instead,
> >> if
> >> the converters are passed a null or empty string for conversion to the
> >> underlying type, they immediately return null. So in this case null is
> >> used
> >> to indicate no value has been selected by the user, and they get an
> >> error.
> >>
> >> With 1.1.5, we get the following exception:
> >>
> >> java.lang.ClassCastException: java.lang.String cannot be cast to
> >> javax.ejb.EJBLocalObject
> >>             at
> >> org.jboss.ejb.plugins.local.LocalProxy.isIdentical(LocalProxy.java:124)
> >>             at
> >> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:174)
> >>             at
> >> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
> >>             at
> >> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:155)
> >>             at
> >> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
> >>            at $Proxy262.equals(Unknown Source)
> >>             at
> >> javax.faces.component._SelectItemsUtil.matchValue(_SelectItemsUtil.java:65)
> >>             at
> >> javax.faces.component.UISelectOne.validateValue(UISelectOne.java:56)
> >>             at javax.faces.component.UIInput.validate(UIInput.java:354)
> >>             at
> >> javax.faces.component.UIInput.processValidators(UIInput.java:184)
> >>             […]
> >>
> >> Here are the relevant lines from _SelectItemsUtil.MatchValue():
> >>
> >>                 [item is class SelectItem]
> >>                 Object itemValue = item.getValue();
> >>                 if (value==itemValue || value.equals(itemValue))
> >>
> >> The exception is thrown by the call to equals in an EJB.
> >>
> >> I haven't come up with a low-cost way to fix this.
> >>
> >> Bob
> >> --
> >> View this message in context:
> >> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762021
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762503
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: ERROR: Value is not a valid option

Posted by fastbob <fa...@gmail.com>.
Sure. See below. But before you check that, we're making it through the apply
values phase. If the user does not select a value from the list, they get an
error due to required="true" (oops - when I edited for posting I deleted the
required). If they do select a value, the converter is called with a
non-null string and a valid object is found. The exception occurs later
during validation.

   public Object getAsObject ( FacesContext facesContext,  UIComponent
uiComponent, String string )
      throws ConverterException
   {
      if( string == null || string.trim().length() == 0 )
         return null;
      
      try
      {
         ProjectTypesHomeLocal ptHomeLocal = (ProjectTypesHomeLocal)new
InitialContext().lookup( "projectTypes" );
         return ptHomeLocal.findByPrimaryKey( Integer.valueOf( string ) );
      }
      catch( NamingException e )
      {
         throw new ConverterException( e );
      }
      catch( FinderException e )
      {
         throw new ConverterException( e );
      }
   }


Mike Kienenberger wrote:
> 
> Post the getAsObject method from ProjectTypeConverter.
> 
> On 3/30/07, fastbob <fa...@gmail.com> wrote:
>>
>> Hmmm. I must be missing something. Other than parameterization, including
>> your use of disable and null values, I don't see any significant
>> differences
>> (I also tried moving the converter into the h:selectOneMenu - no effect).
>> In
>> fact, the Tomahawk example uses "" as a nothing -selected value, just as
>> we
>> do. And the converter code is essentially identical - we start with:
>>
>>       if( string == null || string.trim().length() == 0 )
>>          return null;
>>
>> So why are we getting an exception during the validation phase?
>>
>> Bob
>>
>>
>> Mike Kienenberger wrote:
>> >
>> > Here's how the tomahawk examples do it:
>> >
>> >                 <h:selectOneMenu id="selone_menu_colors"
>> > value="#{carconf.color}" styleClass="selectOneMenu"
>> > converter="#{carconf.colorConverter}">
>> >                     <f:selectItem itemValue=""
>> > itemLabel="#{example_messages['empty_selitem']}" />
>> >
>> >
>> >
>> >         public Object getAsObject(FacesContext facesContext,
>> > UIComponent component, String string) throws ConverterException
>> >         {
>> >             if(string==null)
>> >                 return null;
>> >
>> >
>> > Here's how I do it on my own projects:
>> >
>> >     public final static String DISABLED_OPTION_VALUE =
>> > "com.xyz.utilities.web.jsf.converter.DISABLED_OPTION_VALUE";
>> >     public final static String NULL_OPTION_VALUE =
>> > "com.xyz.utilities.web.jsf.converter.NULL_OPTION_VALUE";
>> >
>> >     public String getNullSelectItemOptionValue() {
>> >         return
>> > com.xyz.utilities.web.jsf.converter.ConverterOptions.NULL_OPTION_VALUE;
>> >     }
>> >
>> > <f:selectItem
>> >       itemValue="#{myPage.nullSelectItemOptionValue}"
>> >       itemLabel="&lt;No selection&gt;" />
>> >
>> >     public Object getAsObject(FacesContext context, UIComponent
>> > component, String value) throws ConverterException
>> >     {
>> >       if (null == value)  return null;
>> >         if (ConverterOptions.DISABLED_OPTION_VALUE.equals(value)) 
>> return
>> > null;
>> >         if (ConverterOptions.NULL_OPTION_VALUE.equals(value))  return
>> > null;
>> >
>> > On 3/30/07, fastbob <fa...@gmail.com> wrote:
>> >>
>> >>
>> >> Mike Kienenberger wrote:
>> >> >
>> >> > Yes, that's how I would do it.  If you specify an itemValue, then
>> that
>> >> > value must be of the correct type.  Ie, " " is not a containerType
>> >> > (Srinivas) and "0" is not a region (Carl).
>> >> >
>> >> Ouch. The assumption is that there is a one-one correspondence between
>> >> the
>> >> list items and the type in the model. This isn't always the case.
>> >>
>> >> We had a number of JSP's under 1.1.3 with the following sequence, for
>> >> several different types of lists:
>> >>
>> >>          <h:selectOneMenu id="client" value="#{myPage.projectType}">
>> >>              <f:converter converterId="x.y.ProjectTypeConverter"/>
>> >>              <f:selectItem itemValue="" itemLabel="--- Select Project
>> >> Type---"/>
>> >>              <f:selectItems value="#{myPage.projectTypeList}"/>
>> >>          </h:selectOneMenu>
>> >>
>> >> The values in the type are fixed (essentially an enumeration, but not
>> >> implemented that way), and there is no "empty" value available.
>> Instead,
>> >> if
>> >> the converters are passed a null or empty string for conversion to the
>> >> underlying type, they immediately return null. So in this case null is
>> >> used
>> >> to indicate no value has been selected by the user, and they get an
>> >> error.
>> >>
>> >> With 1.1.5, we get the following exception:
>> >>
>> >> java.lang.ClassCastException: java.lang.String cannot be cast to
>> >> javax.ejb.EJBLocalObject
>> >>             at
>> >>
>> org.jboss.ejb.plugins.local.LocalProxy.isIdentical(LocalProxy.java:124)
>> >>             at
>> >> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:174)
>> >>             at
>> >> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
>> >>             at
>> >> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:155)
>> >>             at
>> >> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
>> >>            at $Proxy262.equals(Unknown Source)
>> >>             at
>> >>
>> javax.faces.component._SelectItemsUtil.matchValue(_SelectItemsUtil.java:65)
>> >>             at
>> >> javax.faces.component.UISelectOne.validateValue(UISelectOne.java:56)
>> >>             at
>> javax.faces.component.UIInput.validate(UIInput.java:354)
>> >>             at
>> >> javax.faces.component.UIInput.processValidators(UIInput.java:184)
>> >>             […]
>> >>
>> >> Here are the relevant lines from _SelectItemsUtil.MatchValue():
>> >>
>> >>                 [item is class SelectItem]
>> >>                 Object itemValue = item.getValue();
>> >>                 if (value==itemValue || value.equals(itemValue))
>> >>
>> >> The exception is thrown by the call to equals in an EJB.
>> >>
>> >> I haven't come up with a low-cost way to fix this.
>> >>
>> >> Bob
>> >> --
>> >> View this message in context:
>> >>
>> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762021
>> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>> >>
>> >>
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762503
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762785
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: ERROR: Value is not a valid option

Posted by Mike Kienenberger <mk...@gmail.com>.
Post the getAsObject method from ProjectTypeConverter.

On 3/30/07, fastbob <fa...@gmail.com> wrote:
>
> Hmmm. I must be missing something. Other than parameterization, including
> your use of disable and null values, I don't see any significant differences
> (I also tried moving the converter into the h:selectOneMenu - no effect). In
> fact, the Tomahawk example uses "" as a nothing -selected value, just as we
> do. And the converter code is essentially identical - we start with:
>
>       if( string == null || string.trim().length() == 0 )
>          return null;
>
> So why are we getting an exception during the validation phase?
>
> Bob
>
>
> Mike Kienenberger wrote:
> >
> > Here's how the tomahawk examples do it:
> >
> >                 <h:selectOneMenu id="selone_menu_colors"
> > value="#{carconf.color}" styleClass="selectOneMenu"
> > converter="#{carconf.colorConverter}">
> >                     <f:selectItem itemValue=""
> > itemLabel="#{example_messages['empty_selitem']}" />
> >
> >
> >
> >         public Object getAsObject(FacesContext facesContext,
> > UIComponent component, String string) throws ConverterException
> >         {
> >             if(string==null)
> >                 return null;
> >
> >
> > Here's how I do it on my own projects:
> >
> >     public final static String DISABLED_OPTION_VALUE =
> > "com.xyz.utilities.web.jsf.converter.DISABLED_OPTION_VALUE";
> >     public final static String NULL_OPTION_VALUE =
> > "com.xyz.utilities.web.jsf.converter.NULL_OPTION_VALUE";
> >
> >     public String getNullSelectItemOptionValue() {
> >         return
> > com.xyz.utilities.web.jsf.converter.ConverterOptions.NULL_OPTION_VALUE;
> >     }
> >
> > <f:selectItem
> >       itemValue="#{myPage.nullSelectItemOptionValue}"
> >       itemLabel="&lt;No selection&gt;" />
> >
> >     public Object getAsObject(FacesContext context, UIComponent
> > component, String value) throws ConverterException
> >     {
> >       if (null == value)  return null;
> >         if (ConverterOptions.DISABLED_OPTION_VALUE.equals(value))  return
> > null;
> >         if (ConverterOptions.NULL_OPTION_VALUE.equals(value))  return
> > null;
> >
> > On 3/30/07, fastbob <fa...@gmail.com> wrote:
> >>
> >>
> >> Mike Kienenberger wrote:
> >> >
> >> > Yes, that's how I would do it.  If you specify an itemValue, then that
> >> > value must be of the correct type.  Ie, " " is not a containerType
> >> > (Srinivas) and "0" is not a region (Carl).
> >> >
> >> Ouch. The assumption is that there is a one-one correspondence between
> >> the
> >> list items and the type in the model. This isn't always the case.
> >>
> >> We had a number of JSP's under 1.1.3 with the following sequence, for
> >> several different types of lists:
> >>
> >>          <h:selectOneMenu id="client" value="#{myPage.projectType}">
> >>              <f:converter converterId="x.y.ProjectTypeConverter"/>
> >>              <f:selectItem itemValue="" itemLabel="--- Select Project
> >> Type---"/>
> >>              <f:selectItems value="#{myPage.projectTypeList}"/>
> >>          </h:selectOneMenu>
> >>
> >> The values in the type are fixed (essentially an enumeration, but not
> >> implemented that way), and there is no "empty" value available. Instead,
> >> if
> >> the converters are passed a null or empty string for conversion to the
> >> underlying type, they immediately return null. So in this case null is
> >> used
> >> to indicate no value has been selected by the user, and they get an
> >> error.
> >>
> >> With 1.1.5, we get the following exception:
> >>
> >> java.lang.ClassCastException: java.lang.String cannot be cast to
> >> javax.ejb.EJBLocalObject
> >>             at
> >> org.jboss.ejb.plugins.local.LocalProxy.isIdentical(LocalProxy.java:124)
> >>             at
> >> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:174)
> >>             at
> >> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
> >>             at
> >> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:155)
> >>             at
> >> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
> >>            at $Proxy262.equals(Unknown Source)
> >>             at
> >> javax.faces.component._SelectItemsUtil.matchValue(_SelectItemsUtil.java:65)
> >>             at
> >> javax.faces.component.UISelectOne.validateValue(UISelectOne.java:56)
> >>             at javax.faces.component.UIInput.validate(UIInput.java:354)
> >>             at
> >> javax.faces.component.UIInput.processValidators(UIInput.java:184)
> >>             […]
> >>
> >> Here are the relevant lines from _SelectItemsUtil.MatchValue():
> >>
> >>                 [item is class SelectItem]
> >>                 Object itemValue = item.getValue();
> >>                 if (value==itemValue || value.equals(itemValue))
> >>
> >> The exception is thrown by the call to equals in an EJB.
> >>
> >> I haven't come up with a low-cost way to fix this.
> >>
> >> Bob
> >> --
> >> View this message in context:
> >> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762021
> >> Sent from the MyFaces - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762503
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: ERROR: Value is not a valid option

Posted by fastbob <fa...@gmail.com>.
Hmmm. I must be missing something. Other than parameterization, including
your use of disable and null values, I don't see any significant differences
(I also tried moving the converter into the h:selectOneMenu - no effect). In
fact, the Tomahawk example uses "" as a nothing -selected value, just as we
do. And the converter code is essentially identical - we start with:

      if( string == null || string.trim().length() == 0 )
         return null;

So why are we getting an exception during the validation phase?

Bob


Mike Kienenberger wrote:
> 
> Here's how the tomahawk examples do it:
> 
>                 <h:selectOneMenu id="selone_menu_colors"
> value="#{carconf.color}" styleClass="selectOneMenu"
> converter="#{carconf.colorConverter}">
>                     <f:selectItem itemValue=""
> itemLabel="#{example_messages['empty_selitem']}" />
> 
> 
> 
>         public Object getAsObject(FacesContext facesContext,
> UIComponent component, String string) throws ConverterException
>         {
>             if(string==null)
>                 return null;
> 
> 
> Here's how I do it on my own projects:
> 
>     public final static String DISABLED_OPTION_VALUE =
> "com.xyz.utilities.web.jsf.converter.DISABLED_OPTION_VALUE";
>     public final static String NULL_OPTION_VALUE =
> "com.xyz.utilities.web.jsf.converter.NULL_OPTION_VALUE";
> 
>     public String getNullSelectItemOptionValue() {
>         return
> com.xyz.utilities.web.jsf.converter.ConverterOptions.NULL_OPTION_VALUE;
>     }
> 
> <f:selectItem
> 	itemValue="#{myPage.nullSelectItemOptionValue}"
> 	itemLabel="&lt;No selection&gt;" />
> 
>     public Object getAsObject(FacesContext context, UIComponent
> component, String value) throws ConverterException
>     {
>     	if (null == value)  return null;
>         if (ConverterOptions.DISABLED_OPTION_VALUE.equals(value))  return
> null;
>         if (ConverterOptions.NULL_OPTION_VALUE.equals(value))  return
> null;
> 
> On 3/30/07, fastbob <fa...@gmail.com> wrote:
>>
>>
>> Mike Kienenberger wrote:
>> >
>> > Yes, that's how I would do it.  If you specify an itemValue, then that
>> > value must be of the correct type.  Ie, " " is not a containerType
>> > (Srinivas) and "0" is not a region (Carl).
>> >
>> Ouch. The assumption is that there is a one-one correspondence between
>> the
>> list items and the type in the model. This isn't always the case.
>>
>> We had a number of JSP's under 1.1.3 with the following sequence, for
>> several different types of lists:
>>
>>          <h:selectOneMenu id="client" value="#{myPage.projectType}">
>>              <f:converter converterId="x.y.ProjectTypeConverter"/>
>>              <f:selectItem itemValue="" itemLabel="--- Select Project
>> Type---"/>
>>              <f:selectItems value="#{myPage.projectTypeList}"/>
>>          </h:selectOneMenu>
>>
>> The values in the type are fixed (essentially an enumeration, but not
>> implemented that way), and there is no "empty" value available. Instead,
>> if
>> the converters are passed a null or empty string for conversion to the
>> underlying type, they immediately return null. So in this case null is
>> used
>> to indicate no value has been selected by the user, and they get an
>> error.
>>
>> With 1.1.5, we get the following exception:
>>
>> java.lang.ClassCastException: java.lang.String cannot be cast to
>> javax.ejb.EJBLocalObject
>>             at
>> org.jboss.ejb.plugins.local.LocalProxy.isIdentical(LocalProxy.java:124)
>>             at
>> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:174)
>>             at
>> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
>>             at
>> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:155)
>>             at
>> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
>>            at $Proxy262.equals(Unknown Source)
>>             at
>> javax.faces.component._SelectItemsUtil.matchValue(_SelectItemsUtil.java:65)
>>             at
>> javax.faces.component.UISelectOne.validateValue(UISelectOne.java:56)
>>             at javax.faces.component.UIInput.validate(UIInput.java:354)
>>             at
>> javax.faces.component.UIInput.processValidators(UIInput.java:184)
>>             […]
>>
>> Here are the relevant lines from _SelectItemsUtil.MatchValue():
>>
>>                 [item is class SelectItem]
>>                 Object itemValue = item.getValue();
>>                 if (value==itemValue || value.equals(itemValue))
>>
>> The exception is thrown by the call to equals in an EJB.
>>
>> I haven't come up with a low-cost way to fix this.
>>
>> Bob
>> --
>> View this message in context:
>> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762021
>> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762503
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: ERROR: Value is not a valid option

Posted by Mike Kienenberger <mk...@gmail.com>.
Here's how the tomahawk examples do it:

                <h:selectOneMenu id="selone_menu_colors"
value="#{carconf.color}" styleClass="selectOneMenu"
converter="#{carconf.colorConverter}">
                    <f:selectItem itemValue=""
itemLabel="#{example_messages['empty_selitem']}" />



        public Object getAsObject(FacesContext facesContext,
UIComponent component, String string) throws ConverterException
        {
            if(string==null)
                return null;


Here's how I do it on my own projects:

    public final static String DISABLED_OPTION_VALUE =
"com.xyz.utilities.web.jsf.converter.DISABLED_OPTION_VALUE";
    public final static String NULL_OPTION_VALUE =
"com.xyz.utilities.web.jsf.converter.NULL_OPTION_VALUE";

    public String getNullSelectItemOptionValue() {
        return com.xyz.utilities.web.jsf.converter.ConverterOptions.NULL_OPTION_VALUE;
    }

<f:selectItem
	itemValue="#{myPage.nullSelectItemOptionValue}"
	itemLabel="&lt;No selection&gt;" />

    public Object getAsObject(FacesContext context, UIComponent
component, String value) throws ConverterException
    {
    	if (null == value)  return null;
        if (ConverterOptions.DISABLED_OPTION_VALUE.equals(value))  return null;
        if (ConverterOptions.NULL_OPTION_VALUE.equals(value))  return null;

On 3/30/07, fastbob <fa...@gmail.com> wrote:
>
>
> Mike Kienenberger wrote:
> >
> > Yes, that's how I would do it.  If you specify an itemValue, then that
> > value must be of the correct type.  Ie, " " is not a containerType
> > (Srinivas) and "0" is not a region (Carl).
> >
> Ouch. The assumption is that there is a one-one correspondence between the
> list items and the type in the model. This isn't always the case.
>
> We had a number of JSP's under 1.1.3 with the following sequence, for
> several different types of lists:
>
>          <h:selectOneMenu id="client" value="#{myPage.projectType}">
>              <f:converter converterId="x.y.ProjectTypeConverter"/>
>              <f:selectItem itemValue="" itemLabel="--- Select Project
> Type---"/>
>              <f:selectItems value="#{myPage.projectTypeList}"/>
>          </h:selectOneMenu>
>
> The values in the type are fixed (essentially an enumeration, but not
> implemented that way), and there is no "empty" value available. Instead, if
> the converters are passed a null or empty string for conversion to the
> underlying type, they immediately return null. So in this case null is used
> to indicate no value has been selected by the user, and they get an error.
>
> With 1.1.5, we get the following exception:
>
> java.lang.ClassCastException: java.lang.String cannot be cast to
> javax.ejb.EJBLocalObject
>             at
> org.jboss.ejb.plugins.local.LocalProxy.isIdentical(LocalProxy.java:124)
>             at
> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:174)
>             at
> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
>             at
> org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:155)
>             at
> org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
>            at $Proxy262.equals(Unknown Source)
>             at
> javax.faces.component._SelectItemsUtil.matchValue(_SelectItemsUtil.java:65)
>             at
> javax.faces.component.UISelectOne.validateValue(UISelectOne.java:56)
>             at javax.faces.component.UIInput.validate(UIInput.java:354)
>             at
> javax.faces.component.UIInput.processValidators(UIInput.java:184)
>             […]
>
> Here are the relevant lines from _SelectItemsUtil.MatchValue():
>
>                 [item is class SelectItem]
>                 Object itemValue = item.getValue();
>                 if (value==itemValue || value.equals(itemValue))
>
> The exception is thrown by the call to equals in an EJB.
>
> I haven't come up with a low-cost way to fix this.
>
> Bob
> --
> View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762021
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: ERROR: Value is not a valid option

Posted by fastbob <fa...@gmail.com>.

Mike Kienenberger wrote:
> 
> Yes, that's how I would do it.  If you specify an itemValue, then that
> value must be of the correct type.  Ie, " " is not a containerType
> (Srinivas) and "0" is not a region (Carl).
> 
Ouch. The assumption is that there is a one-one correspondence between the
list items and the type in the model. This isn't always the case.

We had a number of JSP's under 1.1.3 with the following sequence, for
several different types of lists:

         <h:selectOneMenu id="client" value="#{myPage.projectType}">
             <f:converter converterId="x.y.ProjectTypeConverter"/>
             <f:selectItem itemValue="" itemLabel="--- Select Project
Type---"/>
             <f:selectItems value="#{myPage.projectTypeList}"/>
         </h:selectOneMenu>

The values in the type are fixed (essentially an enumeration, but not
implemented that way), and there is no "empty" value available. Instead, if
the converters are passed a null or empty string for conversion to the
underlying type, they immediately return null. So in this case null is used
to indicate no value has been selected by the user, and they get an error.

With 1.1.5, we get the following exception:

java.lang.ClassCastException: java.lang.String cannot be cast to
javax.ejb.EJBLocalObject
            at
org.jboss.ejb.plugins.local.LocalProxy.isIdentical(LocalProxy.java:124)
            at
org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:174)
            at
org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
            at
org.jboss.ejb.plugins.local.LocalProxy.invoke(LocalProxy.java:155)
            at
org.jboss.ejb.plugins.local.EntityProxy.invoke(EntityProxy.java:40)
           at $Proxy262.equals(Unknown Source)
            at
javax.faces.component._SelectItemsUtil.matchValue(_SelectItemsUtil.java:65)
            at
javax.faces.component.UISelectOne.validateValue(UISelectOne.java:56)
            at javax.faces.component.UIInput.validate(UIInput.java:354)
            at
javax.faces.component.UIInput.processValidators(UIInput.java:184)
            […]

Here are the relevant lines from _SelectItemsUtil.MatchValue():

                [item is class SelectItem]
                Object itemValue = item.getValue();
                if (value==itemValue || value.equals(itemValue))

The exception is thrown by the call to equals in an EJB.

I haven't come up with a low-cost way to fix this.

Bob
-- 
View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9762021
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: [Solved] ERROR: Value is not a valid option

Posted by Mike Kienenberger <mk...@gmail.com>.
On 2/26/07, Mike Kienenberger <mk...@gmail.com> wrote:
> Yes, that's how I would do it.  If you specify an itemValue, then that
> value must be of the correct type.  Ie, " " is not a containerType
> (Srinivas) and "0" is not a region (Carl).

Another way to handle this is to provide your itemValues from a
backing bean for these things:

ie,

itemValue="#{constants.noSelectionContainerType}" itemLabel="no selection"

Re: [Solved] ERROR: Value is not a valid option

Posted by Mike Kienenberger <mk...@gmail.com>.
Yes, that's how I would do it.  If you specify an itemValue, then that
value must be of the correct type.  Ie, " " is not a containerType
(Srinivas) and "0" is not a region (Carl).

On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
> I am using facelets.  Where would that function go?  Each f:selectItem
> entry?
>
> <f:selectItem itemLabel="Website URL"
> itemValue="#{myfn:convertStringToShort(3)}"/>
>
>
>
>
>  On 2/26/07, Mike Kienenberger <mk...@gmail.com> wrote:
> > Take a look at
> http://issues.apache.org/jira/browse/MYFACES-1328.   It
> > looks like the RI does not have this convenience conversion.   I don't
> > know what the spec says, but that'd be the place to get a definitive
> > answer.
> >
> > If you're using facelets, as a temporary workaround you could create a
> > "convertStringToShort()" function (or whatever conversion you're
> > expecting to have happen automatically).
> >
> >
> > On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
> > > I did try that and didn't have any luck.  I think that was due to the
> fact
> > > that I was using shorts rather than ints, but I'd have to try it again
> now
> > > that I have a better understanding of everything involved.
> > >
> > >  I looked at TOMAHAWK-152 briefly.  I'll have to sit down and take a
> better
> > > look at it.  It looks to be in the realm.  The string value of 'true'
> not
> > > matching with a boolean type value?
> > >
> > > I guess the bottom line is I'd like to find out if I should be using an
> > > explicit converter to go from String to Short, or if the JSF api being
> used
> > > should be able to handle a simple[r] conversion like that.  It was doing
> > > that conversion originally.  Does the JSF spec cover this?  Anybody
> happen
> > > to know what the reference implementation does?  I'd love to try it out,
> but
> > > we're trying to push this out the door, so for the near future I have to
> > > focus on what's right in front of me.
> > >
> > >
> > > On 2/26/07, Martin Grotzke < martin.grotzke@javakaffee.de> wrote:
> > > > Does it work when you use itemValue="#{3}" as workaround?
> > > >
> > > > I also had the same problem with itemValue="true", what I think is
> > > > http://issues.apache.org/jira/browse/TOMAHAWK-152 ...
> > > >
> > > > Cheers,
> > > > Martin
> > > >
> > > >
> > > > On Mon, 2007-02-26 at 11:23 -0500, Kevin Galligan wrote:
> > > > > I'm having the same problem.  I had some code that was working for a
> > > > > long time with 1.1.5-SNAPSHOT, and now I'm getting that error.
> > > > >
> > > > > <h:selectOneMenu
> > > value="#{shared$FavoriteDocumentAdd.documentTypeId}"
> > > > > onchange="toggleInputRow()" id="documentTypeSelect"
> > > > > style="background-color:rgb(204,204,255)">
> > > > >     <f:selectItem itemLabel="Website URL" itemValue="3"/>
> > > > >     <f:selectItem itemLabel="File Upload" itemValue="1"/>
> > > > >     <f:selectItem itemLabel="Description Only" itemValue="2"/>
> > > > > </h:selectOneMenu>
> > > > >
> > > > > The value being set is a short.  Essentially it looks like the code
> > > > > was doing an automatic conversion before, but now chokes.
> > > > >
> > > > > I just reverted the code to 1.1.5-SNAPSHOT, and it works again.  I'm
> > > > > going to try to take a quick look at the differences between
> > > > > UISelectOne.java between those two versions, but in practice I've
> > > > > found with any large code base, it'll take a little time to really
> > > > > understand the layout.
> > > > >
> > > > > On 2/26/07, CarlHowarth < carl.howarth@dlapiper.com> wrote:
> > > > >
> > > > >         Hi,
> > > > >
> > > > >         I am having this problem too. My select one is set up as
> > > > >         follows:
> > > > >
> > > > >         <h:selectOneMenu id="regionList"
> > > > >         binding="#{Bean.regionListUI}"
> > > > >         value="#{ Bean.region}" >
> > > > >           <f:converter converterId=" myapp.Region"/>
> > > > >           <f:selectItem itemValue="0" itemLabel="(all)"/>
> > > > >           <t:selectItems var="r" itemLabel="#{ r.name }"
> > > > >         itemValue="#{ r.idString}"
> > > > >         value="#{applicationBean.regionMap}" />
> > > > >           <f:attribute name="fieldRef" value="Region List"/>
> > > > >         </h:selectOneMenu>
> > > > >
> > > > >         - This was working fine with 1.1.4 but since the upgrade to
> > > > >         1.1.5 it now
> > > > >         falls over.
> > > > >         - The application bean is at application scope, so the
> values
> > > > >         should always
> > > > >         be available.
> > > > >         - The converter changes an ID to a region and vice versa.
> > > > >         - The page loads up fine, I only have the problem when I
> > > > >         select a command
> > > > >         button that runs an action listener.
> > > > >         - I use a '<t:saveState value="#{Bean_track}"/>' for my
> > > > >         request-scoped bean.
> > > > >         - The region bean implements a working 'equals' method.
> > > > >         - If I select the manually populated select item, (all), it
> > > > >         works correctly.
> > > > >
> > > > >         My converter is like this:
> > > > >
> > > > >         public final static String CONVERTER_ID = " myapp.Region";
> > > > >             public Object getAsObject(FacesContext facesContext,
> > > > >         UIComponent
> > > > >         uiComponent, String string)
> > > > >                     throws ConverterException {
> > > > >
> > > > >                return
> > > > >
> > >
> JSFUtils.getAppBackingBean().getRegionMap().get(Integer.parseInt(string));
> > > > >             }
> > > > >
> > > > >             public String getAsString(FacesContext facesContext,
> > > > >         UIComponent
> > > > >         uiComponent, Object object)
> > > > >                     throws ConverterException {
> > > > >                 if (object == null) {
> > > > >                     return null;
> > > > >                 } else if (object instanceof Region) {
> > > > >                     final Region region = (Region) object;
> > > > >                     return region.getId().toString();
> > > > >                 }
> > > > >
> > > > >                 return object.toString();
> > > > >             }
> > > > >
> > > > >
> > > > >         I am at a complete loss at the moment, so any thoughts on
> what
> > > > >         could be
> > > > >         causing this error would be appreciated.
> > > > >
> > > > >         Thanks, Carl
> > > > >
> > > > >
> > > > >
> > > > >         Ernst Fastl wrote:
> > > > >         >
> > > > >         > Hi,
> > > > >         >
> > > > >         > I have had a similar problem recently. Generally happens
> if
> > > > >         the
> > > > >         > application is not able to find the selected value in the
> > > > >         List of
> > > > >         > selectItems.
> > > > >         > This can be due to 2 possible situations:
> > > > >         >
> > > > >         > 1. The list is not available during validation
> > > > >         > -> try using a <t:saveState
> > > > >         value="#{reportsBean.containerTypeList }" />
> > > > >         > to ensure it is
> > > > >         >
> > > > >         > 2. The values of the selectItems (getValue() and
> setValue())
> > > > >         do not
> > > > >         > contain
> > > > >         > Strings and there is no converter:
> > > > >         >
> > > > >         > -> use a corresponding converter e.g. for Long -
> > > > >         LongConverter
> > > > >         > for the selectOneMenu
> > > > >         >
> > > > >         > hope that helps
> > > > >         >
> > > > >         > regards
> > > > >         >
> > > > >         > Ernst
> > > > >         >
> > > > >         > On 2/22/07, Srinivas V <vuyyuru.srinivas@gmail.com >
> wrote:
> > > > >         >> Hi All,
> > > > >         >> Please help me!!
> > > > >         >> I am having an issue with SelectOneMenu.
> > > > >         >>
> > > > >         >> I have installed JSF 1.1.5-SNAPSHOT ,Tomahawk1.1.5-
> SNAPSHOT
> > > > >         and
> > > > >         >> tomahawk-sandbox-1.1.5-SNAPSHOT.
> > > > >         >>
> > > > >         >> Previously i had myfaces1.1 jar
> > > > >         >> I dint have issue with selectOneMenu before.
> > > > >         >>
> > > > >         >> Now when I submit the page, I am getting this jsf
> > > > >         validation error:
> > > > >         >> Container:"Value is not a valid option"
> > > > >         >> for a selectOneMenu even if i select some option.
> > > > >         >>
> > > > >         >> code:
> > > > >         >> <h:panelGroup
> > > > >         rendered="#{reportsBean.renderContainerType}">
> > > > >         >>    <x:outputLabel for="containerfilter"
> > > > >         >> value="#{msgBundle.EPCMgr_ContainerLbl }:"
> > > > >         >> styleClass="standard_text_bold"/>
> > > > >         >>    <f:verbatim><br/></f:verbatim>
> > > > >         >>    <h:selectOneMenu id="containerfilter"
> > > > >         >> value="#{ reportsBean.containerType}" immediate="true"
> > > > >         disabled="#{
> > > > >         >> reportsBean.optionDisabled }"
> styleClass="standard_input">
> > > > >         >>     <f:selectItem itemValue="" itemLabel=" " />
> > > > >         >>     <f:selectItems
> > > > >         value="#{reportsBean.containerTypeList }"/>
> > > > >         >>    </h:selectOneMenu>
> > > > >         >>   </h:panelGroup>
> > > > >         >>
> > > > >         >> Can anybody tell me why it is happening?
> > > > >         >>
> > > > >         >> regards
> > > > >         >> srinivas
> > > > >         >>
> > > > >         >
> > > > >         >
> > > > >
> > > > >         --
> > > > >         View this message in context: http://www.nabble.com/ERROR%
> > > > >
> > > 3A-Value-is-not-a-valid-option-tf3270984.html#a9155607
> > > > >         Sent from the MyFaces - Users mailing list archive at
> > > > >         Nabble.com.
> > > > >
> > > > >
> > > > --
> > > > Martin Grotzke
> > > > http://www.javakaffee.de/blog/
> > > >
> > > >
> > >
> > >
> >
>
>

Re: [Solved] ERROR: Value is not a valid option

Posted by Kevin Galligan <kg...@gmail.com>.
I am using facelets.  Where would that function go?  Each f:selectItem
entry?

<f:selectItem itemLabel="Website URL"
itemValue="#{myfn:convertStringToShort(3)}"/>



On 2/26/07, Mike Kienenberger <mk...@gmail.com> wrote:
>
> Take a look at http://issues.apache.org/jira/browse/MYFACES-1328.   It
> looks like the RI does not have this convenience conversion.   I don't
> know what the spec says, but that'd be the place to get a definitive
> answer.
>
> If you're using facelets, as a temporary workaround you could create a
> "convertStringToShort()" function (or whatever conversion you're
> expecting to have happen automatically).
>
>
> On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
> > I did try that and didn't have any luck.  I think that was due to the
> fact
> > that I was using shorts rather than ints, but I'd have to try it again
> now
> > that I have a better understanding of everything involved.
> >
> >  I looked at TOMAHAWK-152 briefly.  I'll have to sit down and take a
> better
> > look at it.  It looks to be in the realm.  The string value of 'true'
> not
> > matching with a boolean type value?
> >
> > I guess the bottom line is I'd like to find out if I should be using an
> > explicit converter to go from String to Short, or if the JSF api being
> used
> > should be able to handle a simple[r] conversion like that.  It was doing
> > that conversion originally.  Does the JSF spec cover this?  Anybody
> happen
> > to know what the reference implementation does?  I'd love to try it out,
> but
> > we're trying to push this out the door, so for the near future I have to
> > focus on what's right in front of me.
> >
> >
> > On 2/26/07, Martin Grotzke <ma...@javakaffee.de> wrote:
> > > Does it work when you use itemValue="#{3}" as workaround?
> > >
> > > I also had the same problem with itemValue="true", what I think is
> > > http://issues.apache.org/jira/browse/TOMAHAWK-152 ...
> > >
> > > Cheers,
> > > Martin
> > >
> > >
> > > On Mon, 2007-02-26 at 11:23 -0500, Kevin Galligan wrote:
> > > > I'm having the same problem.  I had some code that was working for a
> > > > long time with 1.1.5-SNAPSHOT, and now I'm getting that error.
> > > >
> > > > <h:selectOneMenu
> > value="#{shared$FavoriteDocumentAdd.documentTypeId}"
> > > > onchange="toggleInputRow()" id="documentTypeSelect"
> > > > style="background-color:rgb(204,204,255)">
> > > >     <f:selectItem itemLabel="Website URL" itemValue="3"/>
> > > >     <f:selectItem itemLabel="File Upload" itemValue="1"/>
> > > >     <f:selectItem itemLabel="Description Only" itemValue="2"/>
> > > > </h:selectOneMenu>
> > > >
> > > > The value being set is a short.  Essentially it looks like the code
> > > > was doing an automatic conversion before, but now chokes.
> > > >
> > > > I just reverted the code to 1.1.5-SNAPSHOT, and it works again.  I'm
> > > > going to try to take a quick look at the differences between
> > > > UISelectOne.java between those two versions, but in practice I've
> > > > found with any large code base, it'll take a little time to really
> > > > understand the layout.
> > > >
> > > > On 2/26/07, CarlHowarth <ca...@dlapiper.com> wrote:
> > > >
> > > >         Hi,
> > > >
> > > >         I am having this problem too. My select one is set up as
> > > >         follows:
> > > >
> > > >         <h:selectOneMenu id="regionList"
> > > >         binding="#{Bean.regionListUI}"
> > > >         value="#{Bean.region}" >
> > > >           <f:converter converterId=" myapp.Region"/>
> > > >           <f:selectItem itemValue="0" itemLabel="(all)"/>
> > > >           <t:selectItems var="r" itemLabel="#{r.name }"
> > > >         itemValue="#{ r.idString}"
> > > >         value="#{applicationBean.regionMap}" />
> > > >           <f:attribute name="fieldRef" value="Region List"/>
> > > >         </h:selectOneMenu>
> > > >
> > > >         - This was working fine with 1.1.4 but since the upgrade to
> > > >         1.1.5 it now
> > > >         falls over.
> > > >         - The application bean is at application scope, so the
> values
> > > >         should always
> > > >         be available.
> > > >         - The converter changes an ID to a region and vice versa.
> > > >         - The page loads up fine, I only have the problem when I
> > > >         select a command
> > > >         button that runs an action listener.
> > > >         - I use a '<t:saveState value="#{Bean_track}"/>' for my
> > > >         request-scoped bean.
> > > >         - The region bean implements a working 'equals' method.
> > > >         - If I select the manually populated select item, (all), it
> > > >         works correctly.
> > > >
> > > >         My converter is like this:
> > > >
> > > >         public final static String CONVERTER_ID = " myapp.Region";
> > > >             public Object getAsObject(FacesContext facesContext,
> > > >         UIComponent
> > > >         uiComponent, String string)
> > > >                     throws ConverterException {
> > > >
> > > >                return
> > > >
> > JSFUtils.getAppBackingBean().getRegionMap().get(Integer.parseInt
> (string));
> > > >             }
> > > >
> > > >             public String getAsString(FacesContext facesContext,
> > > >         UIComponent
> > > >         uiComponent, Object object)
> > > >                     throws ConverterException {
> > > >                 if (object == null) {
> > > >                     return null;
> > > >                 } else if (object instanceof Region) {
> > > >                     final Region region = (Region) object;
> > > >                     return region.getId().toString();
> > > >                 }
> > > >
> > > >                 return object.toString();
> > > >             }
> > > >
> > > >
> > > >         I am at a complete loss at the moment, so any thoughts on
> what
> > > >         could be
> > > >         causing this error would be appreciated.
> > > >
> > > >         Thanks, Carl
> > > >
> > > >
> > > >
> > > >         Ernst Fastl wrote:
> > > >         >
> > > >         > Hi,
> > > >         >
> > > >         > I have had a similar problem recently. Generally happens
> if
> > > >         the
> > > >         > application is not able to find the selected value in the
> > > >         List of
> > > >         > selectItems.
> > > >         > This can be due to 2 possible situations:
> > > >         >
> > > >         > 1. The list is not available during validation
> > > >         > -> try using a <t:saveState
> > > >         value="#{reportsBean.containerTypeList }" />
> > > >         > to ensure it is
> > > >         >
> > > >         > 2. The values of the selectItems (getValue() and
> setValue())
> > > >         do not
> > > >         > contain
> > > >         > Strings and there is no converter:
> > > >         >
> > > >         > -> use a corresponding converter e.g. for Long -
> > > >         LongConverter
> > > >         > for the selectOneMenu
> > > >         >
> > > >         > hope that helps
> > > >         >
> > > >         > regards
> > > >         >
> > > >         > Ernst
> > > >         >
> > > >         > On 2/22/07, Srinivas V <vuyyuru.srinivas@gmail.com >
> wrote:
> > > >         >> Hi All,
> > > >         >> Please help me!!
> > > >         >> I am having an issue with SelectOneMenu.
> > > >         >>
> > > >         >> I have installed JSF 1.1.5-SNAPSHOT,Tomahawk1.1.5-
> SNAPSHOT
> > > >         and
> > > >         >> tomahawk-sandbox-1.1.5-SNAPSHOT.
> > > >         >>
> > > >         >> Previously i had myfaces1.1 jar
> > > >         >> I dint have issue with selectOneMenu before.
> > > >         >>
> > > >         >> Now when I submit the page, I am getting this jsf
> > > >         validation error:
> > > >         >> Container:"Value is not a valid option"
> > > >         >> for a selectOneMenu even if i select some option.
> > > >         >>
> > > >         >> code:
> > > >         >> <h:panelGroup
> > > >         rendered="#{reportsBean.renderContainerType}">
> > > >         >>    <x:outputLabel for="containerfilter"
> > > >         >> value="#{msgBundle.EPCMgr_ContainerLbl }:"
> > > >         >> styleClass="standard_text_bold"/>
> > > >         >>    <f:verbatim><br/></f:verbatim>
> > > >         >>    <h:selectOneMenu id="containerfilter"
> > > >         >> value="#{ reportsBean.containerType}" immediate="true"
> > > >         disabled="#{
> > > >         >> reportsBean.optionDisabled }"
> styleClass="standard_input">
> > > >         >>     <f:selectItem itemValue="" itemLabel=" " />
> > > >         >>     <f:selectItems
> > > >         value="#{reportsBean.containerTypeList }"/>
> > > >         >>    </h:selectOneMenu>
> > > >         >>   </h:panelGroup>
> > > >         >>
> > > >         >> Can anybody tell me why it is happening?
> > > >         >>
> > > >         >> regards
> > > >         >> srinivas
> > > >         >>
> > > >         >
> > > >         >
> > > >
> > > >         --
> > > >         View this message in context: http://www.nabble.com/ERROR%
> > > >
> > 3A-Value-is-not-a-valid-option-tf3270984.html#a9155607
> > > >         Sent from the MyFaces - Users mailing list archive at
> > > >         Nabble.com.
> > > >
> > > >
> > > --
> > > Martin Grotzke
> > > http://www.javakaffee.de/blog/
> > >
> > >
> >
> >
>

Re: [Solved] ERROR: Value is not a valid option

Posted by Mike Kienenberger <mk...@gmail.com>.
Take a look at http://issues.apache.org/jira/browse/MYFACES-1328.   It
looks like the RI does not have this convenience conversion.   I don't
know what the spec says, but that'd be the place to get a definitive
answer.

If you're using facelets, as a temporary workaround you could create a
"convertStringToShort()" function (or whatever conversion you're
expecting to have happen automatically).


On 2/26/07, Kevin Galligan <kg...@gmail.com> wrote:
> I did try that and didn't have any luck.  I think that was due to the fact
> that I was using shorts rather than ints, but I'd have to try it again now
> that I have a better understanding of everything involved.
>
>  I looked at TOMAHAWK-152 briefly.  I'll have to sit down and take a better
> look at it.  It looks to be in the realm.  The string value of 'true' not
> matching with a boolean type value?
>
> I guess the bottom line is I'd like to find out if I should be using an
> explicit converter to go from String to Short, or if the JSF api being used
> should be able to handle a simple[r] conversion like that.  It was doing
> that conversion originally.  Does the JSF spec cover this?  Anybody happen
> to know what the reference implementation does?  I'd love to try it out, but
> we're trying to push this out the door, so for the near future I have to
> focus on what's right in front of me.
>
>
> On 2/26/07, Martin Grotzke <ma...@javakaffee.de> wrote:
> > Does it work when you use itemValue="#{3}" as workaround?
> >
> > I also had the same problem with itemValue="true", what I think is
> > http://issues.apache.org/jira/browse/TOMAHAWK-152 ...
> >
> > Cheers,
> > Martin
> >
> >
> > On Mon, 2007-02-26 at 11:23 -0500, Kevin Galligan wrote:
> > > I'm having the same problem.  I had some code that was working for a
> > > long time with 1.1.5-SNAPSHOT, and now I'm getting that error.
> > >
> > > <h:selectOneMenu
> value="#{shared$FavoriteDocumentAdd.documentTypeId}"
> > > onchange="toggleInputRow()" id="documentTypeSelect"
> > > style="background-color:rgb(204,204,255)">
> > >     <f:selectItem itemLabel="Website URL" itemValue="3"/>
> > >     <f:selectItem itemLabel="File Upload" itemValue="1"/>
> > >     <f:selectItem itemLabel="Description Only" itemValue="2"/>
> > > </h:selectOneMenu>
> > >
> > > The value being set is a short.  Essentially it looks like the code
> > > was doing an automatic conversion before, but now chokes.
> > >
> > > I just reverted the code to 1.1.5-SNAPSHOT, and it works again.  I'm
> > > going to try to take a quick look at the differences between
> > > UISelectOne.java between those two versions, but in practice I've
> > > found with any large code base, it'll take a little time to really
> > > understand the layout.
> > >
> > > On 2/26/07, CarlHowarth <ca...@dlapiper.com> wrote:
> > >
> > >         Hi,
> > >
> > >         I am having this problem too. My select one is set up as
> > >         follows:
> > >
> > >         <h:selectOneMenu id="regionList"
> > >         binding="#{Bean.regionListUI}"
> > >         value="#{Bean.region}" >
> > >           <f:converter converterId=" myapp.Region"/>
> > >           <f:selectItem itemValue="0" itemLabel="(all)"/>
> > >           <t:selectItems var="r" itemLabel="#{r.name }"
> > >         itemValue="#{ r.idString}"
> > >         value="#{applicationBean.regionMap}" />
> > >           <f:attribute name="fieldRef" value="Region List"/>
> > >         </h:selectOneMenu>
> > >
> > >         - This was working fine with 1.1.4 but since the upgrade to
> > >         1.1.5 it now
> > >         falls over.
> > >         - The application bean is at application scope, so the values
> > >         should always
> > >         be available.
> > >         - The converter changes an ID to a region and vice versa.
> > >         - The page loads up fine, I only have the problem when I
> > >         select a command
> > >         button that runs an action listener.
> > >         - I use a '<t:saveState value="#{Bean_track}"/>' for my
> > >         request-scoped bean.
> > >         - The region bean implements a working 'equals' method.
> > >         - If I select the manually populated select item, (all), it
> > >         works correctly.
> > >
> > >         My converter is like this:
> > >
> > >         public final static String CONVERTER_ID = " myapp.Region";
> > >             public Object getAsObject(FacesContext facesContext,
> > >         UIComponent
> > >         uiComponent, String string)
> > >                     throws ConverterException {
> > >
> > >                return
> > >
> JSFUtils.getAppBackingBean().getRegionMap().get(Integer.parseInt(string));
> > >             }
> > >
> > >             public String getAsString(FacesContext facesContext,
> > >         UIComponent
> > >         uiComponent, Object object)
> > >                     throws ConverterException {
> > >                 if (object == null) {
> > >                     return null;
> > >                 } else if (object instanceof Region) {
> > >                     final Region region = (Region) object;
> > >                     return region.getId().toString();
> > >                 }
> > >
> > >                 return object.toString();
> > >             }
> > >
> > >
> > >         I am at a complete loss at the moment, so any thoughts on what
> > >         could be
> > >         causing this error would be appreciated.
> > >
> > >         Thanks, Carl
> > >
> > >
> > >
> > >         Ernst Fastl wrote:
> > >         >
> > >         > Hi,
> > >         >
> > >         > I have had a similar problem recently. Generally happens if
> > >         the
> > >         > application is not able to find the selected value in the
> > >         List of
> > >         > selectItems.
> > >         > This can be due to 2 possible situations:
> > >         >
> > >         > 1. The list is not available during validation
> > >         > -> try using a <t:saveState
> > >         value="#{reportsBean.containerTypeList }" />
> > >         > to ensure it is
> > >         >
> > >         > 2. The values of the selectItems (getValue() and setValue())
> > >         do not
> > >         > contain
> > >         > Strings and there is no converter:
> > >         >
> > >         > -> use a corresponding converter e.g. for Long -
> > >         LongConverter
> > >         > for the selectOneMenu
> > >         >
> > >         > hope that helps
> > >         >
> > >         > regards
> > >         >
> > >         > Ernst
> > >         >
> > >         > On 2/22/07, Srinivas V <vuyyuru.srinivas@gmail.com > wrote:
> > >         >> Hi All,
> > >         >> Please help me!!
> > >         >> I am having an issue with SelectOneMenu.
> > >         >>
> > >         >> I have installed JSF 1.1.5-SNAPSHOT,Tomahawk1.1.5- SNAPSHOT
> > >         and
> > >         >> tomahawk-sandbox-1.1.5-SNAPSHOT.
> > >         >>
> > >         >> Previously i had myfaces1.1 jar
> > >         >> I dint have issue with selectOneMenu before.
> > >         >>
> > >         >> Now when I submit the page, I am getting this jsf
> > >         validation error:
> > >         >> Container:"Value is not a valid option"
> > >         >> for a selectOneMenu even if i select some option.
> > >         >>
> > >         >> code:
> > >         >> <h:panelGroup
> > >         rendered="#{reportsBean.renderContainerType}">
> > >         >>    <x:outputLabel for="containerfilter"
> > >         >> value="#{msgBundle.EPCMgr_ContainerLbl }:"
> > >         >> styleClass="standard_text_bold"/>
> > >         >>    <f:verbatim><br/></f:verbatim>
> > >         >>    <h:selectOneMenu id="containerfilter"
> > >         >> value="#{ reportsBean.containerType}" immediate="true"
> > >         disabled="#{
> > >         >> reportsBean.optionDisabled }" styleClass="standard_input">
> > >         >>     <f:selectItem itemValue="" itemLabel=" " />
> > >         >>     <f:selectItems
> > >         value="#{reportsBean.containerTypeList }"/>
> > >         >>    </h:selectOneMenu>
> > >         >>   </h:panelGroup>
> > >         >>
> > >         >> Can anybody tell me why it is happening?
> > >         >>
> > >         >> regards
> > >         >> srinivas
> > >         >>
> > >         >
> > >         >
> > >
> > >         --
> > >         View this message in context: http://www.nabble.com/ERROR%
> > >
> 3A-Value-is-not-a-valid-option-tf3270984.html#a9155607
> > >         Sent from the MyFaces - Users mailing list archive at
> > >         Nabble.com.
> > >
> > >
> > --
> > Martin Grotzke
> > http://www.javakaffee.de/blog/
> >
> >
>
>

Re: [Solved] ERROR: Value is not a valid option

Posted by Kevin Galligan <kg...@gmail.com>.
I did try that and didn't have any luck.  I think that was due to the fact
that I was using shorts rather than ints, but I'd have to try it again now
that I have a better understanding of everything involved.

I looked at TOMAHAWK-152 briefly.  I'll have to sit down and take a better
look at it.  It looks to be in the realm.  The string value of 'true' not
matching with a boolean type value?

I guess the bottom line is I'd like to find out if I should be using an
explicit converter to go from String to Short, or if the JSF api being used
should be able to handle a simple[r] conversion like that.  It was doing
that conversion originally.  Does the JSF spec cover this?  Anybody happen
to know what the reference implementation does?  I'd love to try it out, but
we're trying to push this out the door, so for the near future I have to
focus on what's right in front of me.

On 2/26/07, Martin Grotzke <ma...@javakaffee.de> wrote:
>
> Does it work when you use itemValue="#{3}" as workaround?
>
> I also had the same problem with itemValue="true", what I think is
> http://issues.apache.org/jira/browse/TOMAHAWK-152 ...
>
> Cheers,
> Martin
>
>
> On Mon, 2007-02-26 at 11:23 -0500, Kevin Galligan wrote:
> > I'm having the same problem.  I had some code that was working for a
> > long time with 1.1.5-SNAPSHOT, and now I'm getting that error.
> >
> > <h:selectOneMenu value="#{shared$FavoriteDocumentAdd.documentTypeId}"
> > onchange="toggleInputRow()" id="documentTypeSelect"
> > style="background-color:rgb(204,204,255)">
> >     <f:selectItem itemLabel="Website URL" itemValue="3"/>
> >     <f:selectItem itemLabel="File Upload" itemValue="1"/>
> >     <f:selectItem itemLabel="Description Only" itemValue="2"/>
> > </h:selectOneMenu>
> >
> > The value being set is a short.  Essentially it looks like the code
> > was doing an automatic conversion before, but now chokes.
> >
> > I just reverted the code to 1.1.5-SNAPSHOT, and it works again.  I'm
> > going to try to take a quick look at the differences between
> > UISelectOne.java between those two versions, but in practice I've
> > found with any large code base, it'll take a little time to really
> > understand the layout.
> >
> > On 2/26/07, CarlHowarth <ca...@dlapiper.com> wrote:
> >
> >         Hi,
> >
> >         I am having this problem too. My select one is set up as
> >         follows:
> >
> >         <h:selectOneMenu id="regionList"
> >         binding="#{Bean.regionListUI}"
> >         value="#{Bean.region}" >
> >           <f:converter converterId=" myapp.Region"/>
> >           <f:selectItem itemValue="0" itemLabel="(all)"/>
> >           <t:selectItems var="r" itemLabel="#{r.name}"
> >         itemValue="#{ r.idString}"
> >         value="#{applicationBean.regionMap}" />
> >           <f:attribute name="fieldRef" value="Region List"/>
> >         </h:selectOneMenu>
> >
> >         - This was working fine with 1.1.4 but since the upgrade to
> >         1.1.5 it now
> >         falls over.
> >         - The application bean is at application scope, so the values
> >         should always
> >         be available.
> >         - The converter changes an ID to a region and vice versa.
> >         - The page loads up fine, I only have the problem when I
> >         select a command
> >         button that runs an action listener.
> >         - I use a '<t:saveState value="#{Bean_track}"/>' for my
> >         request-scoped bean.
> >         - The region bean implements a working 'equals' method.
> >         - If I select the manually populated select item, (all), it
> >         works correctly.
> >
> >         My converter is like this:
> >
> >         public final static String CONVERTER_ID = "myapp.Region";
> >             public Object getAsObject(FacesContext facesContext,
> >         UIComponent
> >         uiComponent, String string)
> >                     throws ConverterException {
> >
> >                return
> >         JSFUtils.getAppBackingBean().getRegionMap().get(Integer.parseInt
> (string));
> >             }
> >
> >             public String getAsString(FacesContext facesContext,
> >         UIComponent
> >         uiComponent, Object object)
> >                     throws ConverterException {
> >                 if (object == null) {
> >                     return null;
> >                 } else if (object instanceof Region) {
> >                     final Region region = (Region) object;
> >                     return region.getId().toString();
> >                 }
> >
> >                 return object.toString();
> >             }
> >
> >
> >         I am at a complete loss at the moment, so any thoughts on what
> >         could be
> >         causing this error would be appreciated.
> >
> >         Thanks, Carl
> >
> >
> >
> >         Ernst Fastl wrote:
> >         >
> >         > Hi,
> >         >
> >         > I have had a similar problem recently. Generally happens if
> >         the
> >         > application is not able to find the selected value in the
> >         List of
> >         > selectItems.
> >         > This can be due to 2 possible situations:
> >         >
> >         > 1. The list is not available during validation
> >         > -> try using a <t:saveState
> >         value="#{reportsBean.containerTypeList }" />
> >         > to ensure it is
> >         >
> >         > 2. The values of the selectItems (getValue() and setValue())
> >         do not
> >         > contain
> >         > Strings and there is no converter:
> >         >
> >         > -> use a corresponding converter e.g. for Long -
> >         LongConverter
> >         > for the selectOneMenu
> >         >
> >         > hope that helps
> >         >
> >         > regards
> >         >
> >         > Ernst
> >         >
> >         > On 2/22/07, Srinivas V <vu...@gmail.com> wrote:
> >         >> Hi All,
> >         >> Please help me!!
> >         >> I am having an issue with SelectOneMenu.
> >         >>
> >         >> I have installed JSF 1.1.5-SNAPSHOT,Tomahawk1.1.5- SNAPSHOT
> >         and
> >         >> tomahawk-sandbox-1.1.5-SNAPSHOT.
> >         >>
> >         >> Previously i had myfaces1.1 jar
> >         >> I dint have issue with selectOneMenu before.
> >         >>
> >         >> Now when I submit the page, I am getting this jsf
> >         validation error:
> >         >> Container:"Value is not a valid option"
> >         >> for a selectOneMenu even if i select some option.
> >         >>
> >         >> code:
> >         >> <h:panelGroup
> >         rendered="#{reportsBean.renderContainerType}">
> >         >>    <x:outputLabel for="containerfilter"
> >         >> value="#{msgBundle.EPCMgr_ContainerLbl }:"
> >         >> styleClass="standard_text_bold"/>
> >         >>    <f:verbatim><br/></f:verbatim>
> >         >>    <h:selectOneMenu id="containerfilter"
> >         >> value="#{ reportsBean.containerType}" immediate="true"
> >         disabled="#{
> >         >> reportsBean.optionDisabled }" styleClass="standard_input">
> >         >>     <f:selectItem itemValue="" itemLabel=" " />
> >         >>     <f:selectItems
> >         value="#{reportsBean.containerTypeList }"/>
> >         >>    </h:selectOneMenu>
> >         >>   </h:panelGroup>
> >         >>
> >         >> Can anybody tell me why it is happening?
> >         >>
> >         >> regards
> >         >> srinivas
> >         >>
> >         >
> >         >
> >
> >         --
> >         View this message in context: http://www.nabble.com/ERROR%
> >         3A-Value-is-not-a-valid-option-tf3270984.html#a9155607
> >         Sent from the MyFaces - Users mailing list archive at
> >         Nabble.com.
> >
> >
> --
> Martin Grotzke
> http://www.javakaffee.de/blog/
>
>

Re: [Solved] ERROR: Value is not a valid option

Posted by Martin Grotzke <ma...@javakaffee.de>.
Does it work when you use itemValue="#{3}" as workaround?

I also had the same problem with itemValue="true", what I think is
http://issues.apache.org/jira/browse/TOMAHAWK-152 ...

Cheers,
Martin


On Mon, 2007-02-26 at 11:23 -0500, Kevin Galligan wrote:
> I'm having the same problem.  I had some code that was working for a
> long time with 1.1.5-SNAPSHOT, and now I'm getting that error. 
> 
> <h:selectOneMenu value="#{shared$FavoriteDocumentAdd.documentTypeId}"
> onchange="toggleInputRow()" id="documentTypeSelect"
> style="background-color:rgb(204,204,255)"> 
>     <f:selectItem itemLabel="Website URL" itemValue="3"/>
>     <f:selectItem itemLabel="File Upload" itemValue="1"/>
>     <f:selectItem itemLabel="Description Only" itemValue="2"/> 
> </h:selectOneMenu>
> 
> The value being set is a short.  Essentially it looks like the code
> was doing an automatic conversion before, but now chokes.
> 
> I just reverted the code to 1.1.5-SNAPSHOT, and it works again.  I'm
> going to try to take a quick look at the differences between
> UISelectOne.java between those two versions, but in practice I've
> found with any large code base, it'll take a little time to really
> understand the layout.
> 
> On 2/26/07, CarlHowarth <ca...@dlapiper.com> wrote:
>         
>         Hi,
>         
>         I am having this problem too. My select one is set up as
>         follows:
>         
>         <h:selectOneMenu id="regionList"
>         binding="#{Bean.regionListUI}"
>         value="#{Bean.region}" >
>           <f:converter converterId=" myapp.Region"/>
>           <f:selectItem itemValue="0" itemLabel="(all)"/>
>           <t:selectItems var="r" itemLabel="#{r.name}"
>         itemValue="#{ r.idString}"
>         value="#{applicationBean.regionMap}" />
>           <f:attribute name="fieldRef" value="Region List"/>
>         </h:selectOneMenu>
>         
>         - This was working fine with 1.1.4 but since the upgrade to
>         1.1.5 it now
>         falls over.
>         - The application bean is at application scope, so the values
>         should always
>         be available.
>         - The converter changes an ID to a region and vice versa.
>         - The page loads up fine, I only have the problem when I
>         select a command 
>         button that runs an action listener.
>         - I use a '<t:saveState value="#{Bean_track}"/>' for my
>         request-scoped bean.
>         - The region bean implements a working 'equals' method.
>         - If I select the manually populated select item, (all), it
>         works correctly. 
>         
>         My converter is like this:
>         
>         public final static String CONVERTER_ID = "myapp.Region";
>             public Object getAsObject(FacesContext facesContext,
>         UIComponent
>         uiComponent, String string)
>                     throws ConverterException { 
>         
>                return
>         JSFUtils.getAppBackingBean().getRegionMap().get(Integer.parseInt(string));
>             }
>         
>             public String getAsString(FacesContext facesContext,
>         UIComponent
>         uiComponent, Object object)
>                     throws ConverterException { 
>                 if (object == null) {
>                     return null;
>                 } else if (object instanceof Region) {
>                     final Region region = (Region) object;
>                     return region.getId().toString();
>                 } 
>         
>                 return object.toString();
>             }
>         
>         
>         I am at a complete loss at the moment, so any thoughts on what
>         could be
>         causing this error would be appreciated.
>         
>         Thanks, Carl
>         
>         
>         
>         Ernst Fastl wrote: 
>         >
>         > Hi,
>         >
>         > I have had a similar problem recently. Generally happens if
>         the
>         > application is not able to find the selected value in the
>         List of
>         > selectItems.
>         > This can be due to 2 possible situations: 
>         >
>         > 1. The list is not available during validation
>         > -> try using a <t:saveState
>         value="#{reportsBean.containerTypeList }" />
>         > to ensure it is
>         >
>         > 2. The values of the selectItems (getValue() and setValue())
>         do not 
>         > contain
>         > Strings and there is no converter:
>         >
>         > -> use a corresponding converter e.g. for Long -
>         LongConverter
>         > for the selectOneMenu
>         >
>         > hope that helps
>         >
>         > regards 
>         >
>         > Ernst
>         >
>         > On 2/22/07, Srinivas V <vu...@gmail.com> wrote:
>         >> Hi All,
>         >> Please help me!!
>         >> I am having an issue with SelectOneMenu. 
>         >>
>         >> I have installed JSF 1.1.5-SNAPSHOT,Tomahawk1.1.5- SNAPSHOT
>         and
>         >> tomahawk-sandbox-1.1.5-SNAPSHOT.
>         >>
>         >> Previously i had myfaces1.1 jar
>         >> I dint have issue with selectOneMenu before. 
>         >>
>         >> Now when I submit the page, I am getting this jsf
>         validation error:
>         >> Container:"Value is not a valid option"
>         >> for a selectOneMenu even if i select some option.
>         >> 
>         >> code:
>         >> <h:panelGroup
>         rendered="#{reportsBean.renderContainerType}">
>         >>    <x:outputLabel for="containerfilter"
>         >> value="#{msgBundle.EPCMgr_ContainerLbl }:"
>         >> styleClass="standard_text_bold"/>
>         >>    <f:verbatim><br/></f:verbatim>
>         >>    <h:selectOneMenu id="containerfilter"
>         >> value="#{ reportsBean.containerType}" immediate="true"
>         disabled="#{
>         >> reportsBean.optionDisabled }" styleClass="standard_input">
>         >>     <f:selectItem itemValue="" itemLabel=" " /> 
>         >>     <f:selectItems
>         value="#{reportsBean.containerTypeList }"/>
>         >>    </h:selectOneMenu>
>         >>   </h:panelGroup>
>         >>
>         >> Can anybody tell me why it is happening? 
>         >>
>         >> regards
>         >> srinivas
>         >>
>         >
>         >
>         
>         --
>         View this message in context: http://www.nabble.com/ERROR%
>         3A-Value-is-not-a-valid-option-tf3270984.html#a9155607
>         Sent from the MyFaces - Users mailing list archive at
>         Nabble.com.
>         
> 
-- 
Martin Grotzke
http://www.javakaffee.de/blog/

Re: [Solved] ERROR: Value is not a valid option

Posted by Kevin Galligan <kg...@gmail.com>.
I'm having the same problem.  I had some code that was working for a long
time with 1.1.5-SNAPSHOT, and now I'm getting that error.

<h:selectOneMenu value="#{shared$FavoriteDocumentAdd.documentTypeId}"
onchange="toggleInputRow()" id="documentTypeSelect"
style="background-color:rgb(204,204,255)">
    <f:selectItem itemLabel="Website URL" itemValue="3"/>
    <f:selectItem itemLabel="File Upload" itemValue="1"/>
    <f:selectItem itemLabel="Description Only" itemValue="2"/>
</h:selectOneMenu>

The value being set is a short.  Essentially it looks like the code was
doing an automatic conversion before, but now chokes.

I just reverted the code to 1.1.5-SNAPSHOT, and it works again.  I'm going
to try to take a quick look at the differences between
UISelectOne.javabetween those two versions, but in practice I've found
with any large code
base, it'll take a little time to really understand the layout.

On 2/26/07, CarlHowarth <ca...@dlapiper.com> wrote:
>
>
> Hi,
>
> I am having this problem too. My select one is set up as follows:
>
> <h:selectOneMenu id="regionList" binding="#{Bean.regionListUI}"
> value="#{Bean.region}" >
>   <f:converter converterId="myapp.Region"/>
>   <f:selectItem itemValue="0" itemLabel="(all)"/>
>   <t:selectItems var="r" itemLabel="#{r.name}" itemValue="#{r.idString}"
> value="#{applicationBean.regionMap}" />
>   <f:attribute name="fieldRef" value="Region List"/>
> </h:selectOneMenu>
>
> - This was working fine with 1.1.4 but since the upgrade to 1.1.5 it now
> falls over.
> - The application bean is at application scope, so the values should
> always
> be available.
> - The converter changes an ID to a region and vice versa.
> - The page loads up fine, I only have the problem when I select a command
> button that runs an action listener.
> - I use a '<t:saveState value="#{Bean_track}"/>' for my request-scoped
> bean.
> - The region bean implements a working 'equals' method.
> - If I select the manually populated select item, (all), it works
> correctly.
>
> My converter is like this:
>
> public final static String CONVERTER_ID = "myapp.Region";
>     public Object getAsObject(FacesContext facesContext, UIComponent
> uiComponent, String string)
>             throws ConverterException {
>
>        return
> JSFUtils.getAppBackingBean().getRegionMap().get(Integer.parseInt(string));
>     }
>
>     public String getAsString(FacesContext facesContext, UIComponent
> uiComponent, Object object)
>             throws ConverterException {
>         if (object == null) {
>             return null;
>         } else if (object instanceof Region) {
>             final Region region = (Region) object;
>             return region.getId().toString();
>         }
>
>         return object.toString();
>     }
>
>
> I am at a complete loss at the moment, so any thoughts on what could be
> causing this error would be appreciated.
>
> Thanks, Carl
>
>
>
> Ernst Fastl wrote:
> >
> > Hi,
> >
> > I have had a similar problem recently. Generally happens if the
> > application is not able to find the selected value in the List of
> > selectItems.
> > This can be due to 2 possible situations:
> >
> > 1. The list is not available during validation
> > -> try using a <t:saveState value="#{reportsBean.containerTypeList }" />
> > to ensure it is
> >
> > 2. The values of the selectItems (getValue() and setValue()) do not
> > contain
> > Strings and there is no converter:
> >
> > -> use a corresponding converter e.g. for Long - LongConverter
> > for the selectOneMenu
> >
> > hope that helps
> >
> > regards
> >
> > Ernst
> >
> > On 2/22/07, Srinivas V <vu...@gmail.com> wrote:
> >> Hi All,
> >> Please help me!!
> >> I am having an issue with SelectOneMenu.
> >>
> >> I have installed JSF 1.1.5-SNAPSHOT,Tomahawk1.1.5- SNAPSHOT and
> >> tomahawk-sandbox-1.1.5-SNAPSHOT.
> >>
> >> Previously i had myfaces1.1 jar
> >> I dint have issue with selectOneMenu before.
> >>
> >> Now when I submit the page, I am getting this jsf validation error:
> >> Container:"Value is not a valid option"
> >> for a selectOneMenu even if i select some option.
> >>
> >> code:
> >> <h:panelGroup rendered="#{reportsBean.renderContainerType}">
> >>    <x:outputLabel for="containerfilter"
> >> value="#{msgBundle.EPCMgr_ContainerLbl}:"
> >> styleClass="standard_text_bold"/>
> >>    <f:verbatim><br/></f:verbatim>
> >>    <h:selectOneMenu id="containerfilter"
> >> value="#{reportsBean.containerType}" immediate="true" disabled="#{
> >> reportsBean.optionDisabled }" styleClass="standard_input">
> >>     <f:selectItem itemValue="" itemLabel=" " />
> >>     <f:selectItems value="#{reportsBean.containerTypeList }"/>
> >>    </h:selectOneMenu>
> >>   </h:panelGroup>
> >>
> >> Can anybody tell me why it is happening?
> >>
> >> regards
> >> srinivas
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9155607
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Re: [Solved] ERROR: Value is not a valid option

Posted by CarlHowarth <ca...@dlapiper.com>.
Hi,

I am having this problem too. My select one is set up as follows:

<h:selectOneMenu id="regionList" binding="#{Bean.regionListUI}"
value="#{Bean.region}" >
  <f:converter converterId="myapp.Region"/>
  <f:selectItem itemValue="0" itemLabel="(all)"/>
  <t:selectItems var="r" itemLabel="#{r.name}" itemValue="#{r.idString}"
value="#{applicationBean.regionMap}" />
  <f:attribute name="fieldRef" value="Region List"/>
</h:selectOneMenu>

- This was working fine with 1.1.4 but since the upgrade to 1.1.5 it now
falls over. 
- The application bean is at application scope, so the values should always
be available. 
- The converter changes an ID to a region and vice versa. 
- The page loads up fine, I only have the problem when I select a command
button that runs an action listener.
- I use a '<t:saveState value="#{Bean_track}"/>' for my request-scoped bean.
- The region bean implements a working 'equals' method.
- If I select the manually populated select item, (all), it works correctly.

My converter is like this:

public final static String CONVERTER_ID = "myapp.Region";
    public Object getAsObject(FacesContext facesContext, UIComponent
uiComponent, String string)
            throws ConverterException {

       return
JSFUtils.getAppBackingBean().getRegionMap().get(Integer.parseInt(string));
    }

    public String getAsString(FacesContext facesContext, UIComponent
uiComponent, Object object)
            throws ConverterException {
        if (object == null) {
            return null;
        } else if (object instanceof Region) {
            final Region region = (Region) object;
            return region.getId().toString();
        }

        return object.toString();
    }


I am at a complete loss at the moment, so any thoughts on what could be
causing this error would be appreciated.

Thanks, Carl



Ernst Fastl wrote:
> 
> Hi,
> 
> I have had a similar problem recently. Generally happens if the
> application is not able to find the selected value in the List of
> selectItems.
> This can be due to 2 possible situations:
> 
> 1. The list is not available during validation
> -> try using a <t:saveState value="#{reportsBean.containerTypeList }" />
> to ensure it is
> 
> 2. The values of the selectItems (getValue() and setValue()) do not
> contain
> Strings and there is no converter:
> 
> -> use a corresponding converter e.g. for Long - LongConverter
> for the selectOneMenu
> 
> hope that helps
> 
> regards
> 
> Ernst
> 
> On 2/22/07, Srinivas V <vu...@gmail.com> wrote:
>> Hi All,
>> Please help me!!
>> I am having an issue with SelectOneMenu.
>>
>> I have installed JSF 1.1.5-SNAPSHOT,Tomahawk1.1.5- SNAPSHOT and
>> tomahawk-sandbox-1.1.5-SNAPSHOT.
>>
>> Previously i had myfaces1.1 jar
>> I dint have issue with selectOneMenu before.
>>
>> Now when I submit the page, I am getting this jsf validation error:
>> Container:"Value is not a valid option"
>> for a selectOneMenu even if i select some option.
>>
>> code:
>> <h:panelGroup rendered="#{reportsBean.renderContainerType}">
>>    <x:outputLabel for="containerfilter"
>> value="#{msgBundle.EPCMgr_ContainerLbl}:"
>> styleClass="standard_text_bold"/>
>>    <f:verbatim><br/></f:verbatim>
>>    <h:selectOneMenu id="containerfilter"
>> value="#{reportsBean.containerType}" immediate="true" disabled="#{
>> reportsBean.optionDisabled }" styleClass="standard_input">
>>     <f:selectItem itemValue="" itemLabel=" " />
>>     <f:selectItems value="#{reportsBean.containerTypeList }"/>
>>    </h:selectOneMenu>
>>   </h:panelGroup>
>>
>> Can anybody tell me why it is happening?
>>
>> regards
>> srinivas
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/ERROR%3A-Value-is-not-a-valid-option-tf3270984.html#a9155607
Sent from the MyFaces - Users mailing list archive at Nabble.com.


Re: ERROR: Value is not a valid option

Posted by Ernst Fastl <er...@gmail.com>.
Hi,

I have had a similar problem recently. Generally happens if the
application is not able to find the selected value in the List of selectItems.
This can be due to 2 possible situations:

1. The list is not available during validation
-> try using a <t:saveState value="#{reportsBean.containerTypeList }" />
to ensure it is

2. The values of the selectItems (getValue() and setValue()) do not contain
Strings and there is no converter:

-> use a corresponding converter e.g. for Long - LongConverter
for the selectOneMenu

hope that helps

regards

Ernst

On 2/22/07, Srinivas V <vu...@gmail.com> wrote:
> Hi All,
> Please help me!!
> I am having an issue with SelectOneMenu.
>
> I have installed JSF 1.1.5-SNAPSHOT,Tomahawk1.1.5- SNAPSHOT and
> tomahawk-sandbox-1.1.5-SNAPSHOT.
>
> Previously i had myfaces1.1 jar
> I dint have issue with selectOneMenu before.
>
> Now when I submit the page, I am getting this jsf validation error:
> Container:"Value is not a valid option"
> for a selectOneMenu even if i select some option.
>
> code:
> <h:panelGroup rendered="#{reportsBean.renderContainerType}">
>    <x:outputLabel for="containerfilter"
> value="#{msgBundle.EPCMgr_ContainerLbl}:"
> styleClass="standard_text_bold"/>
>    <f:verbatim><br/></f:verbatim>
>    <h:selectOneMenu id="containerfilter"
> value="#{reportsBean.containerType}" immediate="true" disabled="#{
> reportsBean.optionDisabled }" styleClass="standard_input">
>     <f:selectItem itemValue="" itemLabel=" " />
>     <f:selectItems value="#{reportsBean.containerTypeList }"/>
>    </h:selectOneMenu>
>   </h:panelGroup>
>
> Can anybody tell me why it is happening?
>
> regards
> srinivas
>

Re: ERROR: Value is not a valid option

Posted by Mike Kienenberger <mk...@gmail.com>.
Does the error go away if you remove this line?

<f:selectItem itemValue="" itemLabel=" " />

I'm guessing that the empty string "" is not a valid container type.


On 2/21/07, Srinivas V <vu...@gmail.com> wrote:
> Hi All,
> Please help me!!
> I am having an issue with SelectOneMenu.
>
> I have installed JSF 1.1.5-SNAPSHOT,Tomahawk1.1.5- SNAPSHOT and
> tomahawk-sandbox-1.1.5-SNAPSHOT.
>
> Previously i had myfaces1.1 jar
> I dint have issue with selectOneMenu before.
>
> Now when I submit the page, I am getting this jsf validation error:
> Container:"Value is not a valid option"
> for a selectOneMenu even if i select some option.
>
> code:
> <h:panelGroup rendered="#{reportsBean.renderContainerType}">
>    <x:outputLabel for="containerfilter"
> value="#{msgBundle.EPCMgr_ContainerLbl}:"
> styleClass="standard_text_bold"/>
>    <f:verbatim><br/></f:verbatim>
>    <h:selectOneMenu id="containerfilter"
> value="#{reportsBean.containerType}" immediate="true" disabled="#{
> reportsBean.optionDisabled }" styleClass="standard_input">
>     <f:selectItem itemValue="" itemLabel=" " />
>     <f:selectItems value="#{reportsBean.containerTypeList }"/>
>    </h:selectOneMenu>
>   </h:panelGroup>
>
> Can anybody tell me why it is happening?
>
> regards
> srinivas
>