DominikM
DominikM

Reputation: 1052

Show/Hide part of the form based on checkbox

I have a similar issue as described in this thread: Show/hide JSF2 form using selectBooleanCheckbox. But solutions presented in that thread dont work for me. I want to have a form which is expandable by checking the checkbox.

My setup is as follows:

<p:selectBooleanCheckbox id="lookupCheck" value="#{addressDetailBean.addQLookup}">
    <p:ajax event="change" update="qlookupcolumn1" process="@this"/>
</p:selectBooleanCheckbox>
<p:outputPanel id="qlookupcolumn1" rendered="#{addressDetailBean.addQLookup}">
    <h2>#{msg['qloookup.new.title']}</h2>
    <ui:include src="/WEB-INF/includes/integration/qlookupDetailColumns.xhtml">
        <ui:param name="bean" value="#{addressDetailBean}" />
    </ui:include>
</p:outputPanel>

But when I check the checkbox form is not rendered. Bean is called and property is set properly and I can see the form in the response but it is not rendered on the page.

What might be wrong?

Upvotes: 1

Views: 4988

Answers (1)

skuntsel
skuntsel

Reputation: 11742

This is a typical problem and there are many related answers. Just embrace your output panel within a component, like <h:panelGroup>, that's always rendered and ajax-update it instead:

<p:selectBooleanCheckbox ...>
    <p:ajax update="refresh" process="@this"/>
</p:selectBooleanCheckbox>
<h:panelGroup id="refresh" ...>
    <p:outputPanel rendered=... />
<h:panelGroup/>

Upvotes: 5

Related Questions