0

I have an input field:

<apex:inputField id="tabIndex5" value="{!My_Object__c.Some_Field__c}">
    <apex:actionSupport event="onchange" action="{!DoNothing}" rerender="info,subinfo,subinfo2,emailinfo,advancedSettings" />
</apex:inputField>

I then add a pageBlockSection

<apex:pageBlockSection id="advancedSettings" title="{!$Label.advanced_settings}" columns="1" rendered="{!AND(Not(IsBlank(My_Object__c.Some_Field__c)))}">
    <apex:inputField value="{!My_Object__c.Checkbox_Field__c}" />
</apex:pageBlockSection>

This correctly renders on page rerender or page load. But if the field is populated and it renders initially, then I clear the field, nothing happens. That pageBlockSection does not go away like it should with its rerender because Some_Field__c is now empty. Or if it is empty and then gets populated, the pageBlockSection never shows up. How can I get this onchange to actually rerender the pageBlockSection correctly?

2

you can't rerender element with the specific id, if it has rendered attribute. Add one more outer apex:outputPanel and rerender it

<apex:outputPanel id="advancedSettings">
    <apex:pageBlockSection title="{!$Label.advanced_settings}" columns="1" rendered="{!AND(Not(IsBlank(My_Object__c.Some_Field__c)))}">
        <apex:inputField value="{!My_Object__c.Checkbox_Field__c}" />
    </apex:pageBlockSection>
</apex:outputPanel>
| improve this answer | |
  • Thanks, this is getting closer. However, doing this now has the inner pageBlockSection show up like it is a subsection, where I need it to look like its own section, where the header bar stretches across the entire page. Is there a way to force that? – Tyler Dahle Dec 5 '19 at 15:38
  • @TylerDahle I have updated my answer, you can use apex:outputPanel for outer element – Oleksandr Berehovskyi Dec 5 '19 at 15:40
  • That worked! Thank you. – Tyler Dahle Dec 5 '19 at 15:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.