0

I've used this reRender functionality before and I cannot for the life of me see what's wrong with this basic code. Thanks in advance.

VF Page

  <apex:pageBlock>
            <apex:pageBlockButtons>
                <apex:commandButton action="{!save}" value="Save" reRender="commissionForm"/>
                <apex:commandButton action="{!showMessage}" value="Show" reRender="successMsg"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection id="successMsg" rendered="{!isSuccess}">
                <apex:outputText>SUCCESS!</apex:outputText>
            </apex:pageBlockSection>
        </apex:pageBlock>

Controller

public Boolean isSuccess {get;set;}

public ClassificationTypeContactHandler(ApexPages.StandardController controller) {
        
        Contact c = (Contact)controller.getRecord();
        con = new Classification_Type_Contact__c(Contact__c = c.Id );
        this.isSuccess=false;

    }

public void showMessage(){
        System.debug('show');
        this.isSuccess= true;
    }
1

1 Answer 1

2

In Visualforce you cannot force rerender element by specifying id, if this element has a condition to rendered you need to rerender some outer element of it. Something like this should work:

<apex:pageBlock>
    <apex:pageBlockButtons>
        <apex:commandButton action="{!save}" value="Save" reRender="commissionForm"/>
        <apex:commandButton action="{!showMessage}" value="Show" reRender="successMsg"/>
    </apex:pageBlockButtons>
    <apex:outputPanel id="successMsg">
        <apex:pageBlockSection  rendered="{!isSuccess}">
            <apex:outputText>SUCCESS!</apex:outputText>
        </apex:pageBlockSection>
    </apex:outputPanel>
</apex:pageBlock>
1
  • 1
    Worked. Waiting for timer to select best answer.
    – thinker
    Commented Apr 4, 2023 at 16:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .