Grails:编辑和删除链接不工作 [英] Grails: Edit and Delete links not working

查看:158
本文介绍了Grails:编辑和删除链接不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个额外的列,并在列表末尾添加了用于编辑和删除事件的图标。



这里是我的

 < g:form value =$ {it.id}> 
< g:hiddenField name =idvalue =$ {it.id}/>
< / g:表格>

我写了 ID是$ {it.id} ,它会识别它并给我ID号码,所以我不知道问题出在哪里。任何帮助将不胜感激。
$ b

更新



所以我认为错误在控制器中编辑和删除被定义

  def edit = {
def entryInstance = Entry.get(params.id)
if(!entryInstance){
flash.message =$ {message(code:'default.not.found.message',args:[message(code:'entry.label',default:'Proyecto / $ R
$ b $ return $ [
$ return} [entryInstance:entryInstance]
}}
redirect(action:list)
}





$ b我认为它说params.id在get参数中不正确,我还有什么其他的选择?

 < g:form id = $ {it.id} > 
< span class =simple>
value =$ {message(code:'default.button.editar.label',
default:'& amp; amp; amp; ; & nbsp;')}/>
< / span>
< span class =simple>
value =$ {message(code:'default.button.eliminar.label',
default:'& amp; amp; ;'
onclick =return confirm('$ {message(code:'default.button.delete.confirm.message',default:'Esta seguro que desea Eliminar?')}'); />
< / span>
< / g:表格>

总结:在g:form标签中替换value =$ {it.id}用id ={it.id},然后删除ID的hiddenField。我认为这样可以解决问题。



让我知道它是否无效...


I created an extra column and added icons at the end of the list for editing and deleting an event.

Here is what I have

<g:form value="${it.id}">
                            <g:hiddenField name="id" value="${it.id}" />
                            <span class="simple"><g:actionSubmit class="editar" action="edit" value="${message(code: 'default.button.editar.label', default: '&nbsp;&nbsp;&nbsp;')}" /></span>
                            <span class="simple"><g:actionSubmit class="eliminar" action="delete" value="${message(code: 'default.button.eliminar.label', default: '&nbsp;&nbsp;&nbsp;')}" onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Esta seguro que desea Eliminar?')}');" /></span>
                        </g:form>

I wrote The ID is ${it.id} and it recognizes it and gives me the ID number, so I don't know where the problem is. Any help would be highly appreciated. Thanks.

Update

So I figured the mistake was in the controller where edit and delete are defined

def edit = {
    def entryInstance = Entry.get(params.id)
    if (!entryInstance) {
        flash.message = "${message(code: 'default.not.found.message', args: [message(code: 'entry.label', default: 'Proyecto/Ruta'), params.id])}"
        redirect(action: "list")
    }
    else {
        return [entryInstance: entryInstance]
    }
}

I think since it says params.id in the get parameters I not working right, what other alternatives do I have??

解决方案

<g:form id="${it.id}"> 
   <span class="simple">
     <g:actionSubmit class="editar" action="edit" 
                     value="${message(code:'default.button.editar.label', 
                                      default: '&nbsp;&nbsp;&nbsp;')}" />
   </span>
   <span class="simple">
     <g:actionSubmit class="eliminar" action="delete" 
                     value="${message(code: 'default.button.eliminar.label', 
                                      default: '&nbsp;&nbsp;&nbsp;')}" 
                     onclick="return confirm('${message(code: 'default.button.delete.confirm.message', default: 'Esta seguro que desea Eliminar?')}');" />
   </span>
 </g:form>

In summary: replace the value="${it.id}" in your g:form tag with id="{it.id}" and remove the hiddenField for ID. I think that will correct the problem.

Let me know if it doesn't work...

这篇关于Grails:编辑和删除链接不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆