9 Replies Latest reply on Oct 8, 2007 11:14 AM by damianharvey

    s:decorate changed to use DIV instead of SPAN

    damianharvey

      Just upgraded from Seam 1.3.0.ALPHA to 2.0.0.CR1 and have found out that s:decorate now wraps the template code in a div rather than a span.

      I have a large number of forms with inline fields (ie. several on the same line) and a template "edit_inline". This ruins all of that as the div forces each to a new line. I can't even set the decorate tag to have style="display:inline;" as the style is not propagated to the div.

      Can anyone think of any suggestions to remedy this? Why was this changed? What was wrong with using a span? At least with a span you had the option of forcing a line break after it if you wanted to have one field per line.

      Thanks,

      Damian.

        • 1. Re: s:decorate changed to use DIV instead of SPAN
          christian.bauer

          ?! s:decorate doesn't render anything. It decorates a template. You can customize/create that template.

          • 2. Re: s:decorate changed to use DIV instead of SPAN
            damianharvey

            Sorry but it does. Look at the pagesource.

            From UIDecorate.java under Seam 1.3:

             @Override
             public void encodeBegin(FacesContext context) throws IOException
             {
             super.encodeBegin(context);
            
             Contexts.getEventContext().set("invalid", hasMessage(this, context));
             Contexts.getEventContext().set("required", hasRequired(this, context));
            
             context.getResponseWriter().startElement("span", this);
             context.getResponseWriter().writeAttribute("id", getClientId(context), "id");
            


            And then in DecorateRendererBase (split out from UIDecorate) from Seam 2.0:
            
             @Override
             protected void doEncodeBegin(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException
             {
             UIDecorate decorate = (UIDecorate) component;
            
             Contexts.getEventContext().set("invalid", Decoration.hasMessage(decorate, context));
             Contexts.getEventContext().set("required", Decoration.hasRequired(component, context));
            
             boolean hasMessage = decorate.hasMessage();
            
             writer.startElement("div", decorate);
             writer.writeAttribute("id", decorate.getClientId(context), "id");
            



            • 3. Re: s:decorate changed to use DIV instead of SPAN
              pmuir

               

              "damianharvey" wrote:
              Can anyone think of any suggestions to remedy this?


              http://jira.jboss.com/jira/browse/JBSEAM-1572

              Why was this changed? What was wrong with using a span?


              It's not valid html to nest div's inside spans hence inflexible.

              • 4. Re: s:decorate changed to use DIV instead of SPAN
                damianharvey

                 

                "pete.muir@jboss.org" wrote:
                http://jira.jboss.com/jira/browse/JBSEAM-1572

                I'm not sure what the solution proposed there involves? Is it to move the field value out of the decorate and use the "for" attribute? Or to use ui:decorate?

                It's not valid html to nest div's inside spans hence inflexible.

                I think it's a moot point about being inflexible as the current situation is obviously inflexible as well. IMHO I think that span is more flexible. If someone is worried about valid HTML then they shouldn't use a div in their template. At least this way they can style the span in their template to resemble a div (ie. display=block, etc). I can't do anything to style this div to look like a span.

                Thanks,

                Damian.

                • 5. Re: s:decorate changed to use DIV instead of SPAN
                  pmuir

                  There is no solution unless the FR described (by me) in that issue gets implemented. You could file a issue asking for the ability to style the s:decorate's div.

                  At least this way they can style the span in their template to resemble a div (ie. display=block, etc)


                  No, because it's not valid to nest block level components in inline components.

                  • 6. Re: s:decorate changed to use DIV instead of SPAN
                    damianharvey

                    One option could be to use the approach that the Richfaces guys have followed (eg. in the a4j:outputPanel) and have an attribute called layout that can be set to 'block' or 'inline'.

                    From the outputPanel documentation:


                    HTML layout for generated markup. Possible values: "block" for generating an HTML div element, "inline" for generating an HTML span element, and "none" for generating no HTML element. There is a minor exception for the "none" case where a child element has the property "rendered" set to "false". In this case, we create an empty span element with same ID as the child element to use as a placeholder for later processing.


                    Setting it to "none" would also partially address the issue in JBSEAM-1572.

                    Thanks,

                    Damian.

                    • 7. Re: s:decorate changed to use DIV instead of SPAN
                      damianharvey

                      I've raised a JIRA to allow for the styling of the decorate. http://jira.jboss.com/jira/browse/JBSEAM-2065.

                      I'll change the DecorateRendererBase myself and manually build as I have no other option and certainly can't use it as it is.

                      Pete, do you think that styling the DIV is the best way forward or is the "layout" option (as per Richfaces) feasible?

                      Thanks,

                      Damian.

                      • 8. Re: s:decorate changed to use DIV instead of SPAN
                        pmuir

                         

                        "damianharvey" wrote:
                        I've raised a JIRA to allow for the styling of the decorate. http://jira.jboss.com/jira/browse/JBSEAM-2065.


                        I'll get this fixed for the GA as it's almost a bug and necessary ;)

                        Pete, do you think that styling the DIV is the best way forward or is the "layout" option (as per Richfaces) feasible?


                        I would like to see both options available. I've scheduled the layout option for 2.0.1 (if you do the patch yourself, feel free to attach it to the issue :) )

                        • 9. Re: s:decorate changed to use DIV instead of SPAN
                          damianharvey

                          Cheers Pete. Much appreciated.

                          I'll have a go myself and put the patch up for your inspection/amusement.

                          Thanks,

                          Damian.