[jboss-cvs] jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component ...

Peter Muir peter at bleepbleep.org.uk
Tue May 8 10:07:25 EDT 2007


  User: pmuir   
  Date: 07/05/08 10:07:25

  Modified:    seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component   
                        UIMessage.java UIDecorate.java
  Added:       seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component   
                        UILabel.java
  Log:
  Updates for CDK port
  
  Revision  Changes    Path
  1.2       +53 -22    jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIMessage.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UIMessage.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIMessage.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- UIMessage.java	20 Mar 2007 17:58:58 -0000	1.1
  +++ UIMessage.java	8 May 2007 14:07:25 -0000	1.2
  @@ -21,37 +21,68 @@
   
   package org.jboss.seam.ui.component;
   
  +import javax.faces.component.EditableValueHolder;
   import javax.faces.component.UIComponent;
   import javax.faces.component.html.HtmlMessage;
   
  +import org.jboss.seam.ui.UIDecorate;
  +
   /**
    * JSF component class
    *
    */
   public abstract class UIMessage extends HtmlMessage {
   	
  -	private static final String COMPONENT_TYPE = "org.jboss.seam.ui.Message";
  -	
  -	private static final String COMPONENT_FAMILY = "org.jboss.seam.ui.Message";
  +   /**
  +    * A depth-first search for an EditableValueHolder
  +    */
  +   protected static UIComponent getEditableValueHolder(UIComponent component)
  +   {
  +      if (component instanceof EditableValueHolder)
  +      {
  +         return component.isRendered() ? component : null;
  +      }
  +      for (Object child: component.getChildren())
  +      {
  +         if (child instanceof UIComponent)
  +         {
  +            UIComponent evh = getEditableValueHolder( (UIComponent) child );
  +            if (evh!=null) return evh;
  +         }
  +      }
  +      return null;
  +   }
   
  -    private String getFor(UIComponent component)
  +   private static String getInputId(UIComponent cmp)
         {
  -         /*if (component instanceof UIDecorate) 
  +      String forId = cmp instanceof UIDecorate ?
  +               ( (UIDecorate) cmp ).getFor() : null;
  +      if (forId==null)
            {
  -            return Decorate.getInputId(component);
  +         UIComponent evh = getEditableValueHolder(cmp);
  +         return evh==null ? null : evh.getId();
            }
  -         else if ( component.getParent() instanceof UIDecorateAll )
  +      else
            {
  -            return Decorate.getInputId(component);
  +         return forId;
  +      }
            }
  -         else if ( component.getParent()==null )
  +   
  +   private static String getFor(UIComponent component)
  +   {
  +      
  +      if ( component.getParent()==null )
            {
               return null;
            }
  +      else if (component instanceof UIDecorate) 
  +      {
  +         return getInputId(component);
  +      }
            else
  -         {*/
  +      {
               return getFor( component.getParent() );
  -         /*}*/
  +      }
         }
   
         @Override
  
  
  
  1.2       +4 -74     jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIDecorate.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UIDecorate.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UIDecorate.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -b -r1.1 -r1.2
  --- UIDecorate.java	28 Mar 2007 12:52:14 -0000	1.1
  +++ UIDecorate.java	8 May 2007 14:07:25 -0000	1.2
  @@ -1,9 +1,9 @@
   package org.jboss.seam.ui.component;
   
  -import javax.faces.component.EditableValueHolder;
   import javax.faces.component.UIComponent;
   import javax.faces.component.UIComponentBase;
  -import javax.faces.context.FacesContext;
  +
  +import org.jboss.seam.ui.util.Decoration;
   
   public abstract class UIDecorate extends UIComponentBase
   {
  @@ -11,52 +11,6 @@
      public static final String COMPONENT_TYPE = "org.jboss.seam.ui.UIDecorate";
      public static final String COMPONENT_FAMILY = "org.jboss.seam.ui.Decorate";
   
  -   public static boolean hasMessage(UIComponent component, FacesContext context)
  -   {
  -      if ( !component.isRendered() ) return false;
  -      
  -      /*Iterator<FacesMessage> iter = context.getMessages( component.getClientId(context) );
  -      if ( iter.hasNext() )
  -      {
  -         return true;
  -      }*/
  -      
  -      if ( component instanceof EditableValueHolder )
  -      {
  -         if ( ! ( (EditableValueHolder) component ).isValid() ) return true;
  -      }
  -
  -      for (Object child: component.getChildren())
  -      {
  -         if (child instanceof UIComponent)
  -         {
  -            boolean message = hasMessage( (UIComponent) child, context );
  -            if (message) return true;
  -         }
  -      }
  -      return false;
  -   }
  -
  -   public static boolean hasRequired(UIComponent component, FacesContext context)
  -   {
  -      if ( !component.isRendered() ) return false;
  -      
  -      if ( component instanceof EditableValueHolder )
  -      {
  -         if (  ( (EditableValueHolder) component ).isRequired() ) return true;
  -      }
  -
  -      for (Object child: component.getChildren())
  -      {
  -         if (child instanceof UIComponent)
  -         {
  -            boolean required = hasRequired( (UIComponent) child, context );
  -            if (required) return true;
  -         }
  -      }
  -      return false;
  -   }
  -
      public boolean hasMessage()
      {
         String clientId = getInputClientId();
  @@ -75,7 +29,7 @@
         String id = getFor();
         if (id==null)
         {
  -         UIComponent evh = getEditableValueHolder(this);
  +         UIComponent evh = Decoration.getEditableValueHolder(this);
            return evh==null ? null : evh.getId();
         }
         else
  @@ -89,7 +43,7 @@
         String id = getFor();
         if (id==null)
         {
  -         UIComponent evh = getEditableValueHolder(this);
  +         UIComponent evh = Decoration.getEditableValueHolder(this);
            return evh==null ? null : evh.getClientId( getFacesContext() );
         }
         else
  @@ -99,30 +53,6 @@
         }
      }
   
  -   /**
  -    * A depth-first search for an EditableValueHolder
  -    */
  -   private static UIComponent getEditableValueHolder(UIComponent component)
  -   {
  -      for (Object child: component.getChildren())
  -      {
  -         if (child instanceof EditableValueHolder)
  -         {
  -            UIComponent evh =(UIComponent) child;
  -            if ( evh.isRendered() )
  -            {
  -               return evh;
  -            }
  -         }
  -         else if (child instanceof UIComponent)
  -         {
  -            UIComponent evh = getEditableValueHolder( (UIComponent) child );
  -            if (evh!=null) return evh;
  -         }
  -      }
  -      return null;
  -   }
  -
      public abstract String getFor();
   
      public abstract void setFor(String forId);
  
  
  
  1.1      date: 2007/05/08 14:07:25;  author: pmuir;  state: Exp;jboss-seam/seam-ui-cdk/jboss-seam-ui/src/main/java/org/jboss/seam/ui/component/UILabel.java
  
  Index: UILabel.java
  ===================================================================
  package org.jboss.seam.ui.component;
  
  import javax.faces.component.EditableValueHolder;
  import javax.faces.component.UIComponent;
  import javax.faces.component.html.HtmlOutputLabel;
  
  
  public abstract class UILabel extends HtmlOutputLabel
  {
  
     /**
      * A depth-first search for an EditableValueHolder
      */
     protected static UIComponent getEditableValueHolder(UIComponent component)
     {
        if (component instanceof EditableValueHolder)
        {
           return component.isRendered() ? component : null;
        }
        for (Object child: component.getChildren())
        {
           if (child instanceof UIComponent)
           {
              UIComponent evh = getEditableValueHolder( (UIComponent) child );
              if (evh!=null) return evh;
           }
        }
        return null;
     }
  
     private static String getInputId(UIComponent cmp)
     {
        String forId = cmp instanceof UIDecorate ?
                 ( (UIDecorate) cmp ).getFor() : null;
        if (forId==null)
        {
           UIComponent evh = getEditableValueHolder(cmp);
           return evh==null ? null : evh.getId();
        }
        else
        {
           return forId;
        }
     }
     
     private static String getFor(UIComponent component)
     {
        
        if ( component.getParent()==null )
        {
           return null;
        }
        else if (component instanceof UIDecorate) 
        {
           return getInputId(component);
        }
        else
        {
           return getFor( component.getParent() );
        }
     }
  
     @Override
     public String getFor()
     {
        return getFor(this);
     }
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list