开发者

Url mapping to a plugin view

开发者 https://www.devze.com 2023-03-09 08:36 出处:网络
What is the best, or the preferred way to map an url to a view that is within a plugin installed in a grails app?

What is the best, or the preferred way to map an url to a view that is within a plugin installed in a grails app?

The application has its own views, however, there is a view that is directly connected to the plugin 开发者_Python百科and I would like to be able to access it. As far as I can see, there is no way to directly map the view in the plugin via UrlMappings.config, or is there?


As far I know (I just read the docs and did some testing), it is not possible to map directly to a view in a plugin unless there is a controller that can forward to it. Plugin controllers are generally available the same way your application's controllers are available.

To get around this you can just copy the view into your own application and access it that way. Or you could use the g.link tag in one of your own controllers to build a URI that accesses the plugin's view and render it that way.

What plugin is this? I'm surprised there would be an inaccessible view that you would need direct access to.


In Grails 3, at least, you can do this:

static mappings = {
  "404" (view:'/notFound', plugin:'myPlugin')
}

And it works.

We have a plugin with common configurations and styling that gets loaded in to multiple applications. You can actually put that URLMapping in the plugin itself and it will propagate to the applications correctly, which is nice.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号