0

When a user click on the button Save/Update, it does what it should but it doesn't give the user feedback that it did it. I would prefer not to refresh the page.

How to give the user feedback?

<apex:page standardController="Community_Yearly_Plan__c" extensions="vf_CommunityPlanGoalPSetting_Cntrlr" cache="false">

    <apex:form >
        <apex:pageblock >
            <apex:pageBlockSection columns="1" id="pbsCon" >
                <apex:outputPanel id="panelCon">
                    <div id="loading-curtain-div"/>

                    <apex:pageBlockTable id="pbtCon" value="{!listGoalsCurrYear}" var="cpgs">
                      <apex:variable value="{!0}" var="cnt"/>   
                        <apex:column headervalue="Action">
                            <apex:commandlink value="Remove" action="{!removeRecord}" immediate="true">
                                <!-- Pass the row number to the controller so that we know which row to remove -->
                                <apex:param name="index" value="{!cnt}"/>
                            </apex:commandlink> 
                            <apex:variable var="cnt" value="{!cnt+1}"/>  

                        </apex:column>  
                        <apex:column value="{!cpgs.Year__c}" />                        
                        <apex:column>
                            <apex:facet name="header">Funding Type</apex:facet>                             
                            <apex:inputField id="ft" value="{!cpgs.Funding_Type__c}" rendered="{!IF(cpgs.EditableOrReadOnly__c='True' || newRow ="nr",'True','False')}" />
                        </apex:column>   
                        <apex:column>
                            <apex:facet name="header">Core Current Participation</apex:facet>                                                         
                            <apex:inputField id="ccp" value="{!cpgs.Core_Current_Participation__c}" rendered="{!IF(cpgs.EditableOrReadOnly__c='True'  || newRow ="nr",'True','False')}" />
                        </apex:column>   

                        <apex:column style="width:10px;">
                            <apex:facet name="header">Funding Amount</apex:facet>                                                         
                            <apex:inputField id="fa" value="{!cpgs.Funding_Amount__c}" rendered="{!IF(cpgs.EditableOrReadOnly__c='True' || newRow ="nr",'True','False')}" />
                        </apex:column>   
                        <apex:column >
                            <apex:facet name="header">Funding Description</apex:facet>                                                         
                            <apex:inputField id="fd" value="{!cpgs.Funding_Description__c}" rendered="{!IF(cpgs.EditableOrReadOnly__c='True' || newRow ="nr",'True','False')}" />
                        </apex:column>   
                        <apex:column style="width:10px;">
                            <apex:facet name="header">Goal Amount</apex:facet>                                                         
                            <apex:inputField id="ga" value="{!cpgs.Goal_Amount__c}" rendered="{!IF(cpgs.EditableOrReadOnly__c='True' || newRow ="nr",'True','False')}" />
                        </apex:column>   
                        <apex:column >
                            <apex:facet name="header">Goal Amount Comments</apex:facet>                            
                            <apex:inputField id="gac" value="{!cpgs.Goal_Amount_Comments__c}" rendered="{!IF(cpgs.EditableOrReadOnly__c='True' || newRow ="nr",'True','False')}" />
                        </apex:column>   

                    </apex:pageBlockTable>

                    <apex:commandButton style="align:center;" action="{!AddRow}" value="Add Goal Setting" reRender="pbsCon" />
                    <apex:commandButton style="align:center;" action="{!SaveRecords}" value="Save/Update" reRender="pbsCon" />                    

                </apex:outputPanel>

                <apex:outputPanel id="panelCon2">
                    <div id="loading-curtain-div"/>

                    <apex:pageBlockTable id="pbtCon2" value="{!listGoalsPrevYears}" var="cpgs2">

                        <apex:column value="{!cpgs2.Year__c}" />                        
                        <apex:column>
                            <apex:facet name="header">Funding Type</apex:facet>                            
                            <apex:outputField value="{!cpgs2.Funding_Type__c}" rendered="{!IF(cpgs2.EditableOrReadOnly__c!='True','True','False')}" />                            
                        </apex:column>   
                        <apex:column>
                            <apex:facet name="header">Core Current Participation</apex:facet>                                                         
                            <apex:outputField value="{!cpgs2.Core_Current_Participation__c}" rendered="{!IF(cpgs2.EditableOrReadOnly__c!='True','True','False')}" />                            
                        </apex:column>   
                        <apex:column>
                            <apex:facet name="header">Funding Amount</apex:facet>                                                                                     
                            <apex:outputField value="{!cpgs2.Funding_Amount__c}" rendered="{!IF(cpgs2.EditableOrReadOnly__c!='True','True','False')}" />                            
                        </apex:column>   
                        <apex:column >
                            <apex:facet name="header">Funding Description</apex:facet>                                                                                     
                            <apex:outputField value="{!cpgs2.Funding_Description__c}" rendered="{!IF(cpgs2.EditableOrReadOnly__c!='True','True','False')}" />
                        </apex:column>   
                        <apex:column >
                            <apex:facet name="header">Goal Amount</apex:facet>                                                                                     
                            <apex:outputField value="{!cpgs2.Goal_Amount__c}" rendered="{!IF(cpgs2.EditableOrReadOnly__c!='True','True','False')}" />
                        </apex:column>   
                        <apex:column >
                            <apex:facet name="header">Goal Amount Comments</apex:facet>                                                        
                            <apex:outputField value="{!cpgs2.Goal_Amount_Comments__c}" rendered="{!IF(cpgs2.EditableOrReadOnly__c!='True','True','False')}" />
                        </apex:column>   

                    </apex:pageBlockTable>

                </apex:outputPanel>                
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>
1

use apex:pagemessages attribute.

In your controller add the pagemessage and then rerender the section.

ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.INFO,'Success');
ApexPages.addMessage(myMsg);

and on VF page include

<apex:pageMessages />
  • This is good but where do I put 'ApexPages.Message myMsg'? If I put it at the top of my controller when I load the page it automatically shows "success". If I put it in the save method, it doesn't show. Also where to put "<apex:pageMessages />"? – Apex N-u-b Aug 16 '16 at 10:23
  • @ApexN-u-b put ApexPages.Message myMsg in save method and <apex:pageMessages /> in apex:form and give some id to this from and rerender this form you will get the message. – Tushar Sharma Aug 16 '16 at 11:22

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.