Results 1 to 4 of 4

Thread: CustomDateEditor problems with Spring 1.1

  1. #1
    Join Date
    Aug 2004
    Location
    Saint Louis, MO
    Posts
    6

    Default CustomDateEditor problems with Spring 1.1

    After upgrading from v1.0.2 to v1.1 yesterday, I have encountered a problem with the CustomDateEditor. Essentially, it neither formats the java.util.Date property in my INPUT field (it displays using the default date format) nor recognizes dates of any format when submitting the form (the property value is null, thus generating a validation error). This all worked fine in 1.0.2.

    Excerpt from JSP
    Code:
    <form method="post">
      ...other fields...
    
      <label>
        Order Date
        <spring&#58;bind path="order.orderDate">
          <input type="text" class="text-medium"
                 name="<c&#58;out value="$&#123;status.expression&#125;"/>"
                 value="<c&#58;out value="$&#123;status.value&#125;"/>">
          <span class="error"><c&#58;out value="$&#123;status.errorMessage&#125;"/></span>
        </spring&#58;bind>
      </label>
              
        <input type="submit" class="button" value="Save"/>
    </form>
    Excerpt from AbstractWizardFormController subclass
    Code:
    protected void initBinder&#40;HttpServletRequest request,ServletRequestDataBinder binder&#41; throws Exception &#123;
        super.initBinder&#40;request, binder&#41;;
    
        DateFormat dateFormat = DateFormat.getDateInstance&#40;DateFormat.SHORT&#41;;
        binder.registerCustomEditor&#40;Order.class, "orderDate", new CustomDateEditor&#40;dateFormat, true&#41;&#41;;
        
        ...registration of other custom PropertyEditors that work fine...
        &#125;
    I looked in the changelog.txt and on this forum, but could not see anything to suggest why this code no longer works. Can anyone help me out?

    Thanks,
    Gareth Davies

  2. #2
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default Re: CustomDateEditor problems with Spring 1.1

    Quote Originally Posted by telcontar4

    Excerpt from AbstractWizardFormController subclass
    Code:
    protected void initBinder&#40;HttpServletRequest request,ServletRequestDataBinder binder&#41; throws Exception &#123;
        super.initBinder&#40;request, binder&#41;;
    
        DateFormat dateFormat = DateFormat.getDateInstance&#40;DateFormat.SHORT&#41;;
        binder.registerCustomEditor&#40;&#91;b&#93;Order.class&#91;/b&#93;, "orderDate", new CustomDateEditor&#40;dateFormat, true&#41;&#41;;
        
        ...registration of other custom PropertyEditors that work fine...
        &#125;
    Order.class should be changed to Date.clas. It should be the property you want the String to be resolved to, not the command class. Maybe the checking mechanisms changed a bit in 1.1.

  3. #3
    Join Date
    Aug 2004
    Location
    Saint Louis, MO
    Posts
    6

    Default

    Alef,

    That makes sense (and works)! I'm curious as to why the old code worked in 1.0.2, but it definitely seems correct the way it works in 1.1.

    Thanks!
    Gareth Davies

  4. #4
    Join Date
    Aug 2004
    Location
    Amsterdam, Netherlands
    Posts
    450

    Default

    I browsed along the revision history of the BeanWrapper and its collaborators when I tested this but couldn't find anything real quickly. So I guess it'll be a mystery for ever ;-)

Similar Threads

  1. Spring MVC Web Framework versus Struts
    By biguniverse in forum Web Flow
    Replies: 27
    Last Post: Aug 29th, 2012, 03:57 AM
  2. Replies: 5
    Last Post: Aug 9th, 2008, 05:30 AM
  3. A Spring Class Loader?
    By azzoti in forum Architecture
    Replies: 8
    Last Post: May 7th, 2005, 04:02 AM
  4. Replies: 14
    Last Post: Feb 21st, 2005, 05:41 PM
  5. Replies: 2
    Last Post: Jan 21st, 2005, 04:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •