Martin,

This change seems to stop any commandLinks and commandButtons from firing that are in the same form as the UISelect. It may or may not be specific to a facelets environment, and it may not only be restricted to commandLinks and commandButtons (those are the only two I tested).  It took me quite a long time to isolate this, but basically everything works fine up to SVN revision r449566. I've included my code below to illustrate. Funnily enough, the commandNavigation still fires! I put that in just for test purposes..

Let me know what you think...

<ui:composition>
    <h:panelGrid id="nav"
                 columns="1">
        <h:form> 
            <h:panelGrid columns="2" styleClass="compactTable" columnClasses="compactColumn">
                <t:commandLink id="nav_0_1" value="Project" action="">                <t:outputText value="#{globalOptions.currentProject}"/>
                <h:outputLabel for="" value="Draw"/>
                <t:selectOneMenu id="drawSelector" value="#{globalOptions.currentDrawNumber}" this.form.submit();">
                    <f:selectItems value="#{globalOptions.drawList.selects}"/>
                </t:selectOneMenu>
                <h:outputLabel for="" value="From"/>
                <t:outputText id="from" value="#{globalOptions.currentDraw.startDate}">
                    <f:convertDateTime pattern="MM/dd/yyyy"/>
                </t:outputText>
                <h:outputLabel for="" value="To"/>
                <t:outputText id="to" value="#{globalOptions.currentDraw.endDate}">
                    <f:convertDateTime pattern="MM/dd/yyyy"/>
                </t:outputText>
                <h:outputLabel for="" value="Schedule"/>
                <t:outputText id="dstatus" value="#{globalOptions.currentDraw.scheduleStatus }"/>
                <t:commandLink id="nav_0_2" value="Contract" action="">                <t:outputText value="#{globalOptions.currentContractDescription }"/>
                <t:commandNavigation id="nav_0_3" value="Vendor" action="">                <t:outputText value="#{globalOptions.currentVendorDescription }"/>
            </h:panelGrid>
        </h:form>


On 9/24/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Author: mmarinschek
Date: Sun Sep 24 21:06:24 2006
New Revision: 449566

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.

Modified:
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectMany.java
    myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectOne.java
    myfaces/core/trunk/api/src/main/java/javax/faces/component/_SelectItemsUtil.java

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectMany.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectMany.java?view=diff&rev=449566&r1=449565&r2=449566
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectMany.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectMany.java Sun Sep 24 21:06:24 2006
@@ -261,26 +261,6 @@

         if (isValid() && hasValues)
         {
-            // all selected values must match to the values of the available options
-
-            _ValueConverter converter = new _ValueConverter()
-            {
-                public Object getConvertedValue(FacesContext context, String value)
-                {
-                    Object convertedValue = UISelectMany.this.getConvertedValue(context, new String[] {value});
-                    if(convertedValue instanceof Collection)
-                    {
-                        Iterator iter = ((Collection)convertedValue).iterator();
-                        if(iter.hasNext())
-                        {
-                            return iter.next();
-                        }
-                        return null;
-                    }
-                    return ((Object[])convertedValue)[0];
-                }
-            };
-
             Collection items = new ArrayList();
             for (Iterator iter = new _SelectItemsIterator(this); iter.hasNext();)
             {
@@ -290,8 +270,7 @@
             {
                 Object itemValue = itemValues.next();

-                if (!_SelectItemsUtil.matchValue(context, itemValue,
-                                                 items.iterator (), converter))
+                if (!_SelectItemsUtil.matchValue(itemValue, items.iterator()))
                 {
                     _MessageUtils.addErrorMessage(context, this,
                                     INVALID_MESSAGE_ID,

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectOne.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectOne.java?view=diff&rev=449566&r1=449565&r2=449566
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectOne.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/UISelectOne.java Sun Sep 24 21:06:24 2006
@@ -50,16 +50,8 @@
             return;
         }

-        _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))
+        if (!_SelectItemsUtil.matchValue(value, new _SelectItemsIterator(this)))
         {
             _MessageUtils.addErrorMessage(context, this, INVALID_MESSAGE_ID,
                             new Object[] {getId()});

Modified: myfaces/core/trunk/api/src/main/java/javax/faces/component/_SelectItemsUtil.java
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/java/javax/faces/component/_SelectItemsUtil.java?view=diff&rev=449566&r1=449565&r2=449566
==============================================================================
--- myfaces/core/trunk/api/src/main/java/javax/faces/component/_SelectItemsUtil.java (original)
+++ myfaces/core/trunk/api/src/main/java/javax/faces/component/_SelectItemsUtil.java Sun Sep 24 21:06:24 2006
@@ -34,14 +34,12 @@
     }

     /**
-     * @param context the faces context
      * @param value the value to check
-     * @param converter
-     * @param iterator contains instances of SelectItem
+     * @param selectItemsIter contains instances of SelectItem
      * @return if the value of a selectitem is equal to the given value
      */
-    public static boolean matchValue(FacesContext context, Object value,
-                    Iterator selectItemsIter, _ValueConverter converter)
+    public static boolean matchValue(Object value,
+                    Iterator selectItemsIter)
     {
         while (selectItemsIter.hasNext())
         {
@@ -52,8 +50,8 @@
                 SelectItem[] selectItems = itemgroup.getSelectItems();
                 if (selectItems != null
                                 && selectItems.length > 0
-                                && matchValue(context, value, Arrays.asList (
-                                                selectItems).iterator(), converter))
+                                && matchValue(value, Arrays.asList(
+                                                selectItems).iterator()))
                 {
                     return true;
                 }
@@ -61,10 +59,6 @@
             else
             {
                 Object itemValue = item.getValue();
-                if(converter != null && itemValue instanceof String)
-                {
-                    itemValue = converter.getConvertedValue(context, (String)itemValue);
-                }
                 if (value==itemValue || value.equals(itemValue))
                 {
                     return true;





--
Grant Smith

Reply via email to