将外键传递给编辑/删除视图grails
我有一套将外键传递给编辑/删除视图grails,grails,groovy,Grails,Groovy,我有一套流视频,外键是它们所属的地区。 然而,然后我点击编辑或删除按钮,我得到 Error 2012-08-30 23:51:16,424 [http-bio-8080-exec-7] ERROR errors.GrailsExceptionResolver - MissingMethodException occurred when processing request: [GET] /ctv/stream/list No signature of method: ctv.Stream.fi
流
视频,外键是它们所属的地区
。
然而,然后我点击编辑
或删除
按钮,我得到
Error 2012-08-30 23:51:16,424 [http-bio-8080-exec-7] ERROR errors.GrailsExceptionResolver - MissingMethodException occurred when processing request: [GET] /ctv/stream/list
No signature of method: ctv.Stream.findAllByDistrict() is applicable for argument types: () values: []
Possible solutions: findAllByDistrict([Ljava.lang.Object;). Stacktrace follows:
Message: No signature of method: ctv.Stream.findAllByDistrict() is applicable for argument types: () values: []
Possible solutions: findAllByDistrict([Ljava.lang.Object;)
问题在于
<g:form>
<g:hiddenField name="id" value="${streamInstance?.id}" />
<span class="button"><g:actionSubmit class="edit" action="edit" id="${params['district']}" value="${message(code: 'default.button.edit.label', default: 'Edit')}" /></span>
<span class="button"><g:actionSubmit class="delete" action="delete" id="${params['district']}" value="${message(code: 'default.button.delete.label', default: 'Delete')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Are you sure?')}');" /></span>
</g:form>
我正试图将地区
id发送到编辑
页面,但无法发送。谁能帮我一下吗?假设district=10
,那么我需要通过
标记传递值10
。我该怎么做呢?我认为标签不支持id参数。它只支持行动和价值
你必须把地区id放在一个隐藏的字段中
<g:hiddenField name="district" value="${params['district']}" />
使用简单的g:link
这里不需要g:form。
还要检查控制器设置是否正确
class MakeAppController {
static allowedMethods = [ update: "POST", delete: "GET",save: "GET"]
因为Grails框架允许在控制器中检查请求。显示触发te编辑操作的控制器代码。或者您使用的是
static scaffold=true
?@nickdos:我使用的是static scaffold=true
,所以您知道如何从另一个视图访问隐藏字段吗?有时params['district']
是空的。请使用firebug检查表单源以确保隐藏字段已正确填充