在grails中不能调用方法本身 [英] Can't call method itself in grails

查看:120
本文介绍了在grails中不能调用方法本身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在方法体内调用方法self时,我的项目中出现错误。我把我的代码放在gsp中。

I got an error in my project when I try to call method it self inside body of method. I put my code in gsp.

在这里它们是

here they are

/* Method for appending the child menu */
def createMenuChild = { obj , paramMenuArr ->
  def urlChildMenu=obj.menu.url
  def idChildMenu=obj.menu.id
  def nameChildMenu=obj.menu.name

  out << '<div><a href="'+urlChildMenu+'" class="mChld">'<< nameChildMenu<< '</div>'

  def childInstance1= Menu.findById(idChildMenu)
  def child1MenuInstance= Menu.createCriteria().list{
    eq("parentMenu",childInstance1)
    order("sequence", "asc")
  }                                     
  if (child1MenuInstance){
    child1MenuInstance.each {newIt5 ->
      def idChildMenu2=newIt5.id
      paramMenuArr.each { newIt6 -> 
        if (newIt6.menu.id == idChildMenu2){
          owner.call (child1MenuInstance,paramMenuArr)
        }
      }
    }       
  }
}

我使用 owner.call 来调用方法本身。我有这样的错误

I use owner.call to call method itself. I got an error like this

Exception Message: No signature of method: bla.....

任何人都可以修复它?

Anybody can fix it?

推荐答案


我把代码放在gsp中。

I put my code in gsp.

你应该真的把这种代码放在taglib。

You should really put this kind of code in a taglib.


任何人都可以修复它吗?

Anybody can fix it?



<如果这只是一个标准的递归方法,那么执行递归调用的明显方法是:

If this is just a standard recursive method, then the obvious way to perform the recursive call is:

createMenuChild(child1MenuInstance,paramMenuArr)

尝试使用它来代替

owner.call (child1MenuInstance,paramMenuArr)

这篇关于在grails中不能调用方法本身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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