[jboss-cvs] jboss-seam/src/main/org/jboss/seam/core ...

Gavin King gavin.king at jboss.com
Mon Jul 24 16:52:50 EDT 2006


  User: gavin   
  Date: 06/07/24 16:52:50

  Modified:    src/main/org/jboss/seam/core   ManagedEntity.java
                        ManagedHibernateEntity.java
  Log:
  improve id conversion
  
  Revision  Changes    Path
  1.3       +29 -15    jboss-seam/src/main/org/jboss/seam/core/ManagedEntity.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ManagedEntity.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ManagedEntity.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- ManagedEntity.java	24 Jul 2006 20:44:51 -0000	1.2
  +++ ManagedEntity.java	24 Jul 2006 20:52:50 -0000	1.3
  @@ -16,8 +16,9 @@
      private Object id;
      private String entityClass;
      private Object newInstance;
  -   private String converterId;
  -   private Converter converter;
  +   private String idConverterId;
  +   private String idClass;
  +   private Converter idConverter;
      
      public EntityManager getEntityManager()
      {
  @@ -69,15 +70,19 @@
      
      //////////// TODO: copy/paste from ManagedHibernateEntity ///////////////////
      
  -   private Object getConvertedId()
  +   private Object getConvertedId() throws Exception
      {
         FacesContext facesContext = FacesContext.getCurrentInstance();
  -      if (converterId!=null)
  +      if (idConverterId!=null)
         {
  -         converter = facesContext.getApplication().createConverter(converterId); //cache the lookup
  +         idConverter = facesContext.getApplication().createConverter(idConverterId); //cache the lookup
  +      }
  +      else if (idClass!=null)
  +      {
  +         idConverter = facesContext.getApplication().createConverter( Class.forName(idClass) );
         }
         
  -      if (converter==null)
  +      if (idConverter==null)
         {
            //TODO: look for an @Id annotation and guess the id type!
            //converter = facesContext.getApplication().createConverter(idClass)
  @@ -85,7 +90,7 @@
         }
         else
         {
  -         return converter.getAsObject( 
  +         return idConverter.getAsObject( 
                  facesContext, 
                  facesContext.getViewRoot(), 
                  (String) id 
  @@ -93,25 +98,34 @@
         }
      }
   
  -   public String getConverterId()
  +   public String getIdConverterId()
      {
  -      return converterId;
  +      return idConverterId;
      }
   
  -   public void setConverterId(String converterId)
  +   public void setIdConverterId(String converterId)
      {
  -      this.converterId = converterId;
  +      this.idConverterId = converterId;
      }
   
  -   public Converter getConverter()
  +   public Converter getIdConverter()
      {
  -      return converter;
  +      return idConverter;
      }
   
  -   public void setConverter(Converter converter)
  +   public void setIdConverter(Converter converter)
      {
  -      this.converter = converter;
  +      this.idConverter = converter;
      }
   
  +   public String getIdClass()
  +   {
  +      return idClass;
  +   }
  +
  +   public void setIdClass(String idClass)
  +   {
  +      this.idClass = idClass;
  +   }
   
   }
  
  
  
  1.4       +30 -15    jboss-seam/src/main/org/jboss/seam/core/ManagedHibernateEntity.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: ManagedHibernateEntity.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/main/org/jboss/seam/core/ManagedHibernateEntity.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- ManagedHibernateEntity.java	24 Jul 2006 20:44:51 -0000	1.3
  +++ ManagedHibernateEntity.java	24 Jul 2006 20:52:50 -0000	1.4
  @@ -15,8 +15,9 @@
      private Serializable id;
      private String entityClass;
      private Object newInstance;
  -   private String converterId;
  -   private Converter converter;
  +   private String idConverterId;
  +   private String idClass;
  +   private Converter idConverter;
      
      public Session getSession()
      {
  @@ -68,15 +69,19 @@
      
      ////////////TODO: copy/paste from ManagedEntity ///////////////////
   
  -   private Serializable getConvertedId()
  +   private Serializable getConvertedId() throws ClassNotFoundException
      {
         FacesContext facesContext = FacesContext.getCurrentInstance();
  -      if (converterId!=null)
  +      if (idConverterId!=null)
         {
  -         converter = facesContext.getApplication().createConverter(converterId); //cache the lookup
  +         idConverter = facesContext.getApplication().createConverter(idConverterId); //cache the lookup
  +      }
  +      else if (idClass!=null)
  +      {
  +         idConverter = facesContext.getApplication().createConverter( Class.forName(idClass) );
         }
         
  -      if (converter==null)
  +      if (idConverter==null)
         {
            //TODO: look for an @Id annotation and guess the id type!
            //converter = facesContext.getApplication().createConverter(idClass)
  @@ -84,7 +89,7 @@
         }
         else
         {
  -         return (Serializable) converter.getAsObject( 
  +         return (Serializable) idConverter.getAsObject( 
                  facesContext, 
                  facesContext.getViewRoot(), 
                  (String) id 
  @@ -92,24 +97,34 @@
         }
      }
   
  -   public String getConverterId()
  +   public String getIdConverterId()
  +   {
  +      return idConverterId;
  +   }
  +
  +   public void setIdConverterId(String converterId)
  +   {
  +      this.idConverterId = converterId;
  +   }
  +
  +   public Converter getIdConverter()
      {
  -      return converterId;
  +      return idConverter;
      }
   
  -   public void setConverterId(String converterId)
  +   public void setIdConverter(Converter converter)
      {
  -      this.converterId = converterId;
  +      this.idConverter = converter;
      }
   
  -   public Converter getConverter()
  +   public String getIdClass()
      {
  -      return converter;
  +      return idClass;
      }
   
  -   public void setConverter(Converter converter)
  +   public void setIdClass(String idClass)
      {
  -      this.converter = converter;
  +      this.idClass = idClass;
      }
   
   }
  
  
  



More information about the jboss-cvs-commits mailing list