4 Replies Latest reply on Nov 5, 2007 7:16 PM by Samuel Doyle

    JSTL Test Boolean Question

    Samuel Doyle Apprentice

      I'm not sure why it doesn't appear to work or if I am doing something incorrectly.

      Here is basically what I have.

      <rich:column>
       <c:choose>
       <c:when test="${sop.isRequired}">
       <h:outputText value="#{sop.name}" style="color:#ff0000" />
       </c:when>
       <c:otherwise>
       <h:outputText value="#{sop.name}" />
       </c:otherwise>
       </c:choose>
      </rich:column>
      


      With this I never see the style applied and just the standard text output.

      If I change:
      <c:when test="${sop.isRequired}">
      to
      <c:when test="${true}">
      


      The style is applied. I know that the values are correct for the isRequired field since when I just ouput the value such as:
      <h:outputText value="#{sop.isRequired}" style="color:#ff0000" />
      

      I will see the mix of true and false values rendered.

      Thanks, S.D.

        • 1. Re: JSTL Test Boolean Question
          Dustin Norlander Apprentice

          Not sure if this is your problem, but have you tried this?

          <c:when test="#{sop.isRequired}">
          


          -Dustin

          • 2. Re: JSTL Test Boolean Question
            Samuel Doyle Apprentice

             

            "dustismo" wrote:
            Not sure if this is your problem, but have you tried this?

            <c:when test="#{sop.isRequired}">
            


            -Dustin


            Yep tried that as well to no avail.

            • 3. Re: JSTL Test Boolean Question
              Matt Drees Master

              c:when is evaluated when the component tree is created (typically right at the beginning of the renderResponse phase). It's used to determine which components get added to the tree. I'm guessing you want the decision to be made later, for each row. So you actually want both components added to the tree, but you only want one or the other rendered for any given row.

              So, you probably want something like this:

              <rich:column>
               <h:outputText value="#{sop.name}" style="color:#ff0000" rendered="#{sop.isRequired}"/>
               <h:outputText value="#{sop.name}" rendered="#{not sop.isRequired}"/>
              </rich:column>
              


              • 4. Re: JSTL Test Boolean Question
                Samuel Doyle Apprentice

                Excellent and thanks, that did the trick.

                S.D.

                "matt.drees" wrote:
                c:when is evaluated when the component tree is created (typically right at the beginning of the renderResponse phase). It's used to determine which components get added to the tree. I'm guessing you want the decision to be made later, for each row. So you actually want both components added to the tree, but you only want one or the other rendered for any given row.

                So, you probably want something like this:
                <rich:column>
                 <h:outputText value="#{sop.name}" style="color:#ff0000" rendered="#{sop.isRequired}"/>
                 <h:outputText value="#{sop.name}" rendered="#{not sop.isRequired}"/>
                </rich:column>