myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lu4...@apache.org
Subject svn commit: r1794908 - /myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/model/FacesDataModelClassBeanHolder.java
Date Fri, 12 May 2017 00:38:52 GMT
Author: lu4242
Date: Fri May 12 00:38:52 2017
New Revision: 1794908

URL: http://svn.apache.org/viewvc?rev=1794908&view=rev
Log:
MYFACES-4079 Implement CDI changes for JSF 2.3 ( @FacesDataModel )

Modified:
    myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/model/FacesDataModelClassBeanHolder.java

Modified: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/model/FacesDataModelClassBeanHolder.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/model/FacesDataModelClassBeanHolder.java?rev=1794908&r1=1794907&r2=1794908&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/model/FacesDataModelClassBeanHolder.java
(original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/model/FacesDataModelClassBeanHolder.java
Fri May 12 00:38:52 2017
@@ -105,8 +105,40 @@ public class FacesDataModelClassBeanHold
     {
         try
         {
-            Constructor constructor = dataModelClass.getConstructor(forClass);
-            return (DataModel) constructor.newInstance(value);
+            Constructor selectedConstructor = null;
+            boolean equalsFound = false;
+            for (Constructor constructor : dataModelClass.getConstructors())
+            {
+                if (constructor.getParameterCount() == 1)
+                {
+                    if (constructor.getParameterTypes()[0].equals(forClass))
+                    {
+                        selectedConstructor = constructor;
+                        equalsFound = true;
+                    }
+                    else if (constructor.getParameterTypes()[0].isAssignableFrom(forClass))
+                    {
+                        if (!equalsFound)
+                        {
+                            selectedConstructor = constructor;
+                        }
+                    }
+                }
+            }
+            
+            Constructor constructor = null;
+            if (selectedConstructor != null)
+            {
+                constructor = selectedConstructor;
+                return (DataModel) constructor.newInstance(value);
+            }
+            else
+            {
+                constructor = dataModelClass.getConstructor();
+                DataModel dm = (DataModel) constructor.newInstance();
+                dm.setWrappedData(value);
+                return dm;
+            }
         } 
         catch (NoSuchMethodException ex)
         {



Mime
View raw message