You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by mm...@apache.org on 2005/06/15 23:12:01 UTC
svn commit: r190809 -
/myfaces/trunk/src/myfaces/org/apache/myfaces/config/ManagedBeanBuilder.java
Author: mmarinschek
Date: Wed Jun 15 14:12:00 2005
New Revision: 190809
URL: http://svn.apache.org/viewcvs?rev=190809&view=rev
Log:
feature/bug? ManagedBeanBuilder now accounts for the type of the component
Modified:
myfaces/trunk/src/myfaces/org/apache/myfaces/config/ManagedBeanBuilder.java
Modified: myfaces/trunk/src/myfaces/org/apache/myfaces/config/ManagedBeanBuilder.java
URL: http://svn.apache.org/viewcvs/myfaces/trunk/src/myfaces/org/apache/myfaces/config/ManagedBeanBuilder.java?rev=190809&r1=190808&r2=190809&view=diff
==============================================================================
--- myfaces/trunk/src/myfaces/org/apache/myfaces/config/ManagedBeanBuilder.java (original)
+++ myfaces/trunk/src/myfaces/org/apache/myfaces/config/ManagedBeanBuilder.java Wed Jun 15 14:12:00 2005
@@ -17,6 +17,8 @@
import org.apache.myfaces.config.element.*;
import org.apache.myfaces.util.ClassUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import javax.faces.FacesException;
import javax.faces.application.Application;
@@ -35,6 +37,8 @@
*/
public class ManagedBeanBuilder
{
+ private static Log log = LogFactory.getLog(ManagedBeanBuilder.class);
+
public Object buildManagedBean(FacesContext facesContext, ManagedBean beanConfiguration) throws FacesException
{
Object bean = ClassUtils.newInstance(beanConfiguration.getManagedBeanClassName());
@@ -99,11 +103,56 @@
switch (property.getType())
{
case ManagedProperty.TYPE_LIST:
- value = new ArrayList();
+ if (property.getPropertyClass() != null)
+ {
+ Class listClass = ClassUtils.simpleJavaTypeToClass(property.getPropertyClass());
+ try
+ {
+ value = listClass.newInstance();
+
+ if(!(value instanceof List))
+ {
+ log.error("Supplied type is no instance of java.util.List");
+ value = new ArrayList();
+ }
+ }
+ catch(Exception ex)
+ {
+ log.error("Exception while initiating list-type. ",ex);
+ value = new ArrayList();
+ }
+ }
+ else
+ {
+ value = new ArrayList();
+ }
initializeList(facesContext, property.getListEntries(), (List) value);
break;
case ManagedProperty.TYPE_MAP:
- value = new HashMap();
+ if (property.getPropertyClass() != null)
+ {
+ Class mapClass = ClassUtils.simpleJavaTypeToClass(property.getPropertyClass());
+ try
+ {
+ value = mapClass.newInstance();
+
+ if(!(value instanceof Map))
+ {
+ log.error("Supplied type is no instance of java.util.Map");
+ value = new HashMap();
+ }
+ }
+ catch(Exception ex)
+ {
+ log.error("Exception while initiating map-type. ",ex);
+ value = new HashMap();
+ }
+ }
+ else
+ {
+ value = new HashMap();
+ }
+
initializeMap(facesContext, property.getMapEntries(), (Map) value);
break;
case ManagedProperty.TYPE_NULL: