gpt4 book ai didi

salesforce - 顶点 :commandButton in visualforce component does not call controller method

转载 作者:行者123 更新时间:2023-12-04 00:45:16 25 4
gpt4 key购买 nike

我在 visualforce 组件中有一个 commandButton。预期的行为是将调用 Controller 方法。页面刷新了,但是在 commandButton {!performUnlinkContact} 中注册的方法没有被调用。奇怪的是,如果我将按钮放在基本 visualforce 页面上,它会按预期调用 Controller 方法 - 但在组件中时,它不会。

这是我的组件:

<apex:component >
<apex:attribute name="rk" description="RK Base Contact Data" type="Object" required="true"/>

<div class="unlinkBox">
<div class="unlinkHeader">
<div class="unlinkHeaderLeft">Wrong Contact?</div>
<div class="unlinkHeaderRight"><a href="" onclick="return hideUnlinkPanel()"><apex:image style="cursor: pointer;" value="{!$Resource.x}" alt="Close Panel" /></a></div>
</div>
<div class="unlinkBody">
<div class="unlinkBodyLeft">
Click Yes if the Contact displayed is incorrect.<br/><br/>You will be given the opportunity to link to a different Contact.
</div>
<div class="unlinkBodyRight">
<apex:outputpanel id="callMethod">
<apex:commandbutton value="Yes, this is the wrong contact" action="{!performUnlinkContact}" rerender="" status="myDisplayStatus" />&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="return hideUnlinkPanel()" style="color:blue;cursor:pointer;text-decoration:underline">No</a>
</apex:outputpanel>
<apex:actionStatus id="myDisplayStatus" startText="(performing Contact Unlink...)" stopText=""/>
</div>
</div>
</div>
</apex:component>

这是 Controller 扩展中的方法:

public PageReference performUnlinkContact() {
System.debug('==================================!!performUnlink');
if (this.thisLead.rkContactId__c != 0) {
this.thisLead.rkContactId__c = 0;

update this.thisLead;
}

return null;
}

我确定我一定是做错了什么,因为我是 salesforce 的新手并且还在学习,但是当我搜索如何解决这个问题时,我找不到任何相关的问题。预先感谢您的帮助。

最佳答案

感谢您的回复 - 为了解决这个问题,我最终向基本页面添加了一个 actionFunction,然后通过按钮的 onclick 事件在组件中调用这个函数:

基页中的代码:

    <apex:actionFunction name="doUnlink" action="{!performUnlinkContact}" rerender="refresh" status="myStatus"/>

组件中调用函数的代码:

    <input type="button" value="Yes, this is the wrong contact" onclick="doUnlink();" />

到目前为止,这种方法似乎很有效。

关于salesforce - 顶点 :commandButton in visualforce component does not call controller method,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12501210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com