myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fastbob <fast...@gmail.com>
Subject Re: ERROR: Value is not a valid option
Date Fri, 30 Mar 2007 22:29:06 GMT


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.


Mime
View raw message