Search from Struts2 Library

Showing posts with label known issues. Show all posts
Showing posts with label known issues. Show all posts

Sunday, September 21, 2008

Datetimepicker setting today's date

Here is a simple tip to initialize your datetimepicker with the current date.

For example this is your tag (Don't forget to add ajax theme in your head tag)

<s:datetimepicker label="Start Date" id="startTime" name="startTime" type="date" required="true"> </s:datetimepicker>

On body's onLoad call a java script function which will set the datatimepicker's value

function setValue() {
var picker = dojo.widget.byId("startTime");
//Date value
picker.setValue(new Date());
}

Known Issues :
  • You can not do the same thing with the datetimepicker 'Time' tag. For example if you have

<s:datetimepicker label="Start Date" id="startTime" name="startTime" type="time" required="true"> </s:datetimepicker>

Then you can not set the time on page load (If anyone has the solution please comment)
  • You can not use 'startDate' value attribute to set the initial value of the datetimepicker