Home Struts Struts Struts2.2.1 Tags Datepicker example in struts2.2.1 framework.

Ask Questions?

View Latest Questions


 
 

Datepicker example in struts2.2.1 framework.
Posted on: January 5, 2011 at 12:00 AM
Advertisement
In this tutorial, you will see how to use date picker in struts2.2.1.

Datepicker example in struts2.2.1 framework.

In this tutorial, we will introduce you to how to implements datepicker in struts2.2.1 frame work. For this we needs an extra jar struts2-dojo-plugin.jar.

Directory structure of datepicker example.

 1- index.html 

<html>

<head>

<title>Struts2.2.1 Date Picker Example</title>

</head><body>

<hr><h2>Datepicker example in struts2.2.1</h2>

<a href="datepicker.action">Datepicker</a>

</body>

</html>

2-DatePickerAction.java

package roseindia;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import com.opensymphony.xwork2.ActionSupport;

public class DatePickerAction extends ActionSupport {

private Date date1;
public Date getDate1() {
return date1;
}
public void setDate1(Date date1) {
this.date1 = date1;
}
public Date getToday() {
return new Date();
}
public String execute() throws Exception {
return SUCCESS;
}
public String display() {
return NONE;
}
}

2-datepicker.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>

<%@ taglib prefix="sd" uri="/struts-dojo-tags" %>

<html>

<head><sd:head/><title>Struts2.2.1 Date Picker Example</title>

</head><body>

<h4>Example of Struts date picker in struts2.2.1</h4>

<s:form action="resultAction.action" method="post">

<sd:datetimepicker name="date1"

displayFormat="yyyy-MM-dd"

value="today"

label="Select Date(yyyy-mm-dd):"/>

<s:submit></s:submit></s:form>

</body></html>

4_struts.xml

<constant name="struts.enable.DynamicMethodInvocation" value="false" />

<constant name="struts.devMode" value="false" />

<package name="roseindia" extends="struts-default" >

<action name="datepicker" class="roseindia.DatePickerAction" method="display">

<result name="none">/jsp/datepicker.jsp</result>

</action>

<action name="resultAction" class="roseindia.DatePickerAction" >

<result name="success">jsp/result.jsp</result>

</action>

</package>

 

3-result.jsp

<%@ taglib prefix="s" uri="/struts-tags" %>

<html>

<head><title>Struts2.2.1 Date Picker Example</title>

</head><body>

<h4>Example of Struts date picker in struts2.2.1</h4>

Date :

<s:date name="date1" format="EEEE dd/MM/yyyy " />

</body></html>

 

index.html

datepicker.jsp

datepicker.jsp

Result.jsp

Download Select Source Code


Related Tags for Datepicker example in struts2.2.1 framework.:


DMCA.com