Struts 2 + Dojo + Datetimepicker [英] Struts 2 + Dojo + Datetimepicker

查看:64
本文介绍了Struts 2 + Dojo + Datetimepicker的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的问题。



我如何一起使用简单主题()和 dojo datetimepicker()?



我已经读到,如果您只想使用简单的主题,那么可以使用head.ftl中的代码手动导入所有必需的dojo文件...



问题是所有这些js都位于struts dojo jar文件中,该文件包含在类路径中。如何将它们包含在jsp中?整个路径应该是什么?任何示例都会有帮助。

解决方案


性能调整



<强> 1。启用Freemarker模板缓存



在2.0.10之前的Struts版本中,必须从
复制/ template
目录。在您的WEB_APP根目录中的
中使用Struts 2 jar来利用
Freemarker内置的缓存
机制,以实现类似的
结果。



<当从
类路径中检索
模板时,内置的Freemarker缓存
机制无法正确缓存
模板。将它们复制到
WEB_APP根目录可以使Freemarker正确地缓存
。 Freemarker在
模板的最后修改时间查找
,以确定是否需要
重新加载模板。从类路径中检索到的资源
没有
的上次修改时间,因此Freemarker会在每次请求时
重新加载它们。



2。覆盖主题时,请将所有必需的模板复制到主题
目录。




模板不能在
当前目录中找到。此
的原因是,Struts 2必须先检查当前主题中的
模板,然后再返回父主题
,然后再检查
。将来,可以通过在Struts 2中实现缺少
的模板缓存来消除这笔罚款







示例

 
YourWebApp
|-WebContent
|-模板
|-ajax
|-controlheader.ftl,datetimepicker.ftl,dojoRequire.js,head.ftl
|-简单
|-[所有文件]
|-xhtml
|-controlfooter.ftl,controlheader-core.ftl,controlheader.ftl,tooltip.ftl,validation.js






 < struts> 
<常量名= struts.ui.templateDir value =模板 />
<常量名= struts.ui.theme value =简单 />
< / struts>

 <%@ taglib prefix = sx uri = / struts-dojo-tags%> 
< head>
< sx:head />
< / head>
< body>
< sx:datetimepicker name = date />
< / body>






Datetimepicker Ajax标签不好,您是否考虑 jQuery UI Timepicker / Datetimepicker


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.

解决方案

Performance Tuning

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?

这篇关于Struts 2 + Dojo + Datetimepicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆