4 Replies Latest reply on Aug 18, 2011 9:50 AM by florianhell

    Simple Repeating Text

    swenvogel

      Hi,


      how can i simply repeat some contents in an xhtml file like with an ordinary for loop in java?
      ui:repeat and a4j:repeat seams only to work with collections. But i only want to repeat
      the same content. For example



      In Java:


      for(int i = 0; i < 10; ++i) {
       ... output some text ...
      }



      Thanks..




        • 1. Re: Simple Repeating Text
          vata2999

          Have u worked with JSTL ?




          <c:foreach var="i" begin="0" end="10">
              <h:outputText value="#{i}" />
          </c:foreach>



          • 2. Re: Simple Repeating Text
            swenvogel

            I tried it on the following simple page, but the output is empty.


            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
            
            <f:view xmlns="http://www.w3.org/1999/xhtml"
               xmlns:f="http://java.sun.com/jsf/core"
               xmlns:h="http://java.sun.com/jsf/html"
               xmlns:s="http://jboss.com/products/seam/taglib"
               xmlns:c="http://java.sun.com/jsp/jstl/core"
               contentType="text/html">
            
            <html>
              <head>
                <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
              </head>
            
            <body>
              <c:foreach var="i" begin="0" end="10">
                <h:outputText value="#{i}" />
              </c:foreach>
                 
            </body>
            </html>
            </f:view>
            



            • 3. Re: Simple Repeating Text
              swenvogel

              And when i replace


              <h:outputText value="#{i}" />
              



              with


              <h:outputText value="test" />
              



              The output is only ONE test!

              • 4. Re: Simple Repeating Text
                florianhell

                Try it this way...


                <c:forEach var="i" begin="1" end="20" step="1" varStatus ="status">
                <c:out value="${i}" /> 
                </c:forEach>