Struts Datetimepicker control not working

Posted on October 21, 2010


Struts Datetimepicker doesn’t work. PERIOD.

It is bulky, slow, buggy and doesn’t work in Firefox.

Just switch to jQueryUI Datepicker … it works like a breeze.

Step 1 – Download and add the links to the jQuery templates and scripts

<link type=”text/css” href=”./css/ui-lightness/jquery-ui-1.8.5.custom.css” rel=”stylesheet” />
<script type=”text/javascript” src=”./js/jquery-1.4.2.min.js”></script>
<script type=”text/javascript” src=”./js/jquery-ui-1.8.5.custom.min.js”></script>
Step 2 – Add the script for the datepicker in the <head></head>

<script type=”text/javascript”>

// Datepicker
dateFormat: ‘dd M, yy’
dateFormat: ‘dd M, yy’

Get more customization options here and dateFormat options here

Step 3 – Add the input text field (can be struts control … just name the “id” right)
<s:textfield id=”sFromDate_datepicker” name = “sFromDate”>
<s:param name=”value”><s:property value=”sFromDate”/></s:param>

<s:textfield id=”sToDate_datepicker” name = “sToDate” >
<s:param name=”value”><s:property value=”sToDate”/></s:param>

Step 4 – Show Off

Enjoy !!

Posted in: jQuery, Struts2