gpt4 book ai didi

javascript - Visualforce 远程处理 : Parameter length does not match remote action

转载 作者:行者123 更新时间:2023-11-30 10:27:52 25 4
gpt4 key购买 nike

我正在尝试在我的 VF 页面中使用 JS Remoting 将两个字符串传递到我的 Controller 。

在我的 VF 页面中,我使用来自复选框的 onclick 事件处理程序调用 javascript 方法:

<apex:inputCheckbox value="{!part.selected}" disabled="{!IF(part.selected == true, true, false)}" onclick="getParamValues('{!part.contactId}','{!part.contactName}');">

这是javascript函数:

function getParamValues(whoid, whoname) {
CallReportControllerExtension.getWhoId(whoid);
CallReportControllerExtension.getWhoName(whoname);
}

这是我在 Controller 中的方法:

@RemoteAction
public static String getWhoId(String id) {
system.debug('*********************** we are inside the getWhoId method');
paramWhoId = id;
return paramWhoId;
}

@RemoteAction
public static String getWhoName(String name) {
system.debug('*********************** we are inside the getWhoName method');
paramWhoName = name;
return paramWhoName;
}

在我的调试中,从未输入操作方法。

错误是什么意思?如何将字符串传递给 Controller ​​方法?

最佳答案

http://www.salesforce.com/us/developer/docs/pages/Content/pages_js_remoting_example.htm

这是上面链接中指出的简单语法。我觉得你的情况有语法错误。

让我们用正确的语法来解决这个问题

function getParamValues(whoid, whoname) {

Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.CallReportControllerExtension.getWhoId}',
whoid,
function(result, event){
if (event.status) {
alert('RESULT WHOID',result);

}
},
{escape: true}
);

Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.CallReportControllerExtension.getWhoName}',
whoname,
function(result, event){
if (event.status) {
alert('RESULT WHONAME',result);

}
},
{escape: true}
);
}

事实上,您可以组合这些并作为 List 发送并作为 List 返回,然后解析相同的 .

关于javascript - Visualforce 远程处理 : Parameter length does not match remote action,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18731448/

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