0

It's possible to do next by jsf facelets?

I want to extend reusable.xhtml with additional html columns

reusable.xhtml

<ui:composition> <table class="table table-striped table-hover table-condensed"> <thead> <tr> <ui:insert name="additional_headers"></ui:insert> </tr> </thead> <tbody> <c:forEach items="${beanChooser.chosenBean.entitiesToShow}" var="item"> <tr id="#{beanChooser.chosenBean.shortEntityName.toLowerCase()}${item.id}"> <td> </td> <td> </td> <ui:insert name="additional_columns"></ui:insert> </tr> </c:forEach> </tbody> </table> </ui:composition> <html> <ui:composition template="/masterTemplate.xhtml" ...> <ui:define name="content"> <ui:include src="../reusable.xhtml"> <ui:define name="additional_columns"> <td> Additional EL Expression </td> </ui:define> <ui:define name="additional_headers"> <th> STATIC </th> </ui:define> </ui:include> </ui:define> </ui:composition> </html> 

if it's not impossible, what is the best practice to achieve this?

1 Answer 1

3

I think what you need is <ui:decorate> instead of <ui:include> (check out the <!-- HERE --> markers):

<ui:composition template="/masterTemplate.xhtml" ...> <ui:define name="content"> <ui:decorate template="../reusable.xhtml"><!-- HERE --> <ui:define name="additional_columns"> <td> Additional EL Expression </td> </ui:define> <ui:define name="additional_headers"> <th> STATIC </th> </ui:define> </ui:decorate> <!-- HERE --> </ui:define> </ui:composition> 
Sign up to request clarification or add additional context in comments.

2 Comments

it's possible to use ${item.field} inside define, in case when reusable.xhtml contains <c:forEach items=".." var="item"> ?
You mean something like <ui:define name="...">${item.field}</ui:define>? I.e. the ${item.field} unwrapped inside it? I do not remeber, but if not, you can always wrap it in a <h:outputText>.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.