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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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.
> >
> >
>
>


Reply via email to