2 Replies Latest reply on Feb 28, 2008 7:48 PM by pete007

    Problem with h:graphicImage and rendered-attribute

      Hi, its me again. I have a problem with using the rendered attribute. In my template.xhtml i got the following lines:


      <td>
        <ui:insert name="content" rendered="#{content!=null}"/>
        <h:graphicImage value="../images/layout/no_content.png" rendered="#{content==null}"/>
      </td>



      and I call them in my forms with:


      <ui:define name="content">
        .. some stuff ..
      <ui:define>



      My problem is, that the no-content-image always appears in my output, no matter if there is a content or not.


      I also tried rendered="#{empty content}", but this didn't work too.


      Is my syntax right? Can h:graphicImage by used with the rendered attribute?

        • 1. Re: Problem with h:graphicImage and rendered-attribute
          keithnaas

          What does

          #{content}

          evaluate to?  a String, a bean, a list?


          If its a String is it possibly an empty string?


          Also, I would recommend using

          #{empty content}

          and
          #{not empty content}



          'empty' checks to see if its null or empty (e.g., instance list, array or string).


          null just seems so dirty in the view :)

          • 2. Re: Problem with h:graphicImage and rendered-attribute

            empty still doesn't work, I used it like this:


            <ui:insert name="content" rendered="#{not empty content}"/>
            <h:graphicImage value="../images/layout/no_content.png" rendered="#{empty content}"/>



            I think it gets evaluated to a String, but I'm not sure, how can I check this? Here's the definition if it helps in any way:


            <ui:define name="content">
              <h:form id="routerForm">
                <table>
                  <tr>
                    <td>
                      <h:graphicImage value="../images/floors/empty.png" rendered="#{router.startImage==null}"/>
                      <h:graphicImage value="../images/#{router.startImage}" rendered="#{router.startImage!=null}"/>
                    </td>
                    <td>
                      <h:graphicImage value="../images/floors/empty.png" rendered="#{router.endImage==null}"/>
                      <h:graphicImage value="../images/#{router.endImage}" rendered="#{router.endImage!=null}"/>
                    </td>
                  </tr>
                </table>
              </h:form>
            </ui:define>



            Yeah, I know, I should use empty here too. ;)