如何刷新VF页面?

时间:2014-12-20 18:13:17

标签: salesforce

我为对象Merchandise创建了一个VF页面,它包含3个字段 - 名称,价格和数量。当我创建新记录并单击保存按钮时,新记录将保存在tat对象(商品)中,但是字段中的值不会刷新。

必须添加到代码中的内容如下:

public with sharing class mdetailcon {   
public Merchandise__c mer{set;get;}  
public mdetailcon(){
mer = new Merchandise__c();     
public PageReference save() {  
insert mer; 
return null;  
 }      }

<apex:page sidebar="false" showHeader="false" controller="mdetailcon">     
<apex:form >
<apex:pageBlock > 
<apex:pageBlockSection columns="1" > 
<apex:inputField value="{!mer.name}" label="Name"/> 
<apex:inputField value="{!mer.Price__c}" label="Price"/>    
<apex:inputField value="{!mer.Q__c}" label="Quantity"/>    
</apex:pageBlockSection>    
<apex:commandButton value="save" action="{!save}"/   
 </apex:pageBlock>  
 </apex:form>    
  </apex:page>

1 个答案:

答案 0 :(得分:0)

我得到了答案,请检查下面的代码

public PageReference save() {
insert mer;
PageReference pageRef = new pageReference('/apex/merchdetail'); 

   // ('/apex/yourvfpagename',as the vfpage i have created was merchdetail)

pageRef.setRedirect(true);
return pageRef;

}
相关问题