Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何正确重写salesforce标准对象控制器save方法,以便在VisualForce页面中拦截它?_Salesforce_Apex Code_Visualforce - Fatal编程技术网

如何正确重写salesforce标准对象控制器save方法,以便在VisualForce页面中拦截它?

如何正确重写salesforce标准对象控制器save方法,以便在VisualForce页面中拦截它?,salesforce,apex-code,visualforce,Salesforce,Apex Code,Visualforce,您好,我在那里创建了一个VisualForce页面,以一个标准的lead控制器作为控制器,并对其进行了扩展。我想这样做,这样我仍然可以利用apex:细节控制,而不是在处理标准潜在客户信息、相关列表等时重新发明轮子 我添加了一个apex:commandbutton并使其调用save。当我点击这个按钮时,我可以清楚地看到我的函数正在被调用。但是,不会捕获通过内联编辑对潜在客户信息所做的所有更改 例如,如果我使用内联编辑编辑LastName并单击apex:commandbutton,则不会保存新的La

您好,我在那里创建了一个VisualForce页面,以一个标准的lead控制器作为控制器,并对其进行了扩展。我想这样做,这样我仍然可以利用apex:细节控制,而不是在处理标准潜在客户信息、相关列表等时重新发明轮子

我添加了一个apex:commandbutton并使其调用save。当我点击这个按钮时,我可以清楚地看到我的函数正在被调用。但是,不会捕获通过内联编辑对潜在客户信息所做的所有更改

例如,如果我使用内联编辑编辑LastName并单击apex:commandbutton,则不会保存新的LastName值。这几乎就像apex调用的save函数:commandbutton不知道数据更改

下面是我的可视力页面的代码

<apex:page standardController="Lead" extensions="LeadTestExtensionController">
<apex:form >
    <apex:commandButton action="{!save}" value="Save" id="btnSave"/>
    <apex:detail subject="{!Lead.Id}" relatedList="true" showchatter="true" inlineEdit="true" />
</apex:form>
</apex:page>
我做错了什么,我如何才能做到这一点。上面的代码是我实际代码的高度简化版本。我在实际代码中试图做的是检查某个字段的值,如果它符合某些标准,我希望它做一些事情。但是,我似乎看不到输入的新值

谢谢。

在标准控制器上调用save()不会提交详细信息部分中的内联编辑。我只是使用标准控制器重现了这个问题,所以您覆盖它的方式不是问题所在

我认为这样做的原因是apex:detail本身从数据库中获取一条记录,而不是使用对标准控制器中的记录的引用


内联编辑应该为您提供自己的保存按钮,我认为您最好的选择是尝试将其纳入您的设计中

inline edit own save按钮的问题是,除非使用触发器检查值更改,否则无法截取它。但是,我无法从触发器内执行任何重定向。谢谢你。
public LeadTestExtensionController(ApexPages.StandardController stdController) {
    this.controller = stdController;
    this.myLead = (Lead)stdController.getrecord();
    this.page = ApexPages.currentPage();
    this.id = page.getParameters().get('id');
    List<Lead> myLeads = [select Opportunity_Stage__c from lead where id = :id];
    if(myLeads.size() > 0)
    {
        positions = myLeads[0].Opportunity_Stage__c;
    }
}

public PageReference save() {
    this.controller.save();
    PageReference newPage = New PageReference('/apex/RCS');
    newPage.getParameters().put('id',ApexPages.currentPage().getParameters().get('id'));
    newPage.setRedirect(true);
    return newPage;
 }
this.controller.save();