The problem I have is much more complex but I try to break it down to a minimal example that demonstrates the main things.
My BeanClass is managing some Entity/POJO where this POJO again contains some other Entities/POJO
public class MyEntityA implements Serializable {
String attributA;
MyEntityB b;
// Getter .. Setter
}
public class MyEntityB implements Serializable {
String attributB
// Getter .. Setter
}
Within my JSF I need input-Fields for all of the attributs like
<p:inputTextarea value="#{myBean.entityA.attributeA}" />
<p:inputText value="#{myBean.entityA.b.attributeB}" />
Instead of this I marely want to write somethin similar to
<my:custom property="#{myBean.entiyA}" />
With using an own facelet tag file I have to assign every single attribute I want to be able to change, so the benefit that I will get is dissatisfying , because I have to touch each of my tags if my EntityClasses change. And that is one point I want to avoid.
Using composite component I have the problem that this is rendered as a single component but that destroys the whole design of my page if I want to use this e.g. in a panelGrid.
Is it possible to achieve this with a Custom Component and Tag Handler? Or are is their even a more simple way? How could a solution for my short example look like with using a Custom Component and Tag Handler?
In the very end I have to somehow loop over these components.
<c:forEach var="item" items="#{myBean.entityACollection}">
<my:custom property="#{item}"/>
</c:forEach>
should be the same as I write anything like
<p:inputTextarea value="#{myBean.firstEntityA.attributeA}" />
<p:inputText value="#{myBean.firstEntityA.b.attributeB}" />
<p:inputTextarea value="#{myBean.secondEntityA.attributeA}" />
<p:inputText value="#{myBean.secondEntityA.b.attributeB}" />
<p:inputTextarea value="#{myBean.thirdEntityA.attributeA}" />
<p:inputText value="#{myBean.thirdEntityA.b.attributeB}" />
...
If you need additional information or there are problems with understanding my question please let know!
I am using PrimeFaces 4.0 and Mojarra 2.1.26