Announcement Announcement Module
Collapse
No announcement yet.
CustomDateEditor problems with Spring 1.1 Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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,

  • #2
    Re: CustomDateEditor problems with Spring 1.1

    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.

    Comment


    • #3
      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!

      Comment


      • #4
        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 ;-)

        Comment

        Working...
        X