老牛拉磨
Share your knowledge with the world!
BlogJava
首頁
新隨筆
聯系
聚合
管理
隨筆-2 評論-0 文章-17 trackbacks-0
如何讓Struts2中datetimepicker 標簽的輸入框不可輸入
在用strust2做項目時遇到一個問題,我用struts2中datetimepicker 標簽時只想讓用戶用后面的選擇按鈕來選擇日期,
而不想讓用戶輸入,因為用戶的輸入很可能不符合日期格式的要求。
于是我就在<s: datetimepicker >標簽中加入了
disabled=“true",
但是我發現這個設置根本不起作用。
我開始到網上去找這方面的資料,我發現遇到這個問題的人還真不少,但是都沒有找到好的解決方案。
于是我開始自己琢磨這這個問題,經過很多次的實驗我發現,<s: datetimepicker >控件其實是一個DIV,
他的innerHTML是的具體內容如下:
代碼內容
<
INPUT
type
=hidden
name
=""
dojoAttachPoint
="valueNode"
><
INPUT
style
="VERTICAL-ALIGN: middle; WIDTH: 7em"
name
=""
__doClobber__
="true"
dojoAttachPoint
="inputNode"
autocomplete
="off"
>
<
IMG
style
="VISIBILITY: hidden; VERTICAL-ALIGN: middle; CURSOR: hand"
alt
="Select a date"
src
="http://localhost:9998/wherp/struts/dojo/src/widget/templates/images/dateIcon.gif"
__doClobber__
="true"
dojoAttachPoint
="buttonNode"
dojoAttachEvent
="onclick: onIconClick"
>
<
DIV
class
=dojoPopupContainer
style
="DISPLAY: none; Z-INDEX: 10; POSITION: absolute"
dojoAttachPoint
="containerNode"
explodeClassName
="calendarBodyContainer"
>
<
DIV
class
=datePickerContainer
dojoAttachPoint
="datePickerContainerNode"
>
<
TABLE
class
=calendarContainer
cellSpacing
=0
cellPadding
=0
>
<
THEAD
>
<
TR
>
<
TD
class
=monthWrapper
vAlign
=top
>
<
TABLE
class
=monthContainer
cellSpacing
=0
cellPadding
=0
border
=0
>
<
TBODY
>
<
TR
>
<
TD
class
="monthCurve monthCurveTL"
vAlign
=top
></
TD
>
<
TD
class
=monthLabelContainer
vAlign
=top
><
SPAN
class
="incrementControl increase"
__doClobber__
="true"
dojoAttachPoint
="increaseWeekNode"
dojoAttachEvent
="onClick: onIncrementWeek;"
><
IMG
style
="WIDTH: 7px; HEIGHT: 5px"
alt
=↓
src
="http://localhost:9998/wherp/struts/dojo/src/widget/templates/images/incrementMonth.png"
>
</
SPAN
><
SPAN
class
="incrementControl increase"
__doClobber__
="true"
dojoAttachPoint
="increaseMonthNode"
dojoAttachEvent
="onClick: onIncrementMonth;"
><
IMG
alt
=↓
src
="http://localhost:9998/wherp/struts/dojo/src/widget/templates/images/incrementMonth.png"
dojoAttachPoint
="incrementMonthImageNode"
>
</
SPAN
><
SPAN
class
="incrementControl decrease"
__doClobber__
="true"
dojoAttachPoint
="decreaseWeekNode"
dojoAttachEvent
="onClick: onIncrementWeek;"
><
IMG
style
="WIDTH: 7px; HEIGHT: 5px"
alt
=↑
src
="http://localhost:9998/wherp/struts/dojo/src/widget/templates/images/decrementMonth.png"
>
</
SPAN
><
SPAN
class
="incrementControl decrease"
__doClobber__
="true"
dojoAttachPoint
="decreaseMonthNode"
dojoAttachEvent
="onClick: onIncrementMonth;"
><
IMG
alt
=↑
src
="http://localhost:9998/wherp/struts/dojo/src/widget/templates/images/decrementMonth.png"
dojoAttachPoint
="decrementMonthImageNode"
>
</
SPAN
><
SPAN
class
=month
dojoAttachPoint
="monthLabelNode"
>
四月
</
SPAN
></
TD
>
<
TD
class
="monthCurve monthCurveTR"
vAlign
=top
></
TD
></
TR
></
TBODY
></
TABLE
></
TD
></
TR
></
THEAD
>
<
TBODY
>
<
TR
>
<
TD
colSpan
=3
>
<
TABLE
class
=calendarBodyContainer
cellSpacing
=0
cellPadding
=0
border
=0
>
<
THEAD
>
<
TR
dojoAttachPoint
="dayLabelsRow"
>
<
TD
>
日
</
TD
>
<
TD
>
一
</
TD
>
<
TD
>
二
</
TD
>
<
TD
>
三
</
TD
>
<
TD
>
四
</
TD
>
<
TD
>
五
</
TD
>
<
TD
>
六
</
TD
></
TR
></
THEAD
>
<
TBODY
__doClobber__
="true"
dojoAttachPoint
="calendarDatesContainerNode"
dojoAttachEvent
="onClick: _handleUiClick;"
>
<
TR
dojoAttachPoint
="calendarWeekTemplate"
>
<
TD
class
=previousMonth
>
28
</
TD
>
<
TD
class
=previousMonth
>
29
</
TD
>
<
TD
class
=previousMonth
>
30
</
TD
>
<
TD
class
=previousMonth
>
31
</
TD
>
<
TD
class
=currentMonth
>
1
</
TD
>
<
TD
class
=currentMonth
>
2
</
TD
>
<
TD
class
=currentMonth
>
3
</
TD
></
TR
>
<
TR
dojoAttachPoint
="calendarWeekTemplate"
>
<
TD
class
=currentMonth
>
4
</
TD
>
<
TD
class
=currentMonth
>
5
</
TD
>
<
TD
class
=currentMonth
>
6
</
TD
>
<
TD
class
=currentMonth
>
7
</
TD
>
<
TD
class
=currentMonth
>
8
</
TD
>
<
TD
class
=currentMonth
>
9
</
TD
>
<
TD
class
=currentMonth
>
10
</
TD
></
TR
>
<
TR
dojoAttachPoint
="calendarWeekTemplate"
>
<
TD
class
=currentMonth
>
11
</
TD
>
<
TD
class
=currentMonth
>
12
</
TD
>
<
TD
class
=currentMonth
>
13
</
TD
>
<
TD
class
=currentMonth
>
14
</
TD
>
<
TD
class
=currentMonth
>
15
</
TD
>
<
TD
class
=currentMonth
>
16
</
TD
>
<
TD
class
=currentMonth
>
17
</
TD
></
TR
>
<
TR
dojoAttachPoint
="calendarWeekTemplate"
>
<
TD
class
=currentMonth
>
18
</
TD
>
<
TD
class
="currentMonth currentDate"
>
19
</
TD
>
<
TD
class
=currentMonth
>
20
</
TD
>
<
TD
class
=currentMonth
>
21
</
TD
>
<
TD
class
=currentMonth
>
22
</
TD
>
<
TD
class
=currentMonth
>
23
</
TD
>
<
TD
class
=currentMonth
>
24
</
TD
></
TR
>
<
TR
dojoAttachPoint
="calendarWeekTemplate"
>
<
TD
class
=currentMonth
>
25
</
TD
>
<
TD
class
=currentMonth
>
26
</
TD
>
<
TD
class
=currentMonth
>
27
</
TD
>
<
TD
class
=currentMonth
>
28
</
TD
>
<
TD
class
=currentMonth
>
29
</
TD
>
<
TD
class
=currentMonth
>
30
</
TD
>
<
TD
class
=nextMonth
>
1
</
TD
></
TR
>
<
TR
dojoAttachPoint
="calendarWeekTemplate"
>
<
TD
class
=nextMonth
>
2
</
TD
>
<
TD
class
=nextMonth
>
3
</
TD
>
<
TD
class
=nextMonth
>
4
</
TD
>
<
TD
class
=nextMonth
>
5
</
TD
>
<
TD
class
=nextMonth
>
6
</
TD
>
<
TD
class
=nextMonth
>
7
</
TD
>
<
TD
class
=nextMonth
>
8
</
TD
></
TR
></
TBODY
></
TABLE
></
TD
></
TR
></
TBODY
>
<
TFOOT
>
<
TR
>
<
TD
class
=yearWrapper
colSpan
=3
>
<
TABLE
class
=yearContainer
cellSpacing
=0
cellPadding
=0
border
=0
>
<
TBODY
>
<
TR
>
<
TD
class
=curveBL
vAlign
=top
></
TD
>
<
TD
vAlign
=top
>
<
H3
class
=yearLabel
><
SPAN
class
=previousYear
__doClobber__
="true"
dojoAttachPoint
="previousYearLabelNode"
dojoAttachEvent
="onClick: onIncrementYear;"
>
2009年
</
SPAN
><
SPAN
class
=selectedYear
dojoAttachPoint
="currentYearLabelNode"
>
2010年
</
SPAN
><
SPAN
class
=nextYear
__doClobber__
="true"
dojoAttachPoint
="nextYearLabelNode"
dojoAttachEvent
="onClick: onIncrementYear;"
>
2011年
</
SPAN
></
H3
></
TD
>
<
TD
class
=curveBR
vAlign
=top
></
TD
></
TR
></
TBODY
></
TABLE
></
TD
></
TR
></
TFOOT
></
TABLE
></
DIV
></
DIV
>
第一個子元素是一個隱藏域的表單,
第二個就是我們看見的文本輸入框.
日期控件的如下:
<
s:datetimepicker
name
="starttime"
id
="starttime"
displayFormat
="yyyy-MM-dd"
></
s:datetimepicker
>
我們想要做的就是讓第二個子元素的disabled="true",所以我們可以這么做:
然后寫javascript,代碼如下:
document.getElementById(
"
starttime
"
).childNodes(
1
).disabled
=
"
true
"
;
其中childNodes(1)代表是第二個子元素,也就是我們不想讓用戶輸入的文本框。
目的達到。
但是這又遇到了另外一個問題設置成disabled的時候,Action中獲取不到頁面中相應的值.
用如下方式:
document.getElementById("startTimeId").childNodes(1).setAttribute("readOnly","true");
或document.getElementById("starttime").childNodes(1).readOnly="true"; //注意readOnly中o大寫
就能獲取值了.
我又嘗試隱藏選擇按鈕圖片:
document.getElementById("startTimeId").childNodes(2)獲取第三個元素的時候發現是空格(狂暈).
document.getElementById("startTimeId").childNodes(3)才是那個圖片!
document.getElementById("startTimeId").childNodes(3).style.display = "none"; //刪掉圖片原來所占的位置
document.getElementById("startTimeId").childNodes(3).style.visibility = "hidden"; //保留圖片位置.
一切ok!
posted on 2010-03-10 14:06
lameer
閱讀(3052)
評論(0)
編輯
收藏
所屬分類:
struts2學習
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
struts2 變慢的處理辦法
Weblogic 10下JSP el與ognl的問題與解決方法
如何讓Struts2中datetimepicker 標簽的輸入框不可輸入
struts2中iterator標簽的相關使用(轉)
JSP代碼段中直接訪問值valuestack棧內容(轉)
在javascript中讀取struts2 s:datetimepicker中的值(轉)
<
2025年5月
>
日
一
二
三
四
五
六
27
28
29
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
常用鏈接
我的隨筆
我的文章
我的評論
我的參與
留言簿
給我留言
查看公開留言
查看私人留言
隨筆分類
POI
文章分類
Java(2)
Maven(1)
struts2學習(6)
設計模式(1)
文章檔案
2019年4月 (1)
2018年5月 (1)
2015年7月 (1)
2013年1月 (1)
2012年4月 (1)
2011年3月 (2)
2010年8月 (2)
2010年3月 (1)
2009年11月 (2)
2009年9月 (1)
2009年8月 (1)
2009年4月 (1)
收藏夾
struts2標簽學習(7)
最新隨筆
1.?初識Maven
2.?Poi之Word文檔結構介紹(轉發)
3.?設計模式分類
4.?window.open出現session超時!
5.?struts2 變慢的處理辦法
6.?weblogic 密碼丟失的問題
7.?clob
8.?Weblogic 10下JSP el與ognl的問題與解決方法
9.?如何讓Struts2中datetimepicker 標簽的輸入框不可輸入
10.?關于Object中clone()方法,詳解
搜索
最新評論
閱讀排行榜
評論排行榜
Powered by:
博客園
模板提供:
滬江博客
Copyright ©2025 lameer
主站蜘蛛池模板:
jzzijzzij在线观看亚洲熟妇
|
久香草视频在线观看免费
|
日韩免费视频播播
|
国产成人无码免费看片软件
|
久久久久亚洲av无码专区喷水
|
久久国产乱子精品免费女
|
久久精品国产亚洲AV电影
|
在线免费观看一级毛片
|
中文字幕av免费专区
|
亚洲欧洲日产专区
|
亚洲精品国精品久久99热
|
18禁成人网站免费观看
|
免费人成视频在线播放
|
亚洲高清免费在线观看
|
heyzo亚洲精品日韩
|
国产人成免费视频网站
|
免费手机在线看片
|
亚洲六月丁香六月婷婷蜜芽
|
亚洲中文无码卡通动漫野外
|
久久久青草青青国产亚洲免观
|
菠萝菠萝蜜在线免费视频
|
亚洲日本中文字幕区
|
国产又大又黑又粗免费视频
|
免费看一级一级人妻片
|
精品无码一区二区三区亚洲桃色
|
国产精品免费电影
|
亚洲大片免费观看
|
国产精品1024在线永久免费
|
亚洲精品亚洲人成在线播放
|
亚洲精品无码成人片久久
|
小小影视日本动漫观看免费
|
免费H网站在线观看的
|
成人电影在线免费观看
|
黄色网址在线免费观看
|
亚洲日韩国产一区二区三区在线
|
人成午夜免费大片在线观看
|
亚洲中文字幕精品久久
|
亚洲宅男永久在线
|
亚洲精品无码久久久久去q
|
亚洲一区二区三区AV无码
|
免费看的黄色大片
|