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>ADS_TO_REPLACE_1 <head> <title>Struts2.2.1 Date Picker Example</title> </head><body>ADS_TO_REPLACE_2 <hr><h2>Datepicker example in struts2.2.1</h2> <a href="datepicker.action">Datepicker</a> </body>ADS_TO_REPLACE_3 </html> |
2-DatePickerAction.java
package roseindia; |
2-datepicker.jsp
<%@ taglib prefix="s" uri="/struts-tags" %>ADS_TO_REPLACE_4 <%@ taglib prefix="sd" uri="/struts-dojo-tags" %> <html> <head><sd:head/><title>Struts2.2.1 Date Picker Example</title>ADS_TO_REPLACE_5 </head><body> <h4>Example of Struts date picker in struts2.2.1</h4> <s:form action="resultAction.action" method="post">ADS_TO_REPLACE_6 <sd:datetimepicker name="date1" displayFormat="yyyy-MM-dd" value="today"ADS_TO_REPLACE_7 label="Select Date(yyyy-mm-dd):"/> <s:submit></s:submit></s:form> </body></html> |
4_struts.xml
<constant name="struts.enable.DynamicMethodInvocation" value="false" />ADS_TO_REPLACE_8 <constant name="struts.devMode" value="false" /> <package name="roseindia" extends="struts-default" > <action name="datepicker" class="roseindia.DatePickerAction" method="display">ADS_TO_REPLACE_9 <result name="none">/jsp/datepicker.jsp</result> </action> <action name="resultAction" class="roseindia.DatePickerAction" >ADS_TO_REPLACE_10 <result name="success">jsp/result.jsp</result> </action> </package>ADS_TO_REPLACE_11
|
3-result.jsp
<%@ taglib prefix="s" uri="/struts-tags" %> <html>ADS_TO_REPLACE_12 <head><title>Struts2.2.1 Date Picker Example</title> </head><body> <h4>Example of Struts date picker in struts2.2.1</h4>ADS_TO_REPLACE_13 Date : <s:date name="date1" format="EEEE dd/MM/yyyy " /> </body></html> |
index.htmlADS_TO_REPLACE_14
datepicker.jsp
ADS_TO_REPLACE_15
datepicker.jsp
Result.jspADS_TO_REPLACE_16
Advertisements
Ads
Ads