【发布时间】:2013-09-19 16:54:53
【问题描述】:
是否可以使用 Grails remoteFunction 调用子域对象的 create 方法?
我试图从我的 gsp 页面上的 remoteFunction 调用中调用子控制器中的 create 函数,但不断收到错误
Message: Provided id of the wrong type for class XXX.YYY. Expected: class java.lang.Long, got class java.lang.String
remoteFunction 代码如下所示:
$.ajax({
type: 'POST',
url: "${remoteFunction(controller:'childController' action:'create' )}"
});
我整个早上都在谷歌上搜索,我唯一能找到的是用于级联 select 语句的 remoteFunctions。
【问题讨论】:
-
问题不在于您所说的 remoteFunction。事实上,您的 create 方法显然希望通过 params.id 上的任何内容来查找对象。很有可能(如果您调试代码)您会看到它以“未定义”的形式出现,因为您的 remoteFunction 没有传入 id 参数。
-
@Gregg 不是这样。我在 create 方法中放了一个 println params.parent.id,它就在那里。
-
你能编辑你的问题并从你的控制器显示创建方法吗?