Results 1 to 9 of 9

Thread: Usage of PorpertyEditors

  1. #1

    Default Usage of PorpertyEditors

    Hi,

    we try to bind an object of type java.util.Date to a form. We have used the Birthdate example code to get it work. A date which is entered in the allowed format gets converted correctly when the form is submitted. Unfortunately, the other way around does not work. The date is printed out in the standard date format. Is the PropertyEditor only responsible for mapping strings in other objects? Should we use fmt:formatDate in the JSP to print out the date in the right format?

    A second question is how we allow different formats for dates entered in the same form. Right now, we can only set one PropertyEditor which is responsible for the date datatype. Is there a way to register multiple PropertyEditors for one datatype?

    Thanks in advance!

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    I recently wrote a blogpost about it, because it seems to be some kind of a FAQ.

    Check it out here
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Thanks for the quick answer. We did it just the way you explained it. Unfortunately, the date is not printed out like we specified it in the SimpleDateFormat. Any hints?

  4. #4
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,695

    Default

    No hints without seeing any code and configuration. It probably is some coding/configuration issue.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  5. #5
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    You could be having an alwaysRedirectOnPause side-effect. Check the following tip for some insights:
    http://www.ervacon.com/products/swf/tips/tip4.html

    Regarding different date formats for the same form. Just register your property editor for a particular field instead of for the "java.util.Date" type. The DataBinder has API for this.

    Erwin
    Last edited by klr8; Feb 19th, 2007 at 08:43 AM. Reason: Fixed URL

  6. #6

    Default

    Unfortunately, we found out that it is a alwaysRedirectOnPause problem. Without the usage of the PRG pattern everything works fine. But this would mean that PropertyEditors for form binding can only be used if the PRG pattern is avoided. Am I right? This would also mean that a central feature of SWF can not be used. So, the question is: What would be the right way to do this? Or is this a bug in SWF?

    Thanks for clarifying this

  7. #7
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    But this would mean that PropertyEditors for form binding can only be used if the PRG pattern is avoided. Am I right?
    No. Read that tip again. You should be calling setupForm during the render actions of your view state to re-register any property editors.

    Erwin

  8. #8

    Default

    Of course, you're right. I apologize. Now we are using setupForm() in RenderActions where we also want to use PropertyEditors. Would it be a general advice to call setupForm() as a RenderAction?

  9. #9
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    Absolutely.

    Erwin

Posting Permissions

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