Announcement Announcement Module
Collapse
No announcement yet.
Sending Object From One Controller to Another controller Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sending Object From One Controller to Another controller

    Hi,

    I am having two pages, first page having a form and am populating the form element with a command class, and am redirecting to another view, and how i will display the form details stored in the command class in that view?


    Regards,


    Vijay Mohan
    Last edited by vijaymohanp; Jan 3rd, 2009, 11:36 AM.

  • #2
    Hi,

    As far as I could understand , you have two pages one with a form that the user can use to key in values, the user clicks on submit, you persist the values and then redirect the user to another page which typically is like a success page.

    consider using SimpleFormController,

    in the
    Code:
    public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors)
    call your service layer which takes care of persisting the command object and then before returning a ModelAndView do the following.
    Code:
    ModelAndView mv = new ModelAndView("whateverviewname");
    // extract data from the command object that you would like to show in the view
    Map map = new HashMap();
    // put the data for example if the command object contains firstName
    map.put("firstName",firstName);
    // now add the map to the ModelAndView
    mv.addAllObjects(map);
    In the success jsp , you could extract the first name using the following code.
    Code:
    <c:out value="${firstName}"/>
    I hope it helps

    Comment

    Working...
    X