6 Replies Latest reply on Jun 10, 2007 3:54 PM by fhh

    <s:decorate /> with template property?

      Hi!

      I am trying to use the template property of <s:decorate /> (instead of facets) in Seam 1.2.1 .GA but it doesn't work for me. The <ui:insert /> in the decorateField.xhtml does not only insert the input child of <s:decorate /> but the whole page (which is in a <ui:define /> because it uses a page template).

      If I explicilty define

      <ui:define name="input"><h:inputText value="#{mitgliedHome.instance.name}" required="true"/></ui:define>

      and ajust the decorateField.xhtml file it works. Is this a mistake in the documentation or am I missing something?

      Regards

      Felix

      P.S.: facelets 1.1.11 / JSF RI 1.2

        • 1. Re: <s:decorate /> with template property?
          gavin.king

          You should not need to do that. Look at the examples.

          • 2. Re: <s:decorate /> with template property?

            Otherwise it doesn't work. It will insert the body of the page I defined and not just the input.

            It seems like a bug to me. I will post the code once I am at home.

            Regards

            Felix

            • 3. Re: <s:decorate /> with template property?

              Here's the code of the form:

              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
              <ui:composition xmlns="http://www.w3.org/1999/xhtml"
               xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:f="http://java.sun.com/jsf/core"
               xmlns:h="http://java.sun.com/jsf/html"
               xmlns:c="http://java.sun.com/jstl/core"
               xmlns:s="http://jboss.com/products/seam/taglib"
               xmlns:rich="http://richfaces.ajax4jsf.org/rich"
               template="/WEB-INF/templates/standard.xhtml">
              
               <ui:define name="title">Title</ui:define>
              
               <ui:define name="body">
              <h:form>
               <rich:toolBar height="26" itemSeparator="line">
              
               <rich:toolBarGroup rendered="#{not mitgliedHome.managed}">
               <h:commandLink action="#{mitgliedHome.persist}"><h:graphicImage value="/images/button_ok.png" /><h:outputText value="Save" /></h:commandLink>
               </rich:toolBarGroup>
              
               </rich:toolBar>
              
               <h:messages globalOnly="true"/>
              
               <s:decorate template="decorateField.xhtml">
               <ui:define name="label">Username:</ui:define>
               <h:inputText value="#{userHome.instance.name}" required="true"/>
               </s:decorate>
              
               </h:form>
              
               </ui:define>
              
               </ui:composition>
              
              


              And the decorateField.xhtml:

              
              <ui:composition xmlns="http://www.w3.org/1999/xhtml"
               xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:h="http://java.sun.com/jsf/html"
               xmlns:f="http://java.sun.com/jsf/core"
               xmlns:s="http://jboss.com/products/seam/taglib">
              
               <div>
              
               <s:label styleClass="#{invalid?'error':''}">
               <ui:insert name="label"/>
               <s:span styleClass="required" rendered="#{required}">*</s:span>
               </s:label>
              
               <span class="#{invalid?'error':''}">
               <!-- <h:graphicImage src="img/error.gif" rendered="#{invalid}"/> -->
               <s:validateAll>
               <ui:insert />
               </s:validateAll>
               </span>
              
               <s:message styleClass="error"/>
              
               </div>
              
              </ui:composition>
              


              The result looks like this:
              http://felix.dyndns.tv/static/s-decorate-error.png

              Regards

              Felix

              • 4. Re: <s:decorate /> with template property?
                dan.j.allen

                Actually, this concern is legitimate. I can confirm that both of you are correct. If you run the seam examples, they work perfectly. If you use your own setup with jsf-facelets-1.1.11.jar, then you get an error when trying to use the bare <ui:insert />. Apparently, seam has a modified (or just alternate) version of Facelets other than the latest stable 1.1.11 version.

                Does anyone know which version of facelets is bundled with Seam? I can assure you that if you take the jsf-facelets-1.1.11.jar file and put it into the seam distribution, the examples using s:decorate with templates will not work.

                • 5. Re: <s:decorate /> with template property?
                  gavin.king

                  It's easy to see which version we have using fisheye:

                  http://fisheye.jboss.com/browse/JBoss/jboss-seam/lib/jsf-facelets.jar

                  ie. it is a version of 1.1.12 with a special bug fix for ui:decorate.

                  So if you're using some other version of facelets other than the one we recommend, its hardly surprising that you run into problems...

                  • 6. Re: <s:decorate /> with template property?

                    Okay, thanks for the information. I use maven and used simply the latest available version.

                    Could you add a hint to the documentation? I think quite a lot of people might bump into this.

                    Regards

                    Felix