Extension: 4.0.0
Glassfish: 4.1
Mojarra: 2.2.9
I want to toggle visibility of form inputs depending on existence of child property Bar.
The GUI supports adding a new Bar instance or deleting it.
Code
I have a simple entity with a child property Bar like:
Code: Select all
class Foo
{
private String name;
private Bar bar;
public void initBar()
{
if (this.bar == null)
bar = new Bar();
}
}
Code: Select all
<pe:masterDetailLevel level="2" contextVar="contextVarFoo" levelLabel="#{foo.name}">
<h:panelGroup id="pnlBar">
<!-- create Bar -->
<p:commandButton icon="ui-icon-plusthick" rendered="#{contextVarFoo.bar eq null}"
action="#{contextVarFoo.initBar()}"
process="@this" update="pnlBar"/>
<ui:fragment rendered="#{contextVarFoo.bar ne null}">
<!-- input components for Bar -->
<!-- remove Bar -->
<p:commandButton icon="ui-icon-closethick"
process="@this" update="pnlBar">
<f:setPropertyActionListener value="#{null}" target="#{contextVarFoo.bar}"/>
</p:commandButton>
</ui:fragment>
</h:panelGroup>
</pe:masterDetail>
The Bar toggling markup is working outside of MasterDetail.
But inside MasterDetail I can only once remove the current instance via AJAX and on next AJAX request contextVar is null.