Results 1 to 3 of 3

Thread: Get access to the command object in the @InitBinder method

  1. #1
    Join Date
    Oct 2004
    Posts
    151

    Default Get access to the command object in the @InitBinder method

    Hi!

    In my @InitBinder method I call binder.setDisallowedFields(). Which fields that should be included here depends on the state of the command Object.

    I tried to get access to the command object with the follwing code:

    Code:
        @InitBinder
        public void initBinder(@ModelAttribute("myCommand") final MyCommand myCommand,
                final HttpServletRequest request, final ServletRequestDataBinder binder) throws Exception {
                
                }
    which gave me the following errormessage: @ModelAttribute is not supported on @InitBinder methods

    I could let both this methond and my @ModelAttribute method delegate the job of getting the command object based on the request but would just like to ask here if someone has found a more elegant solution

    We are using Spring 3.0.5.RELEASE.

    TIA!


    -Kaj

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

    Default

    Basically there isn't a way... InitBinder is called before the modelobject exists because the binder is needed to construct the Modelobject...
    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
    Join Date
    Oct 2004
    Posts
    151

    Default

    Quote Originally Posted by Marten Deinum View Post
    Basically there isn't a way... InitBinder is called before the modelobject exists because the binder is needed to construct the Modelobject...
    Ahh, I see! Thanks!


    -Kaj

Posting Permissions

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