The question is this ... although the problem does not involve JPA / ORM I find it interesting to contextualize.
My project has an @Entity Address and as the name suggests it is an entity responsible for storing data related to the real estate address, in this way, several other Entities have a relationship with this one, such as (eg a publisher has a real address as well as a client)
I then thought that maybe it would be possible to create a sort of VIEW in JSF called "view-address.xhtml" and it would contain all the inputs that feed an address-type entity so I could give an INCLUDE in that view and load it, wherever it is necessary to fill out an address book.
But I entered into the following dilemma ...
Each JSF form is attached to a ManagedBean, right? So, if I implement a publisher's registry I'll have:
My XHTML registration-editor.xhtml would give an include in the view responsible for the address right?
And how would I then associate the attributes of the publisherBean.editora.endereco object with the VALUES of the JSF inputs of the "view-address.xhtml"?
To illustrate, imagine a page like this:
<h:body>
<h:form prependId="false">
<p:growl id="msgs" showDetail="true" />
<p:fieldset id="basic" legend="Editora" style="margin-bottom:20px">
<h:panelGrid columns="2" cellpadding="10">
<p:outputLabel value="Nome: " for="txtEditora" />
<p:inputText id="txtEditora" value="#editoraBean.editora.nomeEditora}" />
</h:panelGrid>
</p:fieldset>
<ui:include src="/restricted/fragments/contato.xhtml" />
<ui:include src="/restricted/fragments/endereco.xhtml" />
</h:form>
</h:body>
Understand? After all, as I intend to modularize this view I can not associate the values of its inputs to the EditBean , but I would like to associate them even if I passed the ENDERECO object via parameter to the view and then retrieving the values to submit on the publisher page.