I have a panelGrid with a row containing a selectCheckBoxMenu and another row which should be shown or hidden based on the selection.
Updating the entire panel when the selection is changed is not desired, because the selectCheckBoxMenu would be refreshed and the user would have to open the dropdown again for each item he wants to select.
Updating the controls to be hidden or shown can't solve the problem either because they can't be updated if they are not shown because rendered was false before.
So, I wrapped these controls in a Fragment and update those fragments. Functionally that's OK, but now I have an ugly layout because in most situations the controls will be hidden and a small empty row is shown.
Is it possible to get rid of that ugly empty row without breaking the functionality again?
My xhtml looks like this:
<p:panelGrid id="panel" columns="2" border="0" cellpadding="5"
cellspacing="2">
...
<h:outputLabel value="Type" />
<p:selectCheckboxMenu id="deviceTypeMenu" value="#{controller.criteria.dts}" label="All" converter="dtConverter"
filter="true" filterMatchMode="contains"
panelStyle="width:300px" valueChangeListener="#{controller.onChange}"
updateLabel="true">
<p:ajax update="sclabel scfield" />
<f:selectItems value="#{deviceTypeBean.alldts}" var="dt"
itemLabel="#{dt.name}" itemValue="#{dt}"/>
</p:selectCheckboxMenu>
...
<p:fragment id="sclabel">
<h:outputText value="Detail" rendered="#{controller.detailRequired}"/>
</p:fragment>
<p:fragment id="scfield">
<p:selectCheckboxMenu rendered="#{controller.detailRequired}" converter="#{detailConverter}"
value="#{controller.criteria.detail}" label="All details"
filter="true" filterMatchMode="contains"
style="width:300px;" scrollHeight="100"
updateLabel="true">
<f:selectItems value="#{detailConverter.values}" var="adetail"
itemLabel="#{adetail.name}" itemValue="#{adetail}" />
</p:selectCheckboxMenu>
</p:fragment>
...
</p:panelGrid>