I recommend porting to 1.4-rc2 already ;)

Alternatively you can override / patch the SqlDateConverter with a new class:

package org.apache.wicket.util.convert.converters;

public class SqlDateConverter extends AbstractConverter
{
  private static final long serialVersionUID = 1L;

  /**
   * @see 
org.apache.wicket.util.convert.IConverter#convertToObject(java.lang.String,Locale)
   */
  public Date convertToObject(final String value, Locale locale)
  {
    if (value == null || Strings.isEmpty(value))
    {
      return null;
    }
    else
    {
      return new Date(((java.util.Date)parse(getDateFormat(locale),
value, locale)).getTime());
    }
  }

  /**
   * @see 
org.apache.wicket.util.convert.converters.DateConverter#convertToObject(java.lang.String,
   *      java.util.Locale)
   */
  @Override
  public String convertToString(Object value, Locale locale)
  {
    final DateFormat dateFormat = getDateFormat(locale);
    if (dateFormat != null)
    {
      return dateFormat.format(value);
    }
    return value.toString();
  }


  /**
   * @param locale
   * @return Returns the date format.
   */
  public DateFormat getDateFormat(Locale locale)
  {
    if (locale == null)
    {
      locale = Locale.getDefault();
    }

    return DateFormat.getDateInstance(DateFormat.SHORT, locale);
  }

  @Override
  protected Class<Date> getTargetType()
  {
    return Date.class;
  }
}


2009/2/22 rolandpeng <[email protected]>:
>
> Now I use wicket 1.3.5.
>
> There is a date field in my webpage.and it is not required.
> The date class type is java.sql.date
>
> But I alway have a NullPointerException while the input of this optional
> field is empty.
> the exceptions below:
> Caused by: java.lang.NullPointerException
>        at
> org.apache.wicket.util.convert.converters.SqlDateConverter.convertToObject(SqlDateConverter.java:35)
>        at
> org.apache.wicket.markup.html.form.FormComponent.convertInput(FormComponent.java:1211)
> ...
>
> How do I fix this problem?
> Now I must set a date into my date filed  to pass the program.But this field
> is not required.
> Thanks.
> --
> View this message in context: 
> http://www.nabble.com/A-Bug-in-SqlDateConverter--tp22145097p22145097.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to