5 Replies Latest reply on Oct 24, 2011 7:57 AM by tschleuss

    Seam 3 s:div tag?

    msahin35

      Does seam 3 has any tag like s:div in seam 2. I have to upgrade my project and I am facing some difficulties about finding the same component in seam 2 and seam 3.

        • 1. Re: Seam 3 s:div tag?
          oranheim

          The s:div tag basically produces a div tag and enables the rendered attribute, so visibility can be turned on/off.


          A replacement tag would be


          <h:panelGroup layout="block">



          Which also produces a div tag and let you control rendered attribute.

          • 2. Re: Seam 3 s:div tag?
            dan.j.allen

            It's also easy to create this using a JSF 2 composite component:


            1. Create the file /resources/htmlx/div.xhtml in your web root and populate it with this content:


            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml"
               xmlns:cc="http://java.sun.com/jsf/composite"
               xmlns:h="http://java.sun.com/jsf/html">
            
            <cc:interface></cc:interface>
            
            <cc:implementation>
               <div><cc:insertChildren/></div>
            </cc:implementation>



            * You may be able to trim some characters in that template, play around with it

            ** I'm naming this library htmlx to mean extra html tags


            2. Now import the namespace into your template and use it:


            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            <html xmlns="http://www.w3.org/1999/xhtml"
              xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:x="http://java.sun.com/jsf/composite/htmlx">
              <h:head>
                <title>Sample page</title>
              </h:head>
              <h:body>
                <x:div>Content in a div</x:div>
              </h:body>
            </html>



            Voila.

            • 3. Re: Seam 3 s:div tag?
              tschleuss

              But, with this, how can i make for example:


              <s:span styleClass="required" rendered="#{required}">
                   <h:outputText value="*" title="Email" />
              </s:span>


              With JSF 2 composite component, how can i implement
              styleClass, redenred condition, etc ??


              I really need s:div and s:span, and others,
              theres any alternative ?


              Thanks!

              • 4. Re: Seam 3 s:div tag?
                piklos


                <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
                <html xmlns="http://www.w3.org/1999/xhtml"
                      xmlns:h="http://java.sun.com/jsf/html"
                      xmlns:f="http://java.sun.com/jsf/core"
                      xmlns:composite="http://java.sun.com/jsf/composite">
                
                    <!-- INTERFACE -->
                    <composite:interface>
                        <composite:attribute name="styleClass" />
                        <composite:attribute name="rendered" />
                    </composite:interface>
                
                    <!-- IMPLEMENTATION -->
                    <composite:implementation>
                       <h:panelGroup rendered="#{cc.attrs.rendered}">
                          <div class="#{cc.attrs.styleClass}"><cc:insertChildren/></div>
                       </h:panelGroup>
                    </composite:implementation>
                </html>



                Try this.

                • 5. Re: Seam 3 s:div tag?
                  tschleuss

                  Thanks, it work.
                  i didn't know this


                  #{cc.attrs....}