[英]Named (map) constructors do not work in grails.gsp.PageRenderer
When I use a map constructor like:当我使用地图构造函数时:
Person p = new Person(name: "Bob")
through something that is called via a grails.gsp.PageRenderer, the field values are not populated.通过通过 grails.gsp.PageRenderer 调用的东西,不会填充字段值。 When I use an empty constructor and then set the fields individually like:当我使用空构造函数然后单独设置字段时:
Person p = new Person()
p.name = "Bob"
it succeeds.它成功了。 When I use the map constructor via a render
call, it also succeeds.当我通过render
调用使用地图构造函数时,它也成功了。
Any ideas as to why this is the case?关于为什么会这样的任何想法?
Sample project is here in case anyone wants to dig deeper: https://github.com/danduke/constructor-test/示例项目在这里,以防有人想深入挖掘: https : //github.com/danduke/constructor-test/
Actual use case, as requested by Jeff below:实际用例,如下 Jeff 所要求:
There are quite a few opportunities for improvement in my actual use case, and I'm open to suggestions on that.在我的实际用例中有很多改进的机会,我愿意就此提出建议。 However, the simplest possible (for me) demonstration of the problem still does suggest that there's a problem.但是,最简单的(对我而言)问题的演示仍然表明存在问题。 I'm curious whether it should be possible to use map constructors in something called from a PageRenderer at all.我很好奇是否应该可以在从 PageRenderer 调用的东西中使用地图构造函数。 I'm surprised that it doesn't work, and it feels like a bug, but obviously a very precise and edge case one.我很惊讶它不起作用,感觉就像一个错误,但显然是一个非常精确和边缘情况的错误。
"Technically it is a bug" (which is the best kind of bug!), and has been reported here: https://github.com/grails/grails-core/issues/11870 “从技术上讲,这是一个错误”(这是最好的错误!),并已在此处报告: https : //github.com/grails/grails-core/issues/11870
I'll update this if/when additional information is available.如果/当有其他信息可用时,我会更新它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.