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
TheReportDoctorTheReportDoctor 

Rerendering the detail object only refreshes the related list

When I can for my form, which holds my detail object, to be rerended only the related list gets rerendered, but the field that I updated does not refresh with the new value.  If I press F5 to refresh the page it appears.  This field needs to be populated before my related list can populate, so we know that the underlying field is updated it just does not appear.  Here is my code.  Thank you for your time. TRD

 

<apex:page standardController="Opportunity" extensions="workFlowData"  >
        <apex:form id="oppsPage"  rendered="{!renderMe}">
            <apex:actionFunction name="postWorkFlow" action="{!postWorkFlow}" rerender="oppsPage" />
            <apex:pageblock >
                <apex:selectList value="{!flow}" size="1" onchange="postWorkFlow()" >
                    <apex:selectOptions value="{!WFNames}"/>
                </apex:selectList>
                <apex:pagemessages />
            </apex:pageblock>
            <apex:detail id="oppsForm" subject="{!$CurrentPage.parameters.Id}" rendered="true"/>
        </apex:form>
</apex:page>

 

public class workFlowData {
    String selectedWorkFlow;
    
    public Opportunity opp {
        get;
        set;
    }
    
    public workFlowData(ApexPages.StandardController stdController) {
        this.opp = (Opportunity)stdController.getRecord();
        if (this.opp.id != null) {
            this.opp = [SELECT Product__c, Stage_of_Install__c, workflow__c FROM Opportunity WHERE Id = :this.opp.Id];
        }
    }
 
    public List<SelectOption> getWFNames() {
        List<Workflow__c> wf_names = [SELECT id, name FROM Workflow__c ORDER BY name];
        List<SelectOption> wf_dropdown= new List<SelectOption>();
        wf_dropdown.add(new SelectOption('',''));
        for (Workflow__c wf_name: wf_names) {
            wf_dropdown.add(new SelectOption(wf_name.id,wf_name.name));
        }
        return wf_dropdown;
    }
    
    public String flow {
        get;
        set;
    }
    
    public Boolean getRenderMe() {
        return this.opp.Product__c!= null && this.opp.Stage_of_Install__c == '7 - Pipeline';
    }
    
    public PageReference postWorkFlow() {
        if (this.opp.Id != null) {
            this.opp.workflow__c = this.flow;
            try {
                update opp;
            } catch (dmlException de) {
                for (Integer err =0; err < de.getNumDml();err++) {
                    system.debug(de.getDmlMessage(err));
                }
            }
        }
        return null;
    }
}

 

incuGuSincuGuS

I suggest wrapping what you need to rerender in an <apex:outputPanel id="rerenderThis"> instead of the actual tags , there are several unwanted behaviours if you rerender a tag with dynamic attributes and such.

 

In your case

 

<apex:outputPanel id="oopsPage">
<apex:form rendered="{!renderMe}">
....

</outputPanel>

 

This way the rendered attribute of your form is re-checked each time you rerender, otherwise its not.

To make it a bit more clear imagine the Rerender only rerendering the contents of the tag, not the tag itself.