- Home
- Technical Library
- Boards
- Cookbook
- Code Share
- Blogs
- Partners
-
More
-
Services
- Training & Certification
- Support
-
Galleries
- Force.com Sites Gallery
- Chatter Challenge Entries
-
Other Web Sites
- Salesforce.com
- Database.com
- AppExchange
- CRM Community
-
Discussions
- Announcements
- General Development
- Schema Development
- New to Cloud Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules Discussion
- Security
- Mobile
- Force.com Sites
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby Development
- Adobe Flash Builder for Force.com
- Desktop Integration
- REST API Integration
- Streaming API
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- Excel Connector
- AJAX Toolkit & S-controls
- Force.com Builder & Native Apps
- AppExchange Directory & Packaging
- Force.com Labs Projects
- Open Source
- Site.com
- Jobs Board - Administrators
- Jobs Board - Developers
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Visualforce Development
- :
- Re: Basic Show/Hide pageBlockSection not working.....
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Basic Show/Hide pageBlockS ection not working...
[ Edited ]
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-09-2010 11:52 AM - last edited on 02-09-2010 11:55 AM
<apex:page standardController="CustomObject__c" extensions="ControllerExt">
<apex:pageMessages id="pageMessages" />
<apex:form id="terminalForm">
<apex:pageBlock>
<apex:pageBlockSection>
<apex:pageBlockSectionItem >
<apex:outputLabel for="type">Type</apex:outputLabel>
<apex:selectList id="type" value="{!type}" size="1">
<apex:selectOptions value="{!typeOptions}" />
<apex:actionSupport event="onchange"
action="{!pageRefreshAction}"
rerender="TypeSection_CC,TypeSection_CH,pageMessages"
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:outputPanel id="TypeSection_CC" rendered="{!(type == 'option1'||type == 'option2')}">
<apex:pageBlockSection>
<!-- Stuff -->
</apex:pageBlockSection>
</apex:outputPanel>
<apex:outputPanel id="TypeSection_CH" rendered="{!(type == 'option3')}">
<apex:pageBlockSection>
<!-- More Stuff -->
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
As you can see, the sections render depending on the value of "type". The default value of "type" is "option1". So "TypeSection_CC" is displayed when the page loads.
The "pageRefreshAction" method just adds a message to the page that displays the value of "type". I've tried making this method void as well, and it makes no difference.
public PageReference pageRefreshAction() { ApexPages.addMessage(new ApexPages.Message(ApexPages.SEVERITY.INFO, 'Type: '+type)); return null; }
When I choose "option3" from the "type" selectList the pageMessages block is refreshed and shows the value of "type" as "option3", but TypeSection_CC is still displayed and TypeSection_CH is not displayed.
Any help?? I don't know why this is causing problems...
Solved! Go to Solution.
Re: Basic Show/Hide pageBlockS ection not working...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-09-2010 12:03 PM
The problem you are facing is that when the page loads, since type is not option 3, TypeSection_CH is not rendered and hence the page also does not has its id. Next time, when the page tries to rerender it, it cannot find the id since it originally didn't existed for the page.
Solution: move the rendered attribute from outputPanel to pageBlockSection but still rerender the outputPanel. This way, your page will always have the Id, however the pageBlockSection will be rendered only based on the values.
Vote for my ideas
Re: Basic Show/Hide pageBlockS ection not working...
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
02-09-2010 10:54 PM
Rajesh -
Thank you! That was driving me crazy. Not only did your solution work, you explained the cause of the problem very clearly. I really appreciate it.
Thanks,
Ryan

