Reputation: 367
One quick question.
How can I use the "simple theme" () and "dojo datetimepicker" () together?
I have read that if you only want to use the simple theme, then manually import all the required dojo files using the code in head.ftl...
The thing is all those js are in struts dojo jar file which is included in the class path. How can I include them in the jsp? What should be the whole path? Any example will be helpful.
Upvotes: 1
Views: 4755
Reputation: 6811
1. Enable Freemarker template caching
In Struts versions prior to 2.0.10, you had to copy the /template directory from the Struts 2 jar in your WEB_APP root to utilize Freemarker's built in chaching mechanism in order to achieve similar results.
The built in Freemarker caching mechanism fails to properly cache templates when they are retrieved from the classpath. Copying them to the WEB_APP root allows Freemarker to cache them correctly. Freemarker looks at the last modified time of the template to determine if it needs to reload the templates. Resources retrieved from the classpath have no last modified time, so Freemarker will reload them on every request.
2. When overriding a theme, copy all necessary templates to the theme directory.
There's a performance cost when a template cannot be found in the current directory. The reason for this is that Struts 2 must check for a template in the current theme first before falling back to the parent theme. In the future, this penalty could be eliminated by implementing a missing template cache in Struts 2.
Example
YourWebApp |-- WebContent |-- templates |-- ajax |-- controlheader.ftl, datetimepicker.ftl, dojoRequire.js, head.ftl |-- simple |-- [All files] |-- xhtml |-- controlfooter.ftl, controlheader-core.ftl, controlheader.ftl, tooltip.ftl, validation.js
<struts>
<constant name="struts.ui.templateDir" value="templates" />
<constant name="struts.ui.theme" value="simple" />
</struts>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<head>
<sx:head />
</head>
<body>
<sx:datetimepicker name="date" />
</body>
The Datetimepicker of Ajax Tags is bad, did you consider jQuery UI Timepicker/Datetimepicker?
Upvotes: 1