1

My problem is a little bit complex, but I'll give an example.

I already have a user.xhtml page (and a MB that uses it) where I register an user

<p:outputLabel value="Name:" /> <h:outputText value="#{userMB.bean.name}" />
<p:outputLabel value="e-mail:" /> <h:outputText value="#{userMB.bean.email}" />
etc...

Now I create an UserAdmMB that inherits UserMB, with another fields. I want to reuse the XHTML that exists, like using <ui:include>:

<ui:include src="user.xhtml" />
<p:outputLabel value="Address:" />
<h:outputText value="#{userAdmMB.anotherbean.address}" />

But the first XHTML already has userMB in it (to be used in another access point). How is the better way to do that?

Tiny
  • 27,221
  • 105
  • 339
  • 599
tpcordeiro
  • 441
  • 1
  • 6
  • 13

1 Answers1

1

Refactor the bean as <ui:param> of <ui:include>.

The new include:

<p:outputLabel value="Name:" /> <h:outputText value="#{user.name}" />
<p:outputLabel value="Email:" /> <h:outputText value="#{user.email}" />
...

The clients:

<ui:include src="user.xhtml">
    <ui:param name="user" value="#{someBean.user}" />
</ui:include>
<ui:include src="user.xhtml">
    <ui:param name="user" value="#{someAdminBean.user}" />
</ui:include>
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555