9 Replies Latest reply on Oct 31, 2006 1:16 PM by gavin.king

    Use of @Out with JSTL/ui:include

    ekusnitz

      I have the following situation which seams to defy explanation:

      In my xhtml page, I have this:
      <c:if test="#{!MyBean.newObject}">
      <ui:include src="/pages/Details.xhtml" />
      </c:if>
      <c:if test="#{MyBean.newObject}">
      <ui:include src="/pages/Choose.xhtml" />
      </c:if>

      This works. However, if I outject the newObject variable instead and change the condition to test="#{newObject}", etc., it does the opposite of expected. But I can see the variable appearing correctly in the context. That is, I add
      newObject:<h:outputText value="#{newObject}"/>

      to the page to see the current value. This renders as expected, but the <c:if> logic follows the branch when the value is false and ignores it when it is true! Can anyone explain this?

      I also tried using the rendered attribute for <ui:include> but that seemed to be ignored in all cases -- traditional jstl or outjection. I read somewhere that this wasn't supported?

        • 1. Re: Use of @Out with JSTL/ui:include
          ekusnitz

          Forget to add:
          We are using JBoss4.0.5GA
          JBoss Portal 2.4.1-CR1
          myfaces-1.1.4

          • 2. Re: Use of @Out with JSTL/ui:include

            Hello!

            I would guess that MyBean is in request scope and newObject is not. That's why it is not acessible.

            I don't think it is a very good idea anyway to mix JSTL and JSF in that way anyway. I would recommend you to use the facelets stuff instead.

            Regards

            fhh

            • 3. Re: Use of @Out with JSTL/ui:include
              pmuir

              https://facelets.dev.java.net/nonav/docs/dev/docbook.html#template-include - you're right rendered isn't an attribute on ui:include but its easy to get around - simply include it in a grouping component which does have a rendered attribute.

              <h:panelGroup rendered="#{myCondition}">
               <ui:include src="myPage.xhtml" />
               </h:panelGroup>


              • 4. Re: Use of @Out with JSTL/ui:include
                ekusnitz

                Thank you for your replies. With regard to the scope,
                I had tried it several ways, but predominantly like this:
                @Out(required=false)
                private boolean newObject;

                What is the default scope for outjection? I couldn't find it in the docs. Furthermore, why wouldn't the expression find it in any scope? And, most important, why it is seen with the h:output and not c:f? I suppose the problem is, like you say, mixing JSF and JSTL. Similar code has worked for us, but I guess, the results are unpredictable, as many say.

                I will try wrapping the ui:include in an h:panelGroup. I just wonder why the attribute is not supported. I thought all decendants of ui:component supported it.

                I am really mostly concerned with how these things work, rather than just what works and what doesn't.

                • 5. Re: Use of @Out with JSTL/ui:include
                  ekusnitz

                  Ugh, this is getting really strange. As suggested, I changed my code to the following (note use of 'preNewObject' instead of 'newObject')

                  <h:panelGroup rendered="#{!preNewObject}">
                  <ui:include src="/pages/admin/Node/NodeDetails.xhtml" />
                  </h:panelGroup>
                  <h:panelGroup rendered="#{preNewObject}">
                  <ui:include src="/pages/admin/Node/ChooseNodeType.xhtml" />
                  </h:panelGroup>

                  It starts to work. It starts with the NodeDetails page because preNewObject is set to false. When the user chooses to create a new object, it's set to true, and the ChooseNodeType page loads correctly. Now, here's the weird thing. The OK button on that page -- whose action is 'newObject' -- stops working! The action is never called. I have a feeling there's a bug here somewhere. How best to proceed?

                  • 6. Re: Use of @Out with JSTL/ui:include
                    gavin.king

                    Well, unless you think that this somehow has something to do with Seam, wouldn't it be better to proceed by asking in a facelets/myfaces forum?

                    • 7. Re: Use of @Out with JSTL/ui:include
                      pmuir

                       

                      "ekusnitz" wrote:
                      I will try wrapping the ui:include in an h:panelGroup. I just wonder why the attribute is not supported. I thought all decendants of ui:component supported it.


                      Ah. ui:component != UIComponent

                      • 8. Re: Use of @Out with JSTL/ui:include
                        ekusnitz

                        Sorry, Gavin. It started out in Seam, but I guess now it belongs in facelets.

                        • 9. Re: Use of @Out with JSTL/ui:include
                          gavin.king

                          NP, I'm just trying to help you get a useful answer, rather than talking to yourself :)