Struts2 日歷選擇框 標簽<sx:datetimepicker.../>詳解
先導入struts2-dojo-plugin-2.1.6.jar,再在jsp頁面最開頭加上:
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
在<html> </html>中加入<sx:head />:head標簽的功能是生成頁面文件的HEAD部分,它還生成了對Ajax框架dojo的配置文件的引用或代碼。
下面的代碼直接就實現了日歷選擇框:
<sx:datetimepicker label="日歷" name="calendar" value="today" toggleType="plain" toggleDuration="300" language="zh_CN" type="date" displayWeeks="5" displayFormat="dd/MM/yyyy" formatLength="long" />
Parameters:
(注:toggle['t?g(?)l]觸發)
最后的效果如下圖:
value屬性的寫法還有:
<sx:datetimepicker value="%{date}"/>
<sx:datetimepicker value="%{'2007-01-01'}"/>
datetimepicker標簽解析:
Description:
Renders a date/time picker in a dropdown(下拉) container.
A stand-alone DateTimePicker widget(文本桌面) that makes it easy to select a date/time, or increment by week, month, and/or year.
It is possible to customize the user-visible formatting with either the 'formatLength' (long, short, medium or full) or 'displayFormat' attributes. By defaulty current locale(區域設置) will be used.
參數displayFormat的所有可能取值:
Format | Description | </tr>|||||||||||||||||||||||||
d | Day of the month | </tr>|||||||||||||||||||||||||
D | Day of year | </tr>|||||||||||||||||||||||||
M | Month - Use one or two for the numerical month, three for the abbreviation, or four for the full name, or 5 for the narrow name. | </tr>|||||||||||||||||||||||||
y | Year | </tr>|||||||||||||||||||||||||
h | Hour [1-12]. | </tr>|||||||||||||||||||||||||
H | Hour [0-23]. | </tr>|||||||||||||||||||||||||
m | Minute. Use one or two for zero padding. | </tr>|||||||||||||||||||||||||
s | Second. Use one or two for zero padding. | </tr> </tbody> </table>