Datetimepicker Tag (Form Tag) Example
In this section, we are going to describe the datetimepicker
tag. The datetimepicker tag is a UI tag that is
used to render 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 default current locale will be used.
Add the following code snippet into the struts.xml
file.
struts.xml
<action name="datetimepickerTag" class="net.roseindia.includeTag">
<result>/pages/uiTags/datetimepickerTag.jsp</result>
</action> |
Create an action class as shown:
includeTag.java
package net.roseindia;
import com.opensymphony.xwork2.ActionSupport;
import java.util.*;
public class includeTag extends ActionSupport {
private Date myBirthday;
public String execute() throws Exception{
setMyBirthday(new Date("Jan 12, 1984 11:21:30 AM"));
return SUCCESS;
}
public void setMyBirthday(Date date){
this.myBirthday = date;
}
public Date getMyBirthday(){
return myBirthday;
}
}
|
Create a jsp using the tag
<s:datetimepicker>
This tag renders a date/time picker in a
dropdown container.
The tag <s:datetimepicker name="myBirthday" label="My Birth Day (dd-MM-yyyy)" displayFormat="dd-MM-yyyy" />
picks the data from the action
class "includeTag" using the parameter name="myBirthday"
using the display format as displayFormat="dd-MM-yyyy".
datetimepickerTag.jsp
<%@ taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
<title>Datetimepicker (Form Tag) Tag Example!</title>
<link href="<s:url value="/css/main.css"/>" rel="stylesheet"
type="text/css"/>
<s:head theme="ajax" />
</head>
<body>
<h1><span style="background-color: #FFFFcc">Datetimepicker
Tag Example!</span></h1>
<s:datetimepicker name="myBirthday" label="My Birth Day
(dd-MM-yyyy)" displayFormat="dd-MM-yyyy" />
</body>
</html>
|
Output of the datetimepickerTag.jsp:
|
Current Comments
12 comments so far (post your own) View All Comments Latest 10 Comments:Hi,
I have une jsp page with a list of datetimepicker. When I submit the form, there is an offset (lag) in array.
Date[0] => Date[3]
Date[1] => Date[0]
Date[2] => Date[1]
etc...
I don't know why...
Does anyone had this problem?
How can I resolved?
Thanks in advance
Giuseppe
Posted by Giuseppe on Wednesday, 04.16.08 @ 16:27pm | #56702
<s:file --here goes the attributes you want--></s:file>
Posted by Kiran Thankaraj on Tuesday, 03.25.08 @ 12:26pm | #54240
hello I want to know how to get its values by javascript.
can you help me
Posted by opensky on Thursday, 03.20.08 @ 14:59pm | #53465
I am trying to change the size of my datetimepicker, but requiredPosition attribute doesnt help, and also want to increase its size.
Any suggestions?
Posted by Divs on Sunday, 02.10.08 @ 00:51am | #47727
I am trying to change the size of my datetimepicker, but requiredPosition attribute doesnt help, and also want to increase its size.
Any suggestions?
Posted by Divs on Sunday, 02.10.08 @ 00:37am | #47725
The tutorial is very helpful
Posted by Prem on Monday, 12.17.07 @ 23:45pm | #42753
How can i disable all the dates prior to today's date? i dont want any past dates to be picked. If there is any way, please let me know.
Thanks and Regsrds,
Swadesh
Posted by Swadesh on Wednesday, 12.12.07 @ 16:38pm | #41945
Struts2NewUser,
Yuo need to add the tag : <s:head/> in your <head></head> section, so that dojo libraries will be included correctly
Regards
Posted by bobsinglar on Wednesday, 11.21.07 @ 20:19pm | #38205
I followed the instruction above, however, it only renders labels. Do I need to setup anything for this to work?
thanks,
Posted by strutsNewUser on Tuesday, 09.25.07 @ 20:32pm | #29329
Hi,
I like the built-in tag for date input. The tutorial is very helpful.
I'd like to know if I can customize the look and feel of the calendar. For example, I don't need to display six weeks in a month.
Thanks,
Jane
Posted by janej on Wednesday, 09.5.07 @ 00:28am | #25027