• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

dateTimePicker w/o field value shows NAN on the Calendar

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm using Struts 2.1.6 and I have my sx:dateTimePicker working for the most part, but I'm running into an issue when the user removes the date in the field. It changes everything in the calendar dropdown to NAN (except for the month which is changed to 'undefined'). Is there a work around for this?

Thanks,

Fletch
 
Fletcher Munson
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I found if I add a startDate and endDate attribute this issue goes away. Though the calendar then defaults the the startDate, which in my case is about 21 years ago and not likely to be used. Does anyone have any suggestions on how to default this calendar to a preset date without any value in the field?
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys ,
I too googled for many hours for this and didnt find any solution, so i tried to do it myself and it worked out luckly

In my case i hve this datetimepicker in a TD
--------------------------------------------
<td onkeydown="Javascript:disablekeys();" onmousedown="Javascript:disableControls()">
<sx:datetimepicker id="startDate" name="startDate"></sx:datetimepicker>
</td>
--------------------------------------------

This is the outerHTML of the datetimepicker when it renders
-----------------------------------------------------------
This is document.getElementById('startDate').outerHTML;
<SPAN id=startDate>
<input type=hidden value=2009-06-11 name="" dojoAttachPoint="valueNode">
<input value=6/11/2009 name="" __doClobber__="true" dojoAttachPoint="inputNode">
<img alt="Select a date" src="../images/dateIcon.gif" __doClobber__="true" dojoAttachPoint="buttonNode" dojoAttachEvent="onclick:onIconClick">
---------------------------------------------------------------

So the solution i found out is
------------------------------
<script languae="javascript">
function disableControls(){
document.getElementById('startDate').childNodes[1].disable='true';
document.getElementById('startDate').childNodes[1].readOnly='readonly';
document.getElementById('startDate').childNodes[1].disable='';
}
function disableKeys(){
var keyCode=(document.all)?event.keyCode:e.which;
if(keyCode==9){
window.event.returnValue=true;
}else{
window.event.returnValue=false;
}
}
</script>
------------------------------

Note* -This will work unless and untill struts framework dont change the order of the childNode when rendering.

Thanks
Bharath
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have done the following to avoid the problem.

On the JSP


Action Class Input Method


Helper Class Method


That way the dateTimePicker shows the current date as the default date. If some other format is entered, the dateTimePicker replaces it with the current date automatically. If the date is removed, then in the validate() method I set the inputdob variable as null explicitly to not show NaN/NaN/NaN and add an action error.
 
If you open the box, you will find Heisenberg strangling Shrodenger's cat. And waving this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic