Re: Javascript string formatting problem with DateTextField and DatePicker
Thanks Igor. I was already running 1.4.7, but I just upgraded to 1.4.9 and that solved the problem. But strange that the bugfix wasn't mentioned on the http://wicket.apache.org/news.html page. Regards /Jimi Igor Vaynberg-2 wrote: i think this is fixed in 1.4.7+, you should upgrade -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Javascript-string-formatting-problem-with-DateTextField-and-DatePicker-tp2241433p2243120.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Javascript string formatting problem with DateTextField and DatePicker
Hi, I tried out the DateTextField together with the Datepicker component, but it doesn't work as expected. I want it to use the format/pattern -MM-dd, and when the page is rendered it does show the date in that format, but the moment I use the datepicker (even only clicking in the button do display the datepicker calender) the date is changed to a yy-MM-dd pattern, and no matter what I do it continues to use this pattern until I refresh the page. I have tried both the wicket-datetime version and the wicket extensions version of the DateTextField, with no difference in behaivor. I wanted to try the wicket-datetime version of the DatePicker but apparently it doesn't exist any more for wicket 1.4. Things that I have tried: - // import org.apache.wicket.datetime.markup.html.form.DateTextField; // import org.apache.wicket.extensions.yui.calendar.DatePicker; DateTextField dateTextField = DateTextField.forDatePattern(dateTextField, new PropertyModelDate(this, exportDate), -MM-dd); dateTextField.add(new DatePicker()); add(dateTextField); - - // import org.apache.wicket.extensions.markup.html.form.DateTextField; // import org.apache.wicket.extensions.yui.calendar.DatePicker; // DateTextField dateTextField = new DateTextField(dateTextField, new PropertyModelDate(this, exportDate), -MM-dd); add(dateTextField); dateTextField.add(new DatePicker()); - - // import org.apache.wicket.datetime.markup.html.form.DateTextField; // import org.apache.wicket.extensions.yui.calendar.DatePicker; // DateTextField dateTextField = new DateTextField(dateTextField, new PropertyModelDate( this, exportDate), new StyleDateConverter(S-, true)) { @Override public Locale getLocale() { return new Locale(sv, SE); } }; add(dateTextField); dateTextField.add(new DatePicker()); - That last example is almost a copy paste of the example code from here: http://wicketstuff.org/wicket/dates/ ...with the difference that my locale is hard coded. The example on wicketstuff works just fine when I select the same locale. The html is simply a input field like this: - input type=text wicket:id=dateTextField/ - Does anyone have any explanation to this strange behavior? What can I do to get it to always use -MM-dd2? This is very hard for me to debug since it is client side (ie javascript) behavior, not server side java behavior. Regards /Jimi -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Javascript-string-formatting-problem-with-DateTextField-and-DatePicker-tp2241433p2241433.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Javascript string formatting problem with DateTextField and DatePicker
Ok, I managed to find the problem using the javascript debug function of Firebug, but I have no idea on how to solve it. The problematic code lies in the file wicket-date.js: 125 /** 126 * Return the result of interpolating the value (date) argument with the date pattern. 127 * The dateValue has to be an array, where year is in the first, month in the second 128 * and date (day of month) in the third slot. 129 */ 130 Wicket.DateTime.substituteDate = function(datePattern, date) { 131 day = date[2]; 132 month = date[1]; 133 year = date[0]; 134 // optionally do some padding to match the pattern 135 if(datePattern.match(/dd+/)) day = Wicket.DateTime.padDateFragment(day); 136 if(datePattern.match(/MM+/)) month = Wicket.DateTime.padDateFragment(month); 137 if(datePattern.match(/yy+/)) year = Wicket.DateTime.padDateFragment(year % 100); 138 // replace pattern with real values 139 return datePattern.replace(/d+/, day).replace(/M+/, month).replace(/y+/, year); 140 } On the line 137 it truncates the year from 2010 to 10, and simply ignores the fact that I want a 4 digit year. When I did the same debugging on the example on wicketstuff.org I found that this javascript function looked a little bit different: 80 Wicket.DateTime.substituteDate = function(datePattern, date) { 71 day = date[2]; 72 month = date[1]; 73 year = date[0]; 74 if(datePattern.match(/dd+/)) day = Wicket.DateTime.padDateFragment(day); 75 if(datePattern.match(/MM+/)) month = Wicket.DateTime.padDateFragment(month); 76 if(datePattern.match(/byy+/)) year = Wicket.DateTime.padDateFragment(year % 100); 77 return datePattern.replace(/d+/, day).replace(/M+/, month).replace(/y+/, year); 78 } Here on line 76 it sees if the datePattern matches byy+, I have no idea what that 'b' i supposed to mean, but the result is that it doesn't truncate the year from 4 to 2 digits. I also noted that these two *different* wicket-date.js files contain the exact same versioning information: YAHOO.register(wicket-date, Wicket.DateTime, {version: 1.3.0, build: rc1}); So, does anyone know what I can do to get the correct wicket-date.js? Or should I report this as a bug somewhere? The way I see it, the javascript should check if the datepattern matches and then leave the year as it is. /Jimi -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Javascript-string-formatting-problem-with-DateTextField-and-DatePicker-tp2241433p2241559.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Javascript string formatting problem with DateTextField and DatePicker
i think this is fixed in 1.4.7+, you should upgrade -igor On Thu, Jun 3, 2010 at 5:11 AM, Jimi jimi.hulleg...@mogul.com wrote: Ok, I managed to find the problem using the javascript debug function of Firebug, but I have no idea on how to solve it. The problematic code lies in the file wicket-date.js: 125 /** 126 * Return the result of interpolating the value (date) argument with the date pattern. 127 * The dateValue has to be an array, where year is in the first, month in the second 128 * and date (day of month) in the third slot. 129 */ 130 Wicket.DateTime.substituteDate = function(datePattern, date) { 131 day = date[2]; 132 month = date[1]; 133 year = date[0]; 134 // optionally do some padding to match the pattern 135 if(datePattern.match(/dd+/)) day = Wicket.DateTime.padDateFragment(day); 136 if(datePattern.match(/MM+/)) month = Wicket.DateTime.padDateFragment(month); 137 if(datePattern.match(/yy+/)) year = Wicket.DateTime.padDateFragment(year % 100); 138 // replace pattern with real values 139 return datePattern.replace(/d+/, day).replace(/M+/, month).replace(/y+/, year); 140 } On the line 137 it truncates the year from 2010 to 10, and simply ignores the fact that I want a 4 digit year. When I did the same debugging on the example on wicketstuff.org I found that this javascript function looked a little bit different: 80 Wicket.DateTime.substituteDate = function(datePattern, date) { 71 day = date[2]; 72 month = date[1]; 73 year = date[0]; 74 if(datePattern.match(/dd+/)) day = Wicket.DateTime.padDateFragment(day); 75 if(datePattern.match(/MM+/)) month = Wicket.DateTime.padDateFragment(month); 76 if(datePattern.match(/byy+/)) year = Wicket.DateTime.padDateFragment(year % 100); 77 return datePattern.replace(/d+/, day).replace(/M+/, month).replace(/y+/, year); 78 } Here on line 76 it sees if the datePattern matches byy+, I have no idea what that 'b' i supposed to mean, but the result is that it doesn't truncate the year from 4 to 2 digits. I also noted that these two *different* wicket-date.js files contain the exact same versioning information: YAHOO.register(wicket-date, Wicket.DateTime, {version: 1.3.0, build: rc1}); So, does anyone know what I can do to get the correct wicket-date.js? Or should I report this as a bug somewhere? The way I see it, the javascript should check if the datepattern matches and then leave the year as it is. /Jimi -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Javascript-string-formatting-problem-with-DateTextField-and-DatePicker-tp2241433p2241559.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org