Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML
 
 
Search All Tutorials
  

 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 
Struts
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

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 TagTag 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:

                         

Facing Programming Problem?
Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

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

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Hot Web Programming Job

Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2007. All rights reserved.