SpringRoo placing <script> and <link> on load-scripts.tagx from view.xml

348 Views Asked by At

A best practice of web development is to place the <styles> and <scripts> on a particular page in .css and .js file respectively.

This question might be a duplicate from this question and the answer from @java1337 get it working. From his answer file management can be an issue since for every definition of a view (.jspx) it is required to add another .jspx file containing all <link href> and <scripts src>.

One possible solution I'm working on is adding in the view.xml the URL/link of all .css and .js files that needed to be placed in the <head> section. Below is a sample of a view.xml is the structure I'm working on but I can get it working on the load-scripts.tagx

<definition extends="default" name="user/index">
   <put-attribute name="body" value="/WEB-INF/views/user/index.jspx" />
   <put-list-attribute name="scriptsList">
      <add-attribute value="/resources/scripts/user/script.js"/>
   </put-list-attribute>
</definition>

And on the load-scripts.tagx

<tiles:useAttribute id="list" name="scriptsList" classname="java.util.List"/> -->
<c:forEach var="script" items="${list }">
   <script text="text/javascript" src="${script }"></script>
</c:forEach>

From the structure above, I am getting an ServletException on the default.jspx file which might be caused by the <tiles:useAttribute>

UPDATE:

  1. The answer of @java1337 not worked but file management can be an issue as stated above.
  2. Updated the question for clarifications.
0

There are 0 best solutions below