-
1. Re: AJAX forms: making a sub-form show up when a box is checked
damianharvey.damianharvey.gmail.com Apr 29, 2008 10:59 AM (in response to ericjava.eric.chiralsoftware.net)If you have rendered="false" then simply reRendering that panel will still return it with rendered="false". You need to have the rendered attribute dependent on some Bean property and change the value of that property before reRendering. For example:
<h:selectBooleanCheckbox value="#{testBean.contact}"> <a:support event="onclick" action="#{testBean.setDisplayTestPanel(true)}" reRender="testPanel" ajaxSingle="true"/> </h:selectBooleanCheckbox> <a:outputPanel id="testPanel"> <a:outputPanel rendered="#{testBean.displayTestPanel}"> <h:inputText value="#{testBean.phone}"/> </a:outputPanel> </a:outputPanel>
Note: you need the nested panel as you can't reRender something that has rendered="false". You need to reRender it's parent.
But IMO using ajax to reRender something like this is overkill. You're better off setting it to style="display:none;" and then using something like jQuery or scriptaculous to display it. For example using rich:jQuery:
<rich:jQuery name="toggleTestPanel" timing="onJScall" selector="#testPanel" query="slideToggle('slow')" /> <h:selectBooleanCheckbox value="#{testBean.contact}" onclick="toggleTestPanel();"/> <a:outputPanel id="testPanel" style="display:none;"> <h:inputText value="#{testBean.phone}"/> </a:outputPanel>
Cheers,
Damian.
-
2. Re: AJAX forms: making a sub-form show up when a box is checked
ericjava.eric.chiralsoftware.net Apr 29, 2008 10:57 PM (in response to ericjava.eric.chiralsoftware.net)THANK YOU Damian. That's cool. That's exactly what I needed to know.
I use the a:outputPanel with a sub-panel. That lets me also call an action as the sub-form expands. I also tried the jQuery stuff and it's very cool and I'll be using that also in some other instances. I liked the slow opening effect.