0 Replies Latest reply on Jan 12, 2010 10:12 PM by Anil Erukala

    If else equivalent in facelets

    Anil Erukala Newbie
      I want to implement if else feature in facelets without calling my backing bean method twice. I am using facelets, JSF, and Seam 2.1.2GA. I do not want to use JSTL tags in my facelets because JSTL tags won't follow the JSF lifecycle. Here is my code.

      `<ui:fragment rendered="#{backingBean.aMethod() eq 'true'}
         display something
      </ui:fragment>
      <ui:fragment rendered="#{backingBean.aMethod() eq 'false'}
         display some other thing
      </ui:fragment>
      `

      But the problem with aMethod() in my backingBean called twice. I don't want to call that method twice. Most of the time those methods have lot of business logic. I tried using ui:param like this.

      `
      <ui:param name="returnedValue" value="#{backingBean.aMethod()}" />
      <ui:fragment rendered="#{returnedValue eq 'true'}
         display something
      </ui:fragment>
      <ui:fragment rendered="#{returnedValue eq 'false'}
         display some other thing
      </ui:fragment>
      `
      But even in this case also aMethod() called twice because returnedValue is not storing the result of #{backingBean.aMethod()}. My backing beans are EVENT or PAGE scoped seam components. Please suggest a way to implement the above scenario without calling the backing bean method twice.

      Thanks,
      Anil