7 Replies Latest reply: Dec 29, 2012 1:14 AM by 982080 RSS

    JSF Rendering & Performance

    982080
      Hi,

      I am using the below code snippet to render my pages based on certain conditions

      <h:form>
      <ui:fragment rendered="#{mybean.pageName eq 'CourseType'}">
      <ui:include src="/pages/courseTypePage.xhtml />
      <ui:fragment>
      <ui:fragment rendered="#{mybean.pageName eq 'ContainerType'}">
      <ui:include src="/pages/containerTypePage.xhtml />
      <ui:fragment>
      <ui:fragment rendered="#{mybean.pageName eq 'MenuType'}">
      <ui:include src="/pages/menuTypePage.xhtml />
      <ui:fragment>
      ..........................................................
      ..........................................................
      </h:form>

      I have many pages like this. I wanted to know,

      1. If I use rendered attribute like this, is it a performance hit.Because even if only 1 page is getting rendered, I found it is validating all the pages I have included here when loading the above page. If any invalid code or duplicate id in any of the pages above with rendered attribute value evaluated to false is giving me error.
      2. In the DOM tree, all the pages and its components will be there?

      I tried to build the pageUrl dynamically. but because of some other issues, it is not working fine.

      Can anyone give some light on this. If there is a better approach, could you please suggest.

      Any help will be greatly appreciated.

      Thanks,
      Sreejith
        • 1. Re: JSF Rendering & Performance
          Mriem-Oracle
          Looking at your example you have 3 ui:includes. The following 3 things you need to be aware of when using ui:include.

          1. all ui:include tags is included in the compiled version of the Facelet page.
          2. when using ui:include it becomes your responsibility to make sure those ui:included pages do not have clashing ids.
          3. when rendering the actual content, the resulting HTML page will only contain those components that have rendered set to true.

          So looking at your example I would say you are doing the right thing.
          • 2. Re: JSF Rendering & Performance
            EJP
            Looking at your example you have 3 ui:includes. The following 3 things you need to be aware of when using ui:include.
            Hmm, let's see.
            1. all ui:include tags is included in the compiled version of the Facelet page.
            1. There is no such thing as a 'compiled version of a Facelets page'. Facelets pages are not compiled.
            2. when using ui:include it becomes your responsibility to make sure those ui:included pages do not have clashing ids.
            2. It is always your responsibility to avoid clashing ids, whether using ui:include or not. You can make your life simpler by not using ids at all, or in this case, by wrapping each include in an id-scoping container rather than in a ui:fragment.
            So looking at your example I would say you are doing the right thing.
            I wouldn't.
            • 3. Re: JSF Rendering & Performance
              Mriem-Oracle
              To clarify my comments:

              1. A Facelet pages gets parsed and then it gets put into a Facelets cache (this cache I consider the compiled version of a Facelet page).

              And EJP, if you think he should not be doing it this way please do tell how you would do it. Instead of just saying I wouldn't. Thanks!

              (I think this is taken out of context. I am trying to express that I am here to help not to pass the ultimate judgment on what should be done. If an example can accomplish what they are trying to do I would say it is right, if it would not do that I would say it is wrong).

              Edited by: mojarra on Dec 28, 2012 10:44 PM
              • 4. Re: JSF Rendering & Performance
                gimbal2
                mojarra wrote:
                And EJP, if you think he should not be doing it this way please do tell how you would do it. Instead of just saying I wouldn't. Thanks!
                Please don't tell people what they should be doing, especially when you have only 15 posts to your name. You are not here to determine what is right or wrong, I hope your ego is not that big and you're just making a mistake.
                • 5. Re: JSF Rendering & Performance
                  Mriem-Oracle
                  Please see the edit I did on my 2nd response. I was not trying to state there is only one way of doing something.
                  • 6. Re: JSF Rendering & Performance
                    EJP
                    1. A Facelet pages gets parsed and then it gets put into a Facelets cache (this cache I consider the compiled version of a Facelet page).
                    You can consider it what you like, but there is still no compilation step. JSPs are compiled. Facelets pages are parsed and then interpreted. It isn't the same thing. You don't get anywhere by misusing standard terminology except to create unnecessary confusion.
                    And EJP, if you think he should not be doing it this way please do tell how you would do it. Instead of just saying I wouldn't.
                    I did. I said to use an id-scoping container instead of ui:fragment. You missed it.
                    (I think this is taken out of context. I am trying to express that I am here to help not to pass the ultimate judgment on what should be done. If an example can accomplish what they are trying to do I would say it is right, if it would not do that I would say it is wrong).
                    I must have missed the part where you provided any example at all, let alone one that was right or wrong.
                    • 7. Re: JSF Rendering & Performance
                      982080
                      Hi all,

                      Thanks for all your valued suggestions.

                      Here my requirement is that on click of menuitem, i wanted to dynamically render the page content. Without the use of <ui:fragment>, it is not working fine. Without <ui:fragment> I can see the content gets dynamically changed, but none of the controlls in the page working fine may be due to the reason the entire page not rendered properly. On click of any of the action component, it is giving me error.

                      I am looking for a concrete solution.

                      Thanks ,
                      Sreejith