0

I know this is somewhat of a replicated post across the web, but nothing out there has answered my question.

I have an input field (picklist) containing Closed Won, Closed Lost, and Closed Lost - No Decision. Code is below:

<apex:inputField value="{!debrief.Stage__c}"  >
     <apex:actionSupport event="onchange" rerender="toRerender"/>
</apex:inputField>

That field is wrapped in a page block section. I have another page block below, which I want to rerender after selecting a value in the picklist. The rerender works if, when opening the vfp, the debrief.Stage__c is set to one of the options. Otherwise, the 'None block' is displayed, and the section seemingly never rerenders when changing the picklist. Code below:

<apex:pageBlock id="toRerender">
            <apex:pageBlockSection title="Details"  >
                <apex:outputPanel id="lossPanel" rendered="{!debrief.Stage__c != 'Closed Won' && debrief.Stage__c != ''}" >
                    loss block
                </apex:outputPanel>

                <apex:outputPanel id="winPanel" rendered="{!debrief.Stage__c == 'Closed Won'}">
                    win block 
                </apex:outputPanel>

                <apex:outputPanel id="nonePanel" rendered="{!debrief.Stage__c == ''}" >
                    None block
                </apex:outputPanel>
            </apex:pageBlockSection>
    </apex:pageBlock>

Does anyone have any idea what the issue could be? I have tried wrapping in more output panels, etc.

  • Can you post your controller code – EricSSH Jul 19 '17 at 18:29
  • @caseyjg - A trick to tell if it actually is re rendering is to place the {!debrief.Stage__c} right below the <apex:pageblock> page without any conditions. If you see it changing when you change the pick list (if the pick list is bound to it) then you can tell it is re rendering and the issue is with your conditions – Eric Jul 19 '17 at 18:36
  • @Eric It outputs nothing on page load when the object is newly created, because Stage__c is not set to anything. But, after selecting it in the picklist it doesn't render anything either. Not really what to do about that. – caseyjg Jul 19 '17 at 18:41
  • @EricSSH Thanks for that suggestion. It was due to the fact that if there was no existing debrief object associated with my query I hadn't instantiated a new one. Fixed that and it's working as expected. – caseyjg Jul 19 '17 at 18:43
0

I always wrap it twice, you cannot rerender a vf component that hasn't already been rerendered

<apex:outputPanel>
  <apex:outputPanel id="nonePanel" rendered="{!debrief.Stage__c == ''}" >
                None block
  </apex:outputPanel>
</apex:outputPanel>

Try it with one of your picklist values and if it works do it for the rest..

  • It's that rerender only affects child elements. So you would need to specify that id attribute on your outer <apex:outputPanel> tag for it to work predictably. In theory. – Adrian Larson Jul 19 '17 at 19:37

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.