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.
![]() |
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; |
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
Advertisements
Ads
Ads