function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vviyervviyer 

Using checkbox to render a pageblocksection

I want to render a page block section depending on whether the user check a checkbox. I'm using action support tag to render the page block section on action"on lick". The page renders when I check it. But it doesntdisappear when I uncheck it?

here is theh VF page

 

<apex:outputPanel >
<apex:outputLabel value="Add Organization Affiliation?" for="theAff"/>
<apex:inputCheckbox value="{!renderAffiliation}" id="theAff"/>
<apex:actionSupport event="onclick" rerender="affsection"/>
</apex:outputPanel>

<apex:outputPanel id="affsection">
<apex:pageBlockSection title="Organization Affiliations" rendered="{!renderAffiliation}">
<apex:inputField value="{!affiliations.npe5__Organization__c}"/>
<apex:inputField value="{!affiliations.npe5__Description__c}"/>
<apex:inputField value="{!affiliations.npe5__Role__c}"/>
<apex:inputField value="{!affiliations.npe5__Status__c}"/>
</apex:pageBlockSection>
</apex:outputPanel>

 THe controller get, set the renderAffiliation variable 

public Boolean renderAffiliation{get; set;}

 

 

 

 

Message Edited by vviyer on 04-08-2009 04:16 PM
TehNrdTehNrd

Try this:

 

 

<apex:outputLabel value="Add Organization Affiliation?" for="theAff"/> <apex:inputCheckbox value="{!renderAffiliation}" id="theAff"/> <apex:actionSupport event="onclick" rerender="affsection"/> </apex:outputPanel> <apex:outputPanel id="affsection"> <apex:pageBlockSection title="Organization Affiliations" rendered="{!renderAffiliation}"> <apex:inputField value="{!affiliations.npe5__Organization__c}"/> <apex:inputField value="{!affiliations.npe5__Description__c}"/> <apex:inputField value="{!affiliations.npe5__Role__c}"/> <apex:inputField value="{!affiliations.npe5__Status__c}"/> </apex:pageBlockSection> </apex:outputPanel>

 

 

 

vviyervviyer

I dont see the difference. Am I missing something?

 

THe code, render the section. but when i uncheck, it doest rerender adn remove the section.

 

PS: you may have seen my post. i made some changes to the code ( i copied an old version to the board)

TehNrdTehNrd

I didn't see your updated code. I'm guessing one of these fields is required:

 

 

<apex:inputField value="{!affiliations.npe5__Organization__c}"/> <apex:inputField value="{!affiliations.npe5__Description__c}"/> <apex:inputField value="{!affiliations.npe5__Role__c}"/> <apex:inputField value="{!affiliations.npe5__Status__c}"/>

Monitor your debug log and add the tag apex:messages inside this panel:

 

 

<apex:outputPanel id="affsection"> <apex:messages/> <apex:pageBlockSection title="Organization Affiliations" rendered="{!renderAffiliation}">

 

 

 

 

 

 

 

 

 

vviyervviyer

Yes you are right, npe5__Organization__c is a required field in affiliations. So when I check the box, the section renders, but when I uncheck it the field npe5__ORganization__c displays a "is required" error and doesnt hide.

 

Also, the debug blog doesnt popup. It says "lo4javascript error: popup is blocked".. the debug log opens fine for other tabs.

Message Edited by vviyer on 04-09-2009 10:57 AM
TehNrdTehNrd
You'll need to look in the the actionRegion tags. In this case I think you will want to put them around the check box and any other inputs that are not dynamically shown and hidden.
s-Forces-Force

Hiii,

 

I also try the same code that you have post for render the page on basis of checkbox. its working fine but it doesn't allow me enter any values in the input field of output panel. i.e. when i check the checkbox a pageblocksection is appear with some values but am not able to enter the values in these input fields..... Please tell me whts the problem. is anything missing from my side????

 

 

Thanks In Advance.