Chetan
Chetan

Reputation: 1707

Grails resource tag generating wrong link

I am working on a project in which different modules are divided in different custom created plugins. As for example-

So like now I have all the UI related stuff inside UiPlugin and I am working on Accounting plugin and I have controllers, services and views of all domains in this plugin only.

I am using Resource tag to get all CSS and JS from the UI plugin and have to use it inside the Accounting plugin like-

<link rel="stylesheet" type="text/css" href="${resource(dir: 'assets/css', file: "datepicker.css")}"/>

which generates http://localhost:8080/PROJECT_NAME/plugins/accountancy-plugin-0.1/assets/css/datepicker.css

but the file is located at- http://localhost:8080/PROJECT_NAME/plugins/ui-plugin-0.1/assets/css/datepicker.css

So the problem is that it is looking inside its own resources. How can I make this resource tag to look for resources in a separate(UI) plugin for resources?

Please note: The business logic has been separated from UI and hence we have multiple plugins and a separate UI plugin which is used by all plugins for getting UI and theme. So they cannot be in same plugin.

Upvotes: 4

Views: 151

Answers (1)

Saurabh Mishra
Saurabh Mishra

Reputation: 881

Use context path to provide the plugin path and also use absolute:"true" so that the URL starts from project name.

Example-

${resource(dir: 'assets/css', file: "datepicker.css", contextPath :"plugins/ui-plugin-0.1", absolute:"true" )}

<link rel="stylesheet" type="text/css" href="${resource(dir: 'assets/css', file: "datepicker.css", contextPath :"plugins/ui-plugin-0.1", absolute:"true" )}"/>

Upvotes: 2

Related Questions