You need to sign in to do that
Don't have an account?
ihssan taziny
Problem while reRendering field after update
Hi, I'm developping a Visualforce Page that shows Opportunity fields. I have a button that update a field and reRender the form, the update operation is working but i cannot see the result when the button is clicked, and i have to reload the page to see the new value of the field.
this is the visualforce page code
and this is my controller :
I have already tried to return Pagereference with null value in the method aprove() but it doesn't work, neither with actionFunction in Visualforce Page
this is the visualforce page code
<apex:page standardController="Opportunity" extensions="InnovationOpportunityController" sidebar="false"> <apex:form id="theForm" > <apex:pageBlock title="Detalles de la Oportunidad" id="pgBlck"> <apex:pageblockButtons location="top"> <apex:commandLink value="Aprove" action="{!aprove}" status="GeneralStatus" styleClass="btn NoDecoration" /> </apex:pageblockButtons> <apex:pageblockSection columns="2" collapsible="false" id="section"> <apex:outputField value="{!Opportunity.OwnerId}"/> <apex:outputField value="{!Opportunity.Amount}"/> <apex:outputField value="{!Opportunity.IsPrivate}"/> <apex:outputField value="{!Opportunity.ExpectedRevenue}"/> <apex:outputField value="{!Opportunity.StateInnovation__c }"/> </apex:pageblockSection> </apex:pageBlock> </apex:form> </apex:page>
and this is my controller :
public without sharing class InnovationOpportunityController { private Opportunity opp; public InnovationOpportunityController(ApexPages.StandardController sc) { opp = [select Id, Name, StateInnovation__c from Opportunity where Id =:sc.getId()]; } public void aprove() { opp.StateInnovation__c = 'Aproved'; update opp; opp = [select Id, Name, StateInnovation__c from Opportunity where Id =: opp.Id]; } }
I have already tried to return Pagereference with null value in the method aprove() but it doesn't work, neither with actionFunction in Visualforce Page
public without sharing class InnovationOpportunityController {
private Opportunity opp;
public InnovationOpportunityController(ApexPages.StandardController sc) {
opp = [select Id, Name, StateInnovation__c from Opportunity where Id =:sc.getId()];
}
public PageReference aprove() {
opp.StateInnovation__c = 'Aproved';
update opp;
PageReference detailPage = ApexPages.currentPage();
detailPage.setredirect(true);
return detailPage ;
}
}
Thank you for your answer.
I resolved the problem replacing the variable {!Opportunity.fieldName} in the outputfield tags by {!opp.OwnerId}, and by establishing the variable opp in the controller with Thanks