myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1309048 [1/7] - in /myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared: application/ renderkit/ renderkit/html/ resource/ taglib/ taglib/core/ util/ util/io/ util/renderkit/
Date Tue, 03 Apr 2012 17:06:13 GMT
Author: lu4242
Date: Tue Apr  3 17:06:12 2012
New Revision: 1309048

URL: http://svn.apache.org/viewvc?rev=1309048&view=rev
Log:
sync with myfaces impl shared

Modified:
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/application/NavigationUtils.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/ContentTypeUtils.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/_SharedRendererUtils.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlJavaScriptUtils.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/HtmlMessageRendererBase.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/html/JavascriptContext.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceLoaderWrapper.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ResourceValidationUtils.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/resource/ValueExpressionFilterInputStream.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagBase.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentELTagUtils.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/taglib/UIComponentTagUtils.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/taglib/core/SelectItemTagBase.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/AttachedDeltaWrapper.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ComponentUtils.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/ConcurrentLRUCache.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/DebugUtils.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/PriorityQueue.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/RendererUtils.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/TagUtils.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/io/DynamicPushbackInputStream.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/renderkit/ClientBehaviorEvents.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/renderkit/HTML.java
    myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/util/renderkit/JsfProperties.java

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/application/NavigationUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/application/NavigationUtils.java?rev=1309048&r1=1309047&r2=1309048&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/application/NavigationUtils.java
(original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/application/NavigationUtils.java
Tue Apr  3 17:06:12 2012
@@ -1,109 +1,109 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.shared.application;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.faces.context.FacesContext;
-
-/**
- * 
- * @author Leonardo Uribe
- *
- */
-public class NavigationUtils
-{
-    /**
-     * Evaluate all EL expressions found as parameters and return a map that can be used
for 
-     * redirect or render bookmark links
-     * 
-     * @param parameters parameter map retrieved from NavigationCase.getParameters()
-     * @return
-     */
-    public static Map<String, List<String> > getEvaluatedNavigationParameters(
-            FacesContext facesContext, 
-            Map<String, List<String> > parameters)
-    {
-        Map<String,List<String>> evaluatedParameters = null;
-        if (parameters != null && parameters.size() > 0)
-        {
-            evaluatedParameters = new HashMap<String, List<String>>();
-            for (Map.Entry<String, List<String>> pair : parameters.entrySet())
-            {
-                boolean containsEL = false;
-                for (String value : pair.getValue())
-                {
-                    if (_isExpression(value))
-                    {
-                        containsEL = true;
-                        break;
-                    }
-                }
-                if (containsEL)
-                {
-                    evaluatedParameters.put(pair.getKey(), 
-                            _evaluateValueExpressions(facesContext, pair.getValue()));
-                }
-                else
-                {
-                    evaluatedParameters.put(pair.getKey(), pair.getValue());
-                }
-            }
-        }
-        else
-        {
-            evaluatedParameters = parameters;
-        }
-        return evaluatedParameters;
-    }
-    
-    /**
-     * Checks the Strings in the List for EL expressions and evaluates them.
-     * Note that the returned List will be a copy of the given List, because
-     * otherwise it will have unwanted side-effects.
-     * @param values
-     * @return
-     */
-    private static List<String> _evaluateValueExpressions(FacesContext context, List<String>
values)
-    {
-        // note that we have to create a new List here, because if we
-        // change any value on the given List, it will be changed in the
-        // NavigationCase too and the EL expression won't be evaluated again
-        List<String> target = new ArrayList<String>(values.size());
-        for (String value : values)
-        {
-            if (_isExpression(value))
-            {
-                // evaluate the ValueExpression
-                value = context.getApplication().evaluateExpressionGet(context, value, String.class);
-            }
-            target.add(value);
-        }
-        return target;
-    }
-    
-    private static boolean _isExpression(String text)
-    {
-        return text.indexOf("#{") != -1;
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.shared.application;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ *
+ */
+public class NavigationUtils
+{
+    /**
+     * Evaluate all EL expressions found as parameters and return a map that can be used
for 
+     * redirect or render bookmark links
+     * 
+     * @param parameters parameter map retrieved from NavigationCase.getParameters()
+     * @return
+     */
+    public static Map<String, List<String> > getEvaluatedNavigationParameters(
+            FacesContext facesContext, 
+            Map<String, List<String> > parameters)
+    {
+        Map<String,List<String>> evaluatedParameters = null;
+        if (parameters != null && parameters.size() > 0)
+        {
+            evaluatedParameters = new HashMap<String, List<String>>();
+            for (Map.Entry<String, List<String>> pair : parameters.entrySet())
+            {
+                boolean containsEL = false;
+                for (String value : pair.getValue())
+                {
+                    if (_isExpression(value))
+                    {
+                        containsEL = true;
+                        break;
+                    }
+                }
+                if (containsEL)
+                {
+                    evaluatedParameters.put(pair.getKey(), 
+                            _evaluateValueExpressions(facesContext, pair.getValue()));
+                }
+                else
+                {
+                    evaluatedParameters.put(pair.getKey(), pair.getValue());
+                }
+            }
+        }
+        else
+        {
+            evaluatedParameters = parameters;
+        }
+        return evaluatedParameters;
+    }
+    
+    /**
+     * Checks the Strings in the List for EL expressions and evaluates them.
+     * Note that the returned List will be a copy of the given List, because
+     * otherwise it will have unwanted side-effects.
+     * @param values
+     * @return
+     */
+    private static List<String> _evaluateValueExpressions(FacesContext context, List<String>
values)
+    {
+        // note that we have to create a new List here, because if we
+        // change any value on the given List, it will be changed in the
+        // NavigationCase too and the EL expression won't be evaluated again
+        List<String> target = new ArrayList<String>(values.size());
+        for (String value : values)
+        {
+            if (_isExpression(value))
+            {
+                // evaluate the ValueExpression
+                value = context.getApplication().evaluateExpressionGet(context, value, String.class);
+            }
+            target.add(value);
+        }
+        return target;
+    }
+    
+    private static boolean _isExpression(String text)
+    {
+        return text.indexOf("#{") != -1;
+    }
+
+}

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/ContentTypeUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/ContentTypeUtils.java?rev=1309048&r1=1309047&r2=1309048&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/ContentTypeUtils.java
(original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/ContentTypeUtils.java
Tue Apr  3 17:06:12 2012
@@ -1,136 +1,136 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.myfaces.shared.renderkit;
-
-import javax.faces.context.FacesContext;
-
-import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
-import org.apache.myfaces.shared.util.StringUtils;
-
-/**
- * 
- * @author Leonardo Uribe
- *
- */
-public class ContentTypeUtils
-{
-    public static final String HTML_CONTENT_TYPE = "text/html";
-    public static final String TEXT_ANY_CONTENT_TYPE = "text/*";
-    public static final String ANY_CONTENT_TYPE = "*/*";
-
-    public static final String[] HTML_ALLOWED_CONTENT_TYPES = {HTML_CONTENT_TYPE, 
-        ANY_CONTENT_TYPE, TEXT_ANY_CONTENT_TYPE};
-    
-    public static final String XHTML_CONTENT_TYPE = "application/xhtml+xml";
-    public static final String APPLICATION_XML_CONTENT_TYPE = "application/xml";
-    public static final String TEXT_XML_CONTENT_TYPE = "text/xml";
-    
-    public static final String[] XHTML_ALLOWED_CONTENT_TYPES = {XHTML_CONTENT_TYPE, 
-        APPLICATION_XML_CONTENT_TYPE, TEXT_XML_CONTENT_TYPE};
-    
-    public static final String[] AJAX_XHTML_ALLOWED_CONTENT_TYPES = {XHTML_CONTENT_TYPE};
-
-
-    /**
-     * Indicate if the passes content type match one of the options passed. 
-     */
-    public static boolean containsContentType(String contentType, String[] allowedContentTypes)
-    {
-        if (allowedContentTypes == null)
-        {
-            return false;
-        }
-        for (int i = 0; i < allowedContentTypes.length; i++)
-        {
-            if (allowedContentTypes[i].indexOf(contentType) != -1)
-            {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    public static String chooseWriterContentType(String contentTypeListString, 
-            String[] htmlContentTypes, String[] xhtmlContentTypes)
-    {
-        String[] contentTypeList = splitContentTypeListString(contentTypeListString);
-        String[] supportedContentTypeArray = HtmlRendererUtils.getSupportedContentTypes();
-        String selectedContentType = null;
-        for (int i = 0; i < supportedContentTypeArray.length; i++)
-        {
-            String supportedContentType = supportedContentTypeArray[i].trim();
-
-            for (int j = 0; j < contentTypeList.length; j++)
-            {
-                String contentType = (String) contentTypeList[j];
-
-                if (contentType.indexOf(supportedContentType) != -1)
-                {
-                    if (containsContentType(contentType, htmlContentTypes))
-                    {
-                        selectedContentType = HTML_CONTENT_TYPE;
-                    }
-                    else if (containsContentType(contentType, xhtmlContentTypes))
-                    {
-                        selectedContentType = XHTML_CONTENT_TYPE;
-                    }
-                    break;
-                }
-            }
-            if (selectedContentType != null)
-            {
-                break;
-            }
-        }
-        return selectedContentType;
-    }
-    
-    public static String[] splitContentTypeListString(String contentTypeListString)
-    {
-        String[] splittedArray = StringUtils.splitShortString(contentTypeListString, ',');
-        for (int i = 0; i < splittedArray.length; i++)
-        {
-            int semicolonIndex = splittedArray[i].indexOf(";");
-            if (semicolonIndex != -1)
-            {
-                splittedArray[i] = splittedArray[i].substring(0,semicolonIndex);
-            }
-        }
-        return splittedArray;
-    }
-    
-    public static String getContentTypeFromAcceptHeader(FacesContext context)
-    {
-        String contentTypeListString = (String) context.getExternalContext()
-            .getRequestHeaderMap().get("Accept");
-        // There is a windows mobile IE client (6.12) sending
-        // "application/vnd.wap.mms-message;*/*"
-        // Note that the Accept header should be written as 
-        // "application/vnd.wap.mms-message,*/*" ,
-        // so this is bug of the client. Anyway, this is a workaround ...
-        if (contentTypeListString != null
-                && contentTypeListString
-                        .startsWith("application/vnd.wap.mms-message;*/*"))
-        {
-            contentTypeListString = "*/*";
-        }
-        return contentTypeListString;
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.shared.renderkit;
+
+import javax.faces.context.FacesContext;
+
+import org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.shared.util.StringUtils;
+
+/**
+ * 
+ * @author Leonardo Uribe
+ *
+ */
+public class ContentTypeUtils
+{
+    public static final String HTML_CONTENT_TYPE = "text/html";
+    public static final String TEXT_ANY_CONTENT_TYPE = "text/*";
+    public static final String ANY_CONTENT_TYPE = "*/*";
+
+    public static final String[] HTML_ALLOWED_CONTENT_TYPES = {HTML_CONTENT_TYPE, 
+        ANY_CONTENT_TYPE, TEXT_ANY_CONTENT_TYPE};
+    
+    public static final String XHTML_CONTENT_TYPE = "application/xhtml+xml";
+    public static final String APPLICATION_XML_CONTENT_TYPE = "application/xml";
+    public static final String TEXT_XML_CONTENT_TYPE = "text/xml";
+    
+    public static final String[] XHTML_ALLOWED_CONTENT_TYPES = {XHTML_CONTENT_TYPE, 
+        APPLICATION_XML_CONTENT_TYPE, TEXT_XML_CONTENT_TYPE};
+    
+    public static final String[] AJAX_XHTML_ALLOWED_CONTENT_TYPES = {XHTML_CONTENT_TYPE};
+
+
+    /**
+     * Indicate if the passes content type match one of the options passed. 
+     */
+    public static boolean containsContentType(String contentType, String[] allowedContentTypes)
+    {
+        if (allowedContentTypes == null)
+        {
+            return false;
+        }
+        for (int i = 0; i < allowedContentTypes.length; i++)
+        {
+            if (allowedContentTypes[i].indexOf(contentType) != -1)
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public static String chooseWriterContentType(String contentTypeListString, 
+            String[] htmlContentTypes, String[] xhtmlContentTypes)
+    {
+        String[] contentTypeList = splitContentTypeListString(contentTypeListString);
+        String[] supportedContentTypeArray = HtmlRendererUtils.getSupportedContentTypes();
+        String selectedContentType = null;
+        for (int i = 0; i < supportedContentTypeArray.length; i++)
+        {
+            String supportedContentType = supportedContentTypeArray[i].trim();
+
+            for (int j = 0; j < contentTypeList.length; j++)
+            {
+                String contentType = (String) contentTypeList[j];
+
+                if (contentType.indexOf(supportedContentType) != -1)
+                {
+                    if (containsContentType(contentType, htmlContentTypes))
+                    {
+                        selectedContentType = HTML_CONTENT_TYPE;
+                    }
+                    else if (containsContentType(contentType, xhtmlContentTypes))
+                    {
+                        selectedContentType = XHTML_CONTENT_TYPE;
+                    }
+                    break;
+                }
+            }
+            if (selectedContentType != null)
+            {
+                break;
+            }
+        }
+        return selectedContentType;
+    }
+    
+    public static String[] splitContentTypeListString(String contentTypeListString)
+    {
+        String[] splittedArray = StringUtils.splitShortString(contentTypeListString, ',');
+        for (int i = 0; i < splittedArray.length; i++)
+        {
+            int semicolonIndex = splittedArray[i].indexOf(";");
+            if (semicolonIndex != -1)
+            {
+                splittedArray[i] = splittedArray[i].substring(0,semicolonIndex);
+            }
+        }
+        return splittedArray;
+    }
+    
+    public static String getContentTypeFromAcceptHeader(FacesContext context)
+    {
+        String contentTypeListString = (String) context.getExternalContext()
+            .getRequestHeaderMap().get("Accept");
+        // There is a windows mobile IE client (6.12) sending
+        // "application/vnd.wap.mms-message;*/*"
+        // Note that the Accept header should be written as 
+        // "application/vnd.wap.mms-message,*/*" ,
+        // so this is bug of the client. Anyway, this is a workaround ...
+        if (contentTypeListString != null
+                && contentTypeListString
+                        .startsWith("application/vnd.wap.mms-message;*/*"))
+        {
+            contentTypeListString = "*/*";
+        }
+        return contentTypeListString;
+    }
+
+}

Modified: myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/_SharedRendererUtils.java
URL: http://svn.apache.org/viewvc/myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/_SharedRendererUtils.java?rev=1309048&r1=1309047&r2=1309048&view=diff
==============================================================================
--- myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/_SharedRendererUtils.java
(original)
+++ myfaces/shared/trunk/core/src/main/java/org/apache/myfaces/shared/renderkit/_SharedRendererUtils.java
Tue Apr  3 17:06:12 2012
@@ -189,104 +189,100 @@ class _SharedRendererUtils
                     SelectItemsIterator iterator = new SelectItemsIterator(component, facesContext);
                     converter = getSelectItemsValueConverter(iterator, facesContext);
                 }
-                
-                if (Collection.class.isAssignableFrom(modelType))
+
+                Object collectionTypeAttr = component.getAttributes().get(
+                        COLLECTION_TYPE_KEY);
+                if (collectionTypeAttr != null)
                 {
-                    // the target should be a Collection
-                    Object collectionTypeAttr = component.getAttributes().get(
-                            COLLECTION_TYPE_KEY);
-                    if (collectionTypeAttr != null)
+                    Class<?> collectionType = getClassFromAttribute(facesContext, collectionTypeAttr);
+                    if (collectionType == null)
                     {
-                        Class<?> collectionType = getClassFromAttribute(facesContext,
collectionTypeAttr);
-                        if (collectionType == null)
-                        {
-                            throw new FacesException(
-                                    "The attribute "
-                                            + COLLECTION_TYPE_KEY
-                                            + " of component "
-                                            + component.getClientId(facesContext)
-                                            + " does not evaluate to a "
-                                            + "String, a Class object or a ValueExpression
pointing "
-                                            + "to a String or a Class object.");
-                        }
-                        // now we have a collectionType --> but is it really some kind
of Collection
-                        if (!Collection.class.isAssignableFrom(collectionType))
-                        {
-                            throw new FacesException("The attribute "
-                                    + COLLECTION_TYPE_KEY + " of component "
-                                    + component.getClientId(facesContext)
-                                    + " does not point to a valid type of Collection.");
-                        }
-                        // now we have a real collectionType --> try to instantiate it
+                        throw new FacesException(
+                                "The attribute "
+                                        + COLLECTION_TYPE_KEY
+                                        + " of component "
+                                        + component.getClientId(facesContext)
+                                        + " does not evaluate to a "
+                                        + "String, a Class object or a ValueExpression pointing
"
+                                        + "to a String or a Class object.");
+                    }
+                    // now we have a collectionType --> but is it really some kind of
Collection
+                    if (!Collection.class.isAssignableFrom(collectionType))
+                    {
+                        throw new FacesException("The attribute "
+                                + COLLECTION_TYPE_KEY + " of component "
+                                + component.getClientId(facesContext)
+                                + " does not point to a valid type of Collection.");
+                    }
+                    // now we have a real collectionType --> try to instantiate it
+                    try
+                    {
+                        targetForConvertedValues = collectionType.newInstance();
+                    }
+                    catch (Exception e)
+                    {
+                        throw new FacesException("The Collection "
+                                + collectionType.getName()
+                                + "can not be instantiated.", e);
+                    }
+                }
+                else if (Collection.class.isAssignableFrom(modelType))
+                {
+                    // component.getValue() will implement Collection at this point
+                    Collection<?> componentValue = (Collection<?>) component
+                            .getValue();
+                    // can we clone the Collection
+                    if (componentValue instanceof Cloneable)
+                    {
+                        // clone method of Object is protected --> use reflection
                         try
                         {
-                            targetForConvertedValues = collectionType.newInstance();
+                            Method cloneMethod = componentValue.getClass()
+                                    .getMethod("clone");
+                            Collection<?> clone = (Collection<?>) cloneMethod
+                                    .invoke(componentValue);
+                            clone.clear();
+                            targetForConvertedValues = clone;
                         }
                         catch (Exception e)
                         {
-                            throw new FacesException("The Collection "
-                                    + collectionType.getName()
-                                    + "can not be instantiated.", e);
+                            log(facesContext, "Could not clone "
+                                    + componentValue.getClass().getName(), e);
                         }
                     }
-                    else
+
+                    // if clone did not work
+                    if (targetForConvertedValues == null)
                     {
-                        // component.getValue() will implement Collection at this point
-                        Collection<?> componentValue = (Collection<?>) component
-                                .getValue();
-                        // can we clone the Collection
-                        if (componentValue instanceof Cloneable)
+                        // try to create the (concrete) collection from modelType 
+                        // or with the class object of componentValue (if any)
+                        try
                         {
-                            // clone method of Object is protected --> use reflection
-                            try
+                            targetForConvertedValues = (componentValue != null 
+                                    ? componentValue.getClass()
+                                    : modelType).newInstance();
+                        }
+                        catch (Exception e)
+                        {
+                            // this did not work either
+                            // use the standard concrete type
+                            if (SortedSet.class.isAssignableFrom(modelType))
                             {
-                                Method cloneMethod = componentValue.getClass()
-                                        .getMethod("clone");
-                                Collection<?> clone = (Collection<?>) cloneMethod
-                                        .invoke(componentValue);
-                                clone.clear();
-                                targetForConvertedValues = clone;
+                                targetForConvertedValues = new TreeSet();
                             }
-                            catch (Exception e)
+                            else if (Queue.class.isAssignableFrom(modelType))
                             {
-                                log(facesContext, "Could not clone "
-                                        + componentValue.getClass().getName(), e);
+                                targetForConvertedValues = new LinkedList();
                             }
-                        }
-    
-                        // if clone did not work
-                        if (targetForConvertedValues == null)
-                        {
-                            // try to create the (concrete) collection from modelType 
-                            // or with the class object of componentValue (if any)
-                            try
+                            else if (Set.class.isAssignableFrom(modelType))
                             {
-                                targetForConvertedValues = (componentValue != null 
-                                        ? componentValue.getClass()
-                                        : modelType).newInstance();
+                                targetForConvertedValues = new HashSet(
+                                        submittedValue.length);
                             }
-                            catch (Exception e)
+                            else
                             {
-                                // this did not work either
-                                // use the standard concrete type
-                                if (SortedSet.class.isAssignableFrom(modelType))
-                                {
-                                    targetForConvertedValues = new TreeSet();
-                                }
-                                else if (Queue.class.isAssignableFrom(modelType))
-                                {
-                                    targetForConvertedValues = new LinkedList();
-                                }
-                                else if (Set.class.isAssignableFrom(modelType))
-                                {
-                                    targetForConvertedValues = new HashSet(
-                                            submittedValue.length);
-                                }
-                                else
-                                {
-                                    targetForConvertedValues = new ArrayList(
-                                            submittedValue.length);
-                                }
+                                targetForConvertedValues = new ArrayList(
+                                        submittedValue.length);
                             }
                         }
                     }



Mime
View raw message