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

Gavin King gavin.king at jboss.com
Sat Mar 17 01:04:01 EDT 2007


  User: gavin   
  Date: 07/03/17 01:04:01

  Modified:    src/ui/org/jboss/seam/ui   HtmlLayoutForm.java
                        UIDecorate.java
  Log:
  reworked layoutForm to use div/span
  
  Revision  Changes    Path
  1.3       +76 -63    jboss-seam/src/ui/org/jboss/seam/ui/HtmlLayoutForm.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: HtmlLayoutForm.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/ui/org/jboss/seam/ui/HtmlLayoutForm.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -b -r1.2 -r1.3
  --- HtmlLayoutForm.java	16 Mar 2007 00:47:18 -0000	1.2
  +++ HtmlLayoutForm.java	17 Mar 2007 05:04:01 -0000	1.3
  @@ -15,12 +15,14 @@
      @Override
      public String getElement()
      {
  -      return HTML.TABLE_ELEM;
  +      return HTML.DIV_ELEM;
      }
      
      @Override
      public void encodeChildren(FacesContext context) throws IOException
      {
  +      ResponseWriter writer = context.getResponseWriter();
  +      writer.writeAttribute(HTML.STYLE_ATTR, "display: table;", null);
        
         for (Object child : this.getChildren())
         {
  @@ -43,11 +45,40 @@
         UIComponent belowField = child.getFacet("belowField");
         UIComponent belowLabel = child.getFacet("belowLabel");
         
  -      ResponseWriter writer = facesContext.getResponseWriter();
  +      renderChild( facesContext, child, belowField, belowLabel, facesContext.getResponseWriter() );
  +   }
  +
  +   private void renderChild(FacesContext facesContext, UIComponent child, UIComponent belowField, UIComponent belowLabel, ResponseWriter writer) throws IOException
  +   {
  +      writer.startElement(HTML.DIV_ELEM, this);
  +      writer.writeAttribute(HTML.STYLE_ATTR, "display: table-row;", null);
  +      
  +      writer.startElement(HTML.DIV_ELEM, child);
  +      writer.writeAttribute(HTML.STYLE_ATTR, "display: table-cell; vertical-align: top", null);  
  +      writeLabel(facesContext, child);
  +      if (belowLabel != null)
  +      {
  +         writer.startElement(HTML.DIV_ELEM, this);
  +         JSF.renderChild(facesContext, belowLabel);
  +         writer.endElement(HTML.DIV_ELEM);
  +      }
  +      writer.endElement(HTML.DIV_ELEM);
         
  +      writer.startElement(HTML.DIV_ELEM, this);
  +      writer.writeAttribute(HTML.STYLE_ATTR, "display: table-cell;", null);
  +      JSF.renderChild(facesContext, child);
  +      if (belowField != null)
  +      {
  +         writer.startElement(HTML.DIV_ELEM, this);
  +         JSF.renderChild(facesContext, belowField);
  +         writer.endElement(HTML.DIV_ELEM);
  +      }
  +      writer.endElement(HTML.DIV_ELEM);
         
  +      writer.endElement(HTML.DIV_ELEM);
  +   }
   
  -      if (child instanceof UIDecorate)
  +   /*private void renderChild(FacesContext facesContext, UIComponent child, UIComponent belowField, UIComponent belowLabel, ResponseWriter writer) throws IOException
         {     
            writer.startElement(HTML.TR_ELEM, child);
            writer.startElement(HTML.TD_ELEM, child);
  @@ -86,42 +117,21 @@
               }
               writer.endElement(HTML.TR_ELEM);
            }
  -      }
  -      else
  -      {
  -         writer.startElement(HTML.TR_ELEM, this);
  -         writer.startElement(HTML.TD_ELEM, child);
  -         writer.writeAttribute(HTML.COLSPAN_ATTR, "2", HTML.COLSPAN_ATTR);
  -         JSF.renderChild(facesContext, child);
  -         writer.endElement(HTML.TD_ELEM);
  -         writer.endElement(HTML.TR_ELEM);
  -         if (belowField != null)
  -         {
  -            writer.startElement(HTML.TD_ELEM, belowField);
  -            writer.writeAttribute(HTML.COLSPAN_ATTR, "2", HTML.COLSPAN_ATTR);
  -            JSF.renderChild(facesContext, belowField);
  -            writer.endElement(HTML.TD_ELEM);
  -         }
  -      }
  -   }
  +   }*/
      
  -   private void writeLabel(FacesContext facesContext, UIDecorate child) throws IOException
  +   private void writeLabel(FacesContext facesContext, UIComponent child) throws IOException
      {
         ResponseWriter writer = facesContext.getResponseWriter();
  -      
         // Write out a label element
         UIComponent label = child.getFacet("label");
         if (label != null)
         {
  -         writer.startElement(HTML.LABEL_ELEM, label);
  -         writer.writeAttribute(HTML.FOR_ATTR, child.getInput().getClientId(facesContext), HTML.FOR_ATTR);
  +         boolean hasMessage = UIDecorate.hasMessage(child, facesContext);
  +         boolean hasRequired = UIDecorate.hasRequired(child, facesContext);
            
  -         boolean hasMessage = child.hasMessage();
  -         boolean hasRequired = child.hasRequired();
  -         
  -         UIComponent aroundLabelDecoration = child.getDecoration("aroundLabel");
  -         UIComponent aroundInvalidLabelDecoration = child.getDecoration("aroundInvalidLabel");
  -         UIComponent aroundRequiredLabelDecoration = child.getDecoration("aroundRequiredLabel");
  +         UIComponent aroundLabelDecoration = UIDecorate.getDecoration("aroundLabel", child);
  +         UIComponent aroundInvalidLabelDecoration = UIDecorate.getDecoration("aroundInvalidLabel", child);
  +         UIComponent aroundRequiredLabelDecoration = UIDecorate.getDecoration("aroundRequiredLabel", child);
            if (aroundLabelDecoration != null && !hasMessage)
            {  
               aroundLabelDecoration.setParent(child);
  @@ -138,9 +148,9 @@
               aroundRequiredLabelDecoration.encodeBegin(facesContext);
            }
            
  -         UIComponent beforeLabelDecoration =  child.getDecoration("beforeLabel");
  -         UIComponent beforeInvalidLabelDecoration =  child.getDecoration("beforeInvalidLabel");
  -         UIComponent beforeRequiredLabelDecoration =  child.getDecoration("beforeRequiredLabel");
  +         UIComponent beforeLabelDecoration =  UIDecorate.getDecoration("beforeLabel", child);
  +         UIComponent beforeInvalidLabelDecoration =  UIDecorate.getDecoration("beforeInvalidLabel", child);
  +         UIComponent beforeRequiredLabelDecoration =  UIDecorate.getDecoration("beforeRequiredLabel", child);
            if (beforeLabelDecoration != null && !hasMessage)
            {  
               beforeLabelDecoration.setParent(child);
  @@ -157,7 +167,10 @@
               JSF.renderChild(facesContext, beforeRequiredLabelDecoration);
            }
            
  +         writer.startElement(HTML.LABEL_ELEM, label);
  +         writer.writeAttribute(HTML.FOR_ATTR, UIDecorate.getInputClientId(child, facesContext), HTML.FOR_ATTR);         
            JSF.renderChild(facesContext, label);
  +         writer.endElement(HTML.LABEL_ELEM);
            
            UIComponent afterLabelDecoration = UIDecorate.getDecoration("afterLabel", child);
            UIComponent afterInvalidLabelDecoration = UIDecorate.getDecoration("afterInvalidLabel", child);
  
  
  
  1.11      +16 -12    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.10
  retrieving revision 1.11
  diff -u -b -r1.10 -r1.11
  --- UIDecorate.java	16 Mar 2007 00:47:18 -0000	1.10
  +++ UIDecorate.java	17 Mar 2007 05:04:01 -0000	1.11
  @@ -47,8 +47,10 @@
         return null;
      }
      
  -   protected static String getInputId(String forId, UIComponent cmp)
  +   protected static String getInputId(UIComponent cmp)
      {
  +      String forId = cmp instanceof UIDecorate ?
  +               ( (UIDecorate) cmp ).getFor() : null;
         if (forId==null)
         {
            UIComponent evh = getEditableValueHolder(cmp);
  @@ -60,14 +62,16 @@
         }
      }
      
  -   protected static String getInputClientId(String forId, UIComponent cmp, FacesContext facesContext)
  +   protected static String getInputClientId(UIComponent cmp, FacesContext facesContext)
      {
  -      UIComponent input = getInput(forId, cmp, facesContext);
  +      UIComponent input = getInput(cmp, facesContext);
         return input == null ? null : input.getClientId(facesContext);
      }
      
  -   protected static UIComponent getInput(String forId, UIComponent cmp, FacesContext facesContext)
  +   protected static UIComponent getInput(UIComponent cmp, FacesContext facesContext)
      {
  +      String forId = cmp instanceof UIDecorate ?
  +         ( (UIDecorate) cmp ).getFor() : null;
         if (forId==null)
         {
            UIComponent evh = getEditableValueHolder(cmp);
  @@ -80,9 +84,9 @@
         }
      }
      
  -   protected static boolean hasMessage(String forId, UIComponent cmp, FacesContext facesContext)
  +   protected static boolean hasMessage(UIComponent cmp, FacesContext facesContext)
      {
  -      String clientId = getInputClientId(forId, cmp, facesContext);
  +      String clientId = getInputClientId(cmp, facesContext);
         if (clientId==null)
         {
            return false;
  @@ -93,9 +97,9 @@
         }
      }
      
  -   protected static boolean hasRequired(String forId, UIComponent cmp, FacesContext facesContext)
  +   protected static boolean hasRequired(UIComponent cmp, FacesContext facesContext)
      {
  -      EditableValueHolder evh = (EditableValueHolder) getInput(forId, cmp, facesContext);
  +      EditableValueHolder evh = (EditableValueHolder) getInput(cmp, facesContext);
         if (evh == null)
         {
            return false;
  @@ -114,22 +118,22 @@
   
      protected boolean hasMessage()
      {
  -      return hasMessage(getFor(), this, getFacesContext());
  +      return hasMessage(this, getFacesContext());
      }
      
      protected boolean hasRequired()
      {
  -      return hasRequired(getFor(), this, getFacesContext());
  +      return hasRequired(this, getFacesContext());
      }
   
      public String getInputId()
      {
  -      return getInputId(getFor(), this);
  +      return getInputId(this);
      }
      
      protected UIComponent getInput()
      {
  -      return getInput(getFor(), this, getFacesContext());
  +      return getInput(this, getFacesContext());
      }
   
      @Override
  
  
  



More information about the jboss-cvs-commits mailing list