Search code examples
javajsffacelets

Facelets: need only an <ui:define> tag of a page


Okay, to include a page in another page I need <ui:include src="pageName"/> tag. But if i want to include only a portion of a page?

Let me explain: I have a template that has the tag <ui:insert name="body"/> and other <ui:insert.../> tags. A page, List.xhtml, uses this template and, of course, fills up ALL the template tags. Now, in another page, named Create.xhtml (that uses the same template), at a certain point, i want to put ONLY the body tag content of List.xhtml, not other tags. Is it possible?

Thank you for you answers.


Solution

  • Another way:

    template.xhtml:

    ......
    
    <ui:insert name="body"/>
    
    ......
    

    List.xhtml:

    <ui:composition xmlns=....... template="/template.xhtml">
    
    ..............
    
         <ui:define name="body">
    
              <ui:include src="ListContent.xhtml"/>
    
         </ui:define>
    
    ..............
    
    </ui:composition>
    

    ListContent.xhtml

    <ui:component xmlns....>
    
         Content I can reuse in other pages different by List.xhtml 
         (without see List.xhtml entire content, which is the scope of this question),
         simply writing "<ui:include src="ListContent.xhtml"/>" in the target page code.
    
    </ui:component>
    

    Hope can help someone.