[jboss-cvs] jboss-seam/src/ui/org/jboss/seam/ui ...

Gavin King gavin.king at jboss.com
Sun Mar 18 00:22:28 EDT 2007


  User: gavin   
  Date: 07/03/18 00:22:28

  Modified:    src/ui/org/jboss/seam/ui       HtmlMessageDecoration.java
                        JSF.java UIDecorate.java
  Added:       src/ui/org/jboss/seam/ui       UIAbstractDecorate.java
                        UIDecorateAll.java
  Removed:     src/ui/org/jboss/seam/ui       HtmlLayoutForm.java
  Log:
  s:decorateAll
  
  Revision  Changes    Path
  1.3       +1 -1      jboss-seam/src/ui/org/jboss/seam/ui/HtmlMessageDecoration.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: HtmlMessageDecoration.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/ui/org/jboss/seam/ui/HtmlMessageDecoration.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- HtmlMessageDecoration.java	18 Mar 2007 01:31:42 -0000	1.2
  +++ HtmlMessageDecoration.java	18 Mar 2007 04:22:28 -0000	1.3
  @@ -14,7 +14,7 @@
         {
            return UIDecorate.getInputId(component);
         }
  -      else if ( component.getParent() instanceof HtmlLayoutForm )
  +      else if ( component.getParent() instanceof UIDecorateAll )
         {
            return UIDecorate.getInputId(component);
         }
  
  
  
  1.6       +3 -2      jboss-seam/src/ui/org/jboss/seam/ui/JSF.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: JSF.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/ui/org/jboss/seam/ui/JSF.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -b -r1.5 -r1.6
  --- JSF.java	5 Mar 2007 20:59:07 -0000	1.5
  +++ JSF.java	18 Mar 2007 04:22:28 -0000	1.6
  @@ -25,8 +25,8 @@
   /**
    * Constant declarations for JSF tags
    * 
  - * @author Anton Koinov (latest modification by $Author: pmuir $)
  - * @version $Revision: 1.5 $ $Date: 2007/03/05 20:59:07 $
  + * @author Anton Koinov (latest modification by $Author: gavin $)
  + * @version $Revision: 1.6 $ $Date: 2007/03/18 04:22:28 $
    */
   public class JSF
   {
  @@ -172,7 +172,8 @@
            if ( child.getRendersChildren() )
            {
               child.encodeChildren(facesContext);
  -         } else
  +         } 
  +         else
            {
               renderChildren(facesContext, child);
            }
  
  
  
  1.14      +20 -212   jboss-seam/src/ui/org/jboss/seam/ui/UIDecorate.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UIDecorate.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/ui/org/jboss/seam/ui/UIDecorate.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- UIDecorate.java	18 Mar 2007 01:31:42 -0000	1.13
  +++ UIDecorate.java	18 Mar 2007 04:22:28 -0000	1.14
  @@ -2,12 +2,11 @@
   
   import java.io.IOException;
   
  -import javax.faces.component.EditableValueHolder;
   import javax.faces.component.UIComponent;
  -import javax.faces.component.UIComponentBase;
   import javax.faces.context.FacesContext;
  +import javax.faces.context.ResponseWriter;
   
  -public class UIDecorate extends UIComponentBase
  +public class UIDecorate extends UIAbstractDecorate
   {
   
      public static final String COMPONENT_TYPE = "org.jboss.seam.ui.UIDecorate";
  @@ -15,95 +14,17 @@
      
      private String forId;
      
  -   protected static UIComponent getDecoration(String name, UIComponent component)
  -   {
  -      UIComponent dec = component.getFacet(name);
  -      if (dec!=null) return dec;
  -      if ( component.getParent()==null ) return null;
  -      return getDecoration( name, component.getParent() );
  -   }
  -   
  -   /**
  -    * 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;
  -   }
  -   
  -   protected static String getInputClientId(UIComponent cmp, FacesContext facesContext)
  -   {
  -      UIComponent input = getInput(cmp, facesContext);
  -      return input == null ? null : input.getClientId(facesContext);
  -   }
  -   
  -   protected 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;
  -      }
  -   }
  -   
  -   protected static UIComponent getInput(UIComponent cmp, FacesContext facesContext)
  -   {
  -      String forId = cmp instanceof UIDecorate ?
  -         ( (UIDecorate) cmp ).getFor() : null;
  -      if (forId==null)
  -      {
  -         UIComponent evh = getEditableValueHolder(cmp);
  -         return evh==null ? null : evh;
  -      }
  -      else
  -      {
  -         UIComponent component = cmp.findComponent(forId);
  -         return component==null ? null : component;
  -      }
  -   }
  -   
  -   protected static boolean hasMessage(UIComponent cmp, FacesContext facesContext)
  -   {
  -      String clientId = getInputClientId(cmp, facesContext);
  -      if (clientId==null)
  -      {
  -         return false;
  -      }
  -      else
  +   @Override
  +   public void startElement(ResponseWriter writer) throws IOException
         {
  -         return facesContext.getMessages(clientId).hasNext();
  -      }
  +      writer.startElement("span", this);
  +      writer.writeAttribute("id", getClientId( getFacesContext() ), "id");
      }
      
  -   protected static boolean hasRequired(UIComponent cmp, FacesContext facesContext)
  -   {
  -      EditableValueHolder evh = (EditableValueHolder) getInput(cmp, facesContext);
  -      if (evh == null)
  -      {
  -         return false;
  -      }
  -      else
  +   @Override
  +   public void endElement(ResponseWriter writer) throws IOException
         {
  -         return evh.isRequired();
  -      }
  +      writer.endElement("span");
      }
   
      @Override
  @@ -112,32 +33,6 @@
         return COMPONENT_FAMILY;
      }
   
  -   protected boolean hasMessage()
  -   {
  -      return hasMessage(this, getFacesContext());
  -   }
  -   
  -   protected boolean hasRequired()
  -   {
  -      return hasRequired(this, getFacesContext());
  -   }
  -
  -   public String getInputId()
  -   {
  -      return getInputId(this);
  -   }
  -   
  -   protected UIComponent getInput()
  -   {
  -      return getInput(this, getFacesContext());
  -   }
  -
  -   @Override
  -   public boolean getRendersChildren()
  -   {
  -      return true;
  -   }
  -
      public String getFor()
      {
         return forId;
  @@ -148,109 +43,16 @@
         this.forId = forId;
      }
   
  -   protected UIComponent getDecoration(String name)
  -   {
  -      return getDecoration(name, this);
  -   }
  -
      @Override
  -   public void encodeBegin(FacesContext context) throws IOException
  +   public void encodeChildren(FacesContext context) throws IOException
      {
  -      super.encodeBegin(context);
  -      context.getResponseWriter().startElement("span", this);
  -      context.getResponseWriter().writeAttribute("id", getClientId(context), "id");
  -      boolean hasMessage = hasMessage();
  -
  -      UIComponent aroundDecoration = getDecoration("aroundField");
  -      UIComponent aroundInvalidDecoration = getDecoration("aroundInvalidField");
  -      UIComponent aroundRequiredDecoration = getDecoration("aroundRequiredField");
  -      if (aroundDecoration!=null && !hasMessage)
  -      {
  -         aroundDecoration.setParent(this);
  -         aroundDecoration.encodeBegin(context);
  -      }
  -      if (aroundInvalidDecoration!=null && hasMessage)
  -      {
  -         aroundInvalidDecoration.setParent(this);
  -         aroundInvalidDecoration.encodeBegin(context);
  -      }
  -      if (aroundRequiredDecoration != null && hasRequired())
  -      {
  -         aroundRequiredDecoration.setParent(this);
  -         aroundRequiredDecoration.encodeBegin(context);
  -      }
  +      renderChildAndDecorations(context, this);
      }
      
      @Override
  -   public void encodeEnd(FacesContext facesContext) throws IOException
  +   protected void renderContent(FacesContext context, UIComponent thiz) throws IOException
      {
  -      boolean hasMessage = hasMessage();
  -      UIComponent aroundDecoration = getDecoration("aroundField");
  -      UIComponent aroundInvalidDecoration = getDecoration("aroundInvalidField");
  -      UIComponent aroundRequiredDecoration = getDecoration("aroundRequiredField");
  -      if (aroundRequiredDecoration != null && hasRequired())
  -      {
  -         aroundRequiredDecoration.setParent(this);
  -         aroundRequiredDecoration.encodeEnd(facesContext);
  -      }
  -      if (aroundDecoration!=null && !hasMessage)
  -      {
  -         aroundDecoration.setParent(this);
  -         aroundDecoration.encodeEnd(facesContext);
  -      }
  -      if (aroundInvalidDecoration!=null && hasMessage)
  -      {
  -         aroundInvalidDecoration.setParent(this);
  -         aroundInvalidDecoration.encodeEnd(facesContext);
  -      }
  -      facesContext.getResponseWriter().endElement("span");
  -      super.encodeEnd(facesContext);
  -   }
  -
  -   @Override
  -   public void encodeChildren(FacesContext facesContext) throws IOException
  -   {
  -      boolean hasMessage = hasMessage();
  -
  -      UIComponent beforeDecoration = getDecoration("beforeField");
  -      UIComponent beforeInvalidDecoration = getDecoration("beforeInvalidField");
  -      UIComponent beforeRequiredDecoration = getDecoration("beforeRequiredField");
  -      if ( beforeDecoration!=null && !hasMessage )
  -      {
  -         beforeDecoration.setParent(this);
  -         JSF.renderChild(facesContext, beforeDecoration);
  -      }
  -      if ( beforeInvalidDecoration!=null && hasMessage )
  -      {
  -         beforeInvalidDecoration.setParent(this);
  -         JSF.renderChild(facesContext, beforeInvalidDecoration);
  -      }
  -      if ( beforeRequiredDecoration!=null && hasRequired() )
  -      {
  -         beforeRequiredDecoration.setParent(this);
  -         JSF.renderChild(facesContext, beforeRequiredDecoration);
  -      }
  -      
  -      JSF.renderChildren(facesContext, this);
  -      
  -      UIComponent afterDecoration = getDecoration("afterField");
  -      UIComponent afterInvalidDecoration = getDecoration("afterInvalidField");
  -      UIComponent afterRequiredDecoration = getDecoration("afterRequiredDecoration");
  -      if ( afterRequiredDecoration!=null && hasRequired() )
  -      {
  -         afterRequiredDecoration.setParent(this);
  -          JSF.renderChild(facesContext, afterRequiredDecoration);
  -      }
  -      if ( afterDecoration!=null  && !hasMessage )
  -      {
  -         afterDecoration.setParent(this);
  -         JSF.renderChild(facesContext, afterDecoration);
  -      }
  -      if ( afterInvalidDecoration!=null && hasMessage )
  -      {
  -         afterInvalidDecoration.setParent(this);
  -         JSF.renderChild(facesContext, afterInvalidDecoration);
  -      }
  +      JSF.renderChildren(context, this);
      }
   
      @Override
  @@ -268,4 +70,10 @@
         return values;
      }
   
  +   @Override
  +   protected void renderChild(FacesContext context, UIComponent thiz) throws IOException
  +   {
  +      renderFieldAndDecorations(context, this);
  +   }
  +
   }
  
  
  
  1.1      date: 2007/03/18 04:22:28;  author: gavin;  state: Exp;jboss-seam/src/ui/org/jboss/seam/ui/UIAbstractDecorate.java
  
  Index: UIAbstractDecorate.java
  ===================================================================
  package org.jboss.seam.ui;
  
  import java.io.IOException;
  
  import javax.faces.component.EditableValueHolder;
  import javax.faces.component.UIComponent;
  import javax.faces.context.FacesContext;
  import javax.faces.context.ResponseWriter;
  
  
  public abstract class UIAbstractDecorate extends UIStyleDecoration
  {
  
     private String labelColumnClass;
     private String fieldColumnClass;
     private String descriptionColumnClass;
     private String messageColumnClass;
  
     protected static UIComponent getDecoration(String name, UIComponent component)
     {
        UIComponent dec = component.getFacet(name);
        if (dec!=null) return dec;
        if ( component.getParent()==null ) return null;
        return getDecoration( name, component.getParent() );
     }
  
     /**
      * 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;
     }
  
     protected static String getInputClientId(UIComponent cmp, FacesContext facesContext)
     {
        UIComponent input = getInput(cmp, facesContext);
        return input == null ? null : input.getClientId(facesContext);
     }
  
     protected 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;
        }
     }
  
     protected static UIComponent getInput(UIComponent cmp, FacesContext facesContext)
     {
        String forId = cmp instanceof UIDecorate ?
           ( (UIDecorate) cmp ).getFor() : null;
        if (forId==null)
        {
           UIComponent evh = getEditableValueHolder(cmp);
           return evh==null ? null : evh;
        }
        else
        {
           UIComponent component = cmp.findComponent(forId);
           return component==null ? null : component;
        }
     }
  
     protected static boolean hasMessage(UIComponent cmp, FacesContext facesContext)
     {
        String clientId = getInputClientId(cmp, facesContext);
        if (clientId==null)
        {
           return false;
        }
        else
        {
           return facesContext.getMessages(clientId).hasNext();
        }
     }
  
     protected static boolean hasRequired(UIComponent cmp, FacesContext facesContext)
     {
        EditableValueHolder evh = (EditableValueHolder) getInput(cmp, facesContext);
        if (evh == null)
        {
           return false;
        }
        else
        {
           return evh.isRequired();
        }
     }
  
     @Override
     public boolean getRendersChildren()
     {
        return true;
     }
     
     protected abstract void renderContent(FacesContext context, UIComponent child) throws IOException;
     protected abstract void renderChild(FacesContext context, UIComponent child) throws IOException;
  
     protected void renderChildAndDecorations(FacesContext context, UIComponent child) throws IOException
     {
        ResponseWriter writer = context.getResponseWriter();
        boolean hasMessage = hasMessage(child, context);
              
        UIComponent label = child.getFacet("label");
        if (label!=null)
        {
           writer.startElement("span", child); 
           writer.writeAttribute("class", labelColumnClass, "labelColumnClass");
           renderLabelAndDecorations(context, label, child);
           writer.endElement("span");
        }
        
        writer.startElement("span", this);
        writer.writeAttribute("class", fieldColumnClass, "fieldColumnClass");
        renderChild(context, child);
        writer.endElement("span");
        
        UIComponent message = getDecoration("message", child);
        if (message!=null && hasMessage)
        {
           message.setParent(child);
           writer.startElement("span", this);
           writer.writeAttribute("class", messageColumnClass, "messageColumnClass");
           JSF.renderChild(context, message);
           writer.endElement("span");
        }
     
        UIComponent description = child.getFacet("description");
        if (description != null)
        {
           writer.startElement("span", this);
           writer.writeAttribute("class", descriptionColumnClass, "descriptionColumnClass");
           JSF.renderChild(context, description);
           writer.endElement("span");
        }
     
     }
  
     protected void renderFieldAndDecorations(FacesContext context, UIComponent child) throws IOException
     {
        boolean hasMessage = hasMessage(child, context);
        boolean hasRequired = hasRequired(child, context);
     
        UIComponent aroundDecoration = getDecoration("aroundField", child);
        UIComponent aroundInvalidDecoration = getDecoration("aroundInvalidField", child);
        UIComponent aroundRequiredDecoration = getDecoration("aroundRequiredField", child);
        if (aroundDecoration!=null && !hasMessage)
        {
           aroundDecoration.setParent(child);
           aroundDecoration.encodeBegin(context);
        }
        if (aroundInvalidDecoration!=null && hasMessage)
        {
           aroundInvalidDecoration.setParent(child);
           aroundInvalidDecoration.encodeBegin(context);
        }
        if (aroundRequiredDecoration!=null && hasRequired)
        {
           aroundRequiredDecoration.setParent(child);
           aroundRequiredDecoration.encodeBegin(context);
        }
        
        UIComponent beforeDecoration = getDecoration("beforeField", child);
        UIComponent beforeInvalidDecoration = getDecoration("beforeInvalidField", child);
        UIComponent beforeRequiredDecoration = getDecoration("beforeRequiredField", child);
        if ( beforeDecoration!=null && !hasMessage )
        {
           beforeDecoration.setParent(child);
           JSF.renderChild(context, beforeDecoration);
        }
        if ( beforeInvalidDecoration!=null && hasMessage )
        {
           beforeInvalidDecoration.setParent(child);
           JSF.renderChild(context, beforeInvalidDecoration);
        }
        if ( beforeRequiredDecoration!=null && hasRequired)
        {
           beforeRequiredDecoration.setParent(child);
           JSF.renderChild(context, beforeRequiredDecoration);
        }
        
        renderContent(context, child);
        
        UIComponent afterDecoration = getDecoration("afterField", child);
        UIComponent afterInvalidDecoration = getDecoration("afterInvalidField", child);
        UIComponent afterRequiredDecoration = getDecoration("afterRequiredField", child);
        if ( afterRequiredDecoration!=null && hasRequired)
        {
           afterRequiredDecoration.setParent(child);
           JSF.renderChild(context, afterRequiredDecoration);
        }
        if ( afterDecoration!=null  && !hasMessage )
        {
           afterDecoration.setParent(child);
           JSF.renderChild(context, afterDecoration);
        }
        if ( afterInvalidDecoration!=null && hasMessage )
        {
           afterInvalidDecoration.setParent(child);
           JSF.renderChild(context, afterInvalidDecoration);
        }
        
        if (aroundRequiredDecoration != null && hasRequired)
        {
           aroundRequiredDecoration.setParent(child);
           aroundRequiredDecoration.encodeEnd(context);
        }
        if (aroundDecoration!=null && !hasMessage)
        {
           aroundDecoration.setParent(child);
           aroundDecoration.encodeEnd(context);
        }
        if (aroundInvalidDecoration!=null && hasMessage)
        {
           aroundInvalidDecoration.setParent(child);
           aroundInvalidDecoration.encodeEnd(context);
        }
     }
  
     private void renderLabelAndDecorations(FacesContext facesContext, UIComponent label, UIComponent child) throws IOException
     {
        ResponseWriter writer = facesContext.getResponseWriter();
        // Write out a label element
        boolean hasMessage = hasMessage(child, facesContext);
        boolean hasRequired = hasRequired(child, facesContext);
        
        UIComponent aroundLabelDecoration = getDecoration("aroundLabel", child);
        UIComponent aroundInvalidLabelDecoration = getDecoration("aroundInvalidLabel", child);
        UIComponent aroundRequiredLabelDecoration = getDecoration("aroundRequiredLabel", child);
        if (aroundLabelDecoration != null && !hasMessage)
        {  
           aroundLabelDecoration.setParent(child);
           aroundLabelDecoration.encodeBegin(facesContext);
        }
        if (aroundInvalidLabelDecoration != null && hasMessage)
        {  
           aroundInvalidLabelDecoration.setParent(child);
           aroundInvalidLabelDecoration.encodeBegin(facesContext);
        }
        if (aroundRequiredLabelDecoration != null && hasRequired)
        {  
           aroundRequiredLabelDecoration.setParent(child);
           aroundRequiredLabelDecoration.encodeBegin(facesContext);
        }
        
        UIComponent beforeLabelDecoration =  getDecoration("beforeLabel", child);
        UIComponent beforeInvalidLabelDecoration =  getDecoration("beforeInvalidLabel", child);
        UIComponent beforeRequiredLabelDecoration =  getDecoration("beforeRequiredLabel", child);
        if (beforeLabelDecoration != null && !hasMessage)
        {  
           beforeLabelDecoration.setParent(child);
           JSF.renderChild(facesContext, beforeLabelDecoration);
        }
        if (beforeInvalidLabelDecoration != null && hasMessage)
        {  
           beforeInvalidLabelDecoration.setParent(child);
           JSF.renderChild(facesContext, beforeInvalidLabelDecoration);
        }
        if (beforeRequiredLabelDecoration != null && hasRequired)
        {  
           beforeRequiredLabelDecoration.setParent(child);
           JSF.renderChild(facesContext, beforeRequiredLabelDecoration);
        }
        
        String inputClientId = getInputClientId(child, facesContext);
        if (inputClientId!=null)
        {
           writer.startElement("label", label);
           writer.writeAttribute("for", inputClientId, "for");
        }
        JSF.renderChild(facesContext, label);
        if (inputClientId!=null)
        {
           writer.endElement("label");
        }
        
        UIComponent afterLabelDecoration = getDecoration("afterLabel", child);
        UIComponent afterInvalidLabelDecoration = getDecoration("afterInvalidLabel", child);
        UIComponent afterRequiredLabelDecoration = getDecoration("afterRequiredLabel", child);
        if (afterRequiredLabelDecoration != null && hasRequired)
        {  
           afterRequiredLabelDecoration.setParent(child);
           JSF.renderChild(facesContext, afterRequiredLabelDecoration);
        }
        if (afterLabelDecoration != null && !hasMessage)
        {  
           afterLabelDecoration.setParent(child);
           JSF.renderChild(facesContext, afterLabelDecoration);
        }
        if (afterInvalidLabelDecoration != null && hasMessage)
        {  
           afterInvalidLabelDecoration.setParent(child);
           JSF.renderChild(facesContext, afterInvalidLabelDecoration);
        }
        
        if (aroundRequiredLabelDecoration != null && hasRequired)
        {  
           aroundRequiredLabelDecoration.setParent(child);
           aroundRequiredLabelDecoration.encodeEnd(facesContext);
        }
        if (aroundLabelDecoration != null && !hasMessage)
        {  
           aroundLabelDecoration.setParent(child);
           aroundLabelDecoration.encodeEnd(facesContext);
        }
        if (aroundInvalidLabelDecoration != null && hasMessage)
        {  
           aroundInvalidLabelDecoration.setParent(child);
           aroundInvalidLabelDecoration.encodeEnd(facesContext);
        }
        
     }
  
     @Override
     public void restoreState(FacesContext context, Object state)
     {
        Object[] array = (Object[]) state;
        super.restoreState(context, array[0]);
        labelColumnClass = (String) array[1];
        fieldColumnClass = (String) array[2];
        descriptionColumnClass = (String) array[3];
        messageColumnClass = (String) array[4];
     }
  
     @Override
     public Object saveState(FacesContext context)
     {
        Object[] state = new Object[5];
        state[0] = super.saveState(context);
        state[1] = labelColumnClass;
        state[2] = fieldColumnClass;
        state[3] = descriptionColumnClass;
        state[4] = messageColumnClass;
        return state;
     }
  
     public String getLabelColumnClass()
     {
        return labelColumnClass;
     }
  
     public void setLabelColumnClass(String leftClass)
     {
        this.labelColumnClass = leftClass;
     }
  
     public String getFieldColumnClass()
     {
        return fieldColumnClass;
     }
  
     public void setFieldColumnClass(String rightClass)
     {
        this.fieldColumnClass = rightClass;
     }
  
     public String getDescriptionColumnClass()
     {
        return descriptionColumnClass;
     }
  
     public void setDescriptionColumnClass(String descriptionColumnClass)
     {
        this.descriptionColumnClass = descriptionColumnClass;
     }
  
     public String getMessageColumnClass()
     {
        return messageColumnClass;
     }
  
     public void setMessageColumnClass(String messageColumnClass)
     {
        this.messageColumnClass = messageColumnClass;
     }
  
  
  }
  
  
  
  1.1      date: 2007/03/18 04:22:28;  author: gavin;  state: Exp;jboss-seam/src/ui/org/jboss/seam/ui/UIDecorateAll.java
  
  Index: UIDecorateAll.java
  ===================================================================
  package org.jboss.seam.ui;
  
  import java.io.IOException;
  
  import javax.faces.component.EditableValueHolder;
  import javax.faces.component.UIComponent;
  import javax.faces.context.FacesContext;
  import javax.faces.context.ResponseWriter;
  
  
  public class UIDecorateAll extends UIAbstractDecorate
  {
     
     public static final String COMPONENT_TYPE = "org.jboss.seam.ui.UIDecorateAll";
     public static final String COMPONENT_FAMILY = "org.jboss.seam.ui.DecorateAll";
     
     private String rowClass;
     private String rowErrorClass;
     
     @Override
     public String getFamily()
     {
        return COMPONENT_FAMILY;
     }
     
     @Override
     public void startElement(ResponseWriter writer) throws IOException
     {
        writer.startElement("div", this);
        writer.writeAttribute("id", getClientId( getFacesContext() ), "id");
     }
  
     @Override
     public void endElement(ResponseWriter writer) throws IOException
     {
        writer.startElement("div", this);
        writer.writeAttribute("style", "clear: both;", null);
        writer.endElement("div");
        writer.endElement("div");
     }
     
     @Override
     public void encodeChildren(FacesContext context) throws IOException
     {
        ResponseWriter writer = context.getResponseWriter();
  
        for (Object child : this.getChildren())
        {
           if (child instanceof UIComponent)
           {
              UIComponent component = (UIComponent) child;
              writer.startElement("div", this);
              String rowClasses = hasMessage(component, context) && rowErrorClass!=null ? 
                       rowClass + ' ' + rowErrorClass : rowClass;
              writer.writeAttribute("class", rowClasses, "rowClass");
              renderChildAndDecorations(context, component);
              writer.endElement("div");
           }
        }
     }
     
     @Override
     protected void renderContent(FacesContext context, UIComponent child) throws IOException
     {
        JSF.renderChild(context, child);
     }
  
     public String getRowClass()
     {
        return rowClass;
     }
  
     public void setRowClass(String rowClass)
     {
        this.rowClass = rowClass;
     }
  
     public String getRowErrorClass()
     {
        return rowErrorClass;
     }
  
     public void setRowErrorClass(String rowErrorClass)
     {
        this.rowErrorClass = rowErrorClass;
     }
  
     @Override
     public void restoreState(FacesContext context, Object state)
     {
        Object[] array = (Object[]) state;
        super.restoreState(context, array[0]);
        rowClass = (String) array[1];
        rowErrorClass = (String) array[2];
     }
  
     @Override
     public Object saveState(FacesContext context)
     {
        Object[] state = new Object[3];
        state[0] = super.saveState(context);
        state[1] = rowClass;
        state[2] = rowErrorClass;
        return state;
     }
  
     @Override
     protected void renderChild(FacesContext context, UIComponent child) throws IOException
     {
        if (child instanceof EditableValueHolder)
        {
           renderFieldAndDecorations(context, child);
        }
        else
        {
           renderContent(context, child);
        }
     }
  
  }
  
  
  



More information about the jboss-cvs-commits mailing list