1 Reply Latest reply on Feb 26, 2008 1:37 PM by Pete Muir

    The s:decorate tag rendering custom tag instead of just div

    Matija Gaspar Newbie

      I had a problem with s:decorate rendering div in my html which was suposed to have the element li at that place. I like to have a clean html and not too many nested elements so the div s:decorate was rendering didnt suit me. I looked on google and on this formus and i didnt find a solution, so I changed source that s:decorate accepts renderTag attribute (ex.: <s:decorate renderTag="li"></s:decorate> is renderdered with tag <li></li>).


      Here im posting the diff and it would be great if u include this or something similar into the trunk.


      diff -ur jboss-seam-2.0.1.CR1/ui/src/main/config/component/decorate.xml Copy of jboss-seam-2.0.1.CR1/ui/src/main/config/component/decorate.xml
      --- jboss-seam-2.0.1.CR1/ui/src/main/config/component/decorate.xml      2008-02-25 14:41:00.578125000 +0100
      +++ Copy of jboss-seam-2.0.1.CR1/ui/src/main/config/component/decorate.xml      2008-02-25 10:41:37.046875000 +0100
      @@ -41,6 +41,12 @@
                      <description></description>
                  </property>
       
      +        <property exist="true">
      +               <name>renderTag</name>
      +               <classname>java.lang.String</classname>
      +               <description></description>
      +           </property>
      +
           </component>
           
       </components>
      diff -ur jboss-seam-2.0.1.CR1/ui/src/main/java/org/jboss/seam/ui/component/UIDecorate.java Copy of jboss-seam-2.0.1.CR1/ui/src/main/java/org/jboss/seam/ui/component/UIDecorate.java
      --- jboss-seam-2.0.1.CR1/ui/src/main/java/org/jboss/seam/ui/component/UIDecorate.java   2008-02-25 14:21:29.984375000 +0100
      +++ Copy of jboss-seam-2.0.1.CR1/ui/src/main/java/org/jboss/seam/ui/component/UIDecorate.java   2008-02-25 14:17:42.750000000 +0100
      @@ -73,6 +73,10 @@
       
          public abstract void setStyle(String style);
       
      +   public abstract void setRenderTag(String RenderTag);
      +
      +   public abstract String getRenderTag();
      +
       
          public UIComponent getDecoration(String name)
          {
      diff -ur jboss-seam-2.0.1.CR1/ui/src/main/java/org/jboss/seam/ui/renderkit/DecorateRendererBase.java Copy of jboss-seam-2.0.1.CR1/ui/src/main/java/org/jboss/seam/ui/renderkit/DecorateRendererBase.java
      --- jboss-seam-2.0.1.CR1/ui/src/main/java/org/jboss/seam/ui/renderkit/DecorateRendererBase.java 2008-02-25 14:21:29.984375000 +0100
      +++ Copy of jboss-seam-2.0.1.CR1/ui/src/main/java/org/jboss/seam/ui/renderkit/DecorateRendererBase.java 2008-02-25 14:17:42.765625000 +0100
      @@ -32,7 +32,9 @@
       
             boolean hasMessage = decorate.hasMessage();
       
      -      writer.startElement("div", decorate);
      +      String startTag =  decorate.getRenderTag()==null ? "div" : decorate.getRenderTag();
      +
      +      writer.startElement(startTag, decorate);
             if (decorate.getStyleClass() != null)
             {
                 writer.writeAttribute(HTML.STYLE_CLASS_ATTR, decorate.getStyleClass(), HTML.STYLE_CLASS_ATTR);
      @@ -65,6 +67,9 @@
             boolean hasMessage = decorate.hasMessage();
             UIComponent aroundDecoration = decorate.getDecoration("aroundField");
             UIComponent aroundInvalidDecoration = decorate.getDecoration("aroundInvalidField");
      +
      +      String endTag =  decorate.getRenderTag()==null ? "div" : decorate.getRenderTag();
      +
             if (aroundDecoration!=null && !hasMessage)
             {
                aroundDecoration.setParent(decorate);
      @@ -75,7 +80,7 @@
                aroundInvalidDecoration.setParent(decorate);
                aroundInvalidDecoration.encodeEnd(context);
             }
      -      context.getResponseWriter().endElement("div");
      +      context.getResponseWriter().endElement(endTag);
       
             Contexts.getEventContext().remove("invalid");
             Contexts.getEventContext().remove("required");