Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

layouts in plugins searched in wrong order #13114

Open
xpusostomos opened this issue Aug 26, 2023 · 0 comments
Open

layouts in plugins searched in wrong order #13114

xpusostomos opened this issue Aug 26, 2023 · 0 comments

Comments

@xpusostomos
Copy link

Expected Behavior

Let's say I have a grails app, that's working. Great. But then let's say I convert that app to a plugin for use in other apps. It probably won't work, because grails seems to search for layouts in plugins randomly. So let's say your main app doesn't have a layouts/main.gsp, so you're expecting that when you call a web page in your plugin, the plugin should pick up its own layouts/main.gsp, but it doesn't. Instead it seems to pick up a layouts/main.gsp from a random plugin, which is highly likely to be the boilerplate "Welcome to grails" crap, that a lot of plugin writers have just left lying around in their code.

Now you might say, well don't call your layout "main", which is fair, however:

  1. We had a situation where it was working fine running as a jar, but not running correctly in Tomcat, seemingly because in one case it randomly picked correctly, and the other time it randomly did not pick correctly. This took an inordinate amount of effort and debugging to try and come to terms with what is going on.

  2. People just go with the flow generally, which means there's a lot of plugins out there using main.gsp as their layout, because the template code does that. That means people are releasing plugins that may work for them, but may not work for you.

  3. If you call it something else, it still might conflict with another plugin.

I would suggest that the correct order to search for layouts is (1) in the same plugin as the view (2) in the main application, (3) maybe alphabetically by plugin, or some other deterministic, albeit not very interesting order. Or even better, be able to specify a search order.

I realise a case could be made for swapping (1) and (2) above, and that's kinda the current way it works, but I would suggest that the order above will lead to the least unpleasant surprises, which is to search first in view's plugin, but there should be a config item so you can do it the other way.

It also wouldn't hurt if this report #10110 was implemented, and the template code specified what layout to apply.

Actual Behaviour

layout seems to be searched for randomly in plugins.

Steps To Reproduce

  1. create plugin that has views and main.gsp layout.
  2. embed plugin into top level grails app.
  3. include a bunch of other plugins for good measure.
  4. run the app and look at one of the views. There's a good chance it will pick up a different main.gsp layout than the one in the plugin that it relates to.

Environment Information

windows
java 17

Example Application

No response

Version

5.3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant