More on that, we used the newConverterLocator() in out application exactly as it is suggested in WIA, page 297. However, because the DateTextField has its own converter, we even don't get to our customized converter.
Is it a bug? Please advise. Eyal Golan [email protected] Visit: http://jvdrums.sourceforge.net/ LinkedIn: http://www.linkedin.com/in/egolan74 P Save a tree. Please don't print this e-mail unless it's really necessary On Tue, May 5, 2009 at 7:51 PM, Eyal Golan <[email protected]> wrote: > Hello, > We use Wicket 1.3.5 and I found something annoying with the DateTextField. > In the constructor of that class, the converter is created internally. > If I want to use my own converter, I need to inherit DateTextField, add a > converter as a member, and return it in the getConverter method. > > Why not have a protected method (that can be overridden) that returns the > converter: > Instead of: > public DateTextField(String id, IModel model, String datePattern) > { > super(id, model, Date.class); > this.datePattern = datePattern; > *this.converter = new DateConverter() > { > private static final long serialVersionUID = 1L; > > /** > * @see > org.apache.wicket.util.convert.converters.DateConverter#getDateFormat(java.util.Locale) > */ > public DateFormat getDateFormat(Locale locale) > { > return new > SimpleDateFormat(DateTextField.this.datePattern); > } > };* > } > > Do something like: > public DateTextField(String id, IModel model, String datePattern) > { > super(id, model, Date.class); > this.datePattern = datePattern; > *this.converter = newDateConverter();* > } > and > > protected newDateConverter() { > return new DateConverter() > { > private static final long serialVersionUID = 1L; > > /** > * @see > org.apache.wicket.util.convert.converters.DateConverter#getDateFormat(java.util.Locale) > */ > public DateFormat getDateFormat(Locale locale) > { > return new > SimpleDateFormat(DateTextField.this.datePattern); > } > }; > } > > BTW, I know that we can also use the newConverterLocator() in our > application. > > Do you think I should open a JIRA issue with 'wish' for that? > > > Eyal Golan > [email protected] > > Visit: http://jvdrums.sourceforge.net/ > LinkedIn: http://www.linkedin.com/in/egolan74 > > P Save a tree. Please don't print this e-mail unless it's really necessary >
