Results 1 to 2 of 2

Thread: Data binding issue String -> Domain Object

  1. #1
    Join Date
    Jul 2010
    Posts
    4

    Default Data binding issue String -> Domain Object

    I am new to alot of the technologies employed behind the scene so I will begin with what I am trying to achieve.

    I want to supply a Form with a current setting from the form backing object, but have it be immutable. Upon submission of the form I want to reference the original object supplied to the update form.

    What is happening is that I can get the update form to display the object settings, but upon submission it is coming across as null with a BindingResults error with the error being String -> Object type conversion error. This will work if I bind the property to a form:select/option pair. I took that model from the autogenerated code from Roo.

    My research points to the potential need of a custom DataBinder but I am unsure of whether or not that is necessary or how to approach doing that within the generated code.

    Thanks,

    -Pete G

  2. #2
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    667

    Lightbulb

    Just tell the existing binder to ignore that field, by adding this method to the controller:

    Code:
    @InitBinder
    public void canBeCalledAnything(WebDataBinder binder) {
        binder.setAllowedFields(...);  // leave out the immutable one
    }
    Andrew Swan
    "Now is the EJB of our discontent made glorious Spring"

Tags for this Thread

Posting Permissions

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