Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8297723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:31:11+00:00 2026-06-08T15:31:11+00:00

I am writing a wizard-like controller that handles the management of a single bean

  • 0

I am writing a wizard-like controller that handles the management of a single bean across multiple views. I use @SessionAttributes to store the bean, and SessionStatus.setComplete() to terminate the session in the final call. However, if the user abandons the wizard and goes to another part of the application, I need to force Spring to re-create the @ModelAttribute when they return. For example:

@Controller
@SessionAttributes("commandBean")
@RequestMapping(value = "/order")
public class OrderController
{
  @RequestMapping("/*", method=RequestMethod.GET)
  public String getCustomerForm(@ModelAttribute("commandBean") Order commandBean)
  {
    return "customerForm";
  }

  @RequestMapping("/*", method=RequestMethod.GET)
  public String saveCustomer(@ModelAttribute("commandBean") Order commandBean, BindingResult result)
  {
    [ Save the customer data ];
    return "redirect:payment";
  }

  @RequestMapping("/payment", method=RequestMethod.GET)
  public String getPaymentForm(@ModelAttribute("commandBean") Order commandBean)
  {
    return "paymentForm";
  }

  @RequestMapping("/payment", method=RequestMethod.GET)
  public String savePayment(@ModelAttribute("commandBean") Order commandBean, BindingResult result)
  {
    [ Save the payment data ];
    return "redirect:confirmation";
  }

  @RequestMapping("/confirmation", method=RequestMethod.GET)
  public String getConfirmationForm(@ModelAttribute("commandBean") Order commandBean)
  {
    return "confirmationForm";
  }

  @RequestMapping("/confirmation", method=RequestMethod.GET)
  public String saveOrder(@ModelAttribute("commandBean") Order commandBean, BindingResult result, SessionStatus status)
  {
    [ Save the payment data ];
    status.setComplete();
    return "redirect:/order";
  }

  @ModelAttribute("commandBean")
  public Order getOrder()
  {
    return new Order();
  }
}

If a user makes a request to the application that would trigger the “getCustomerForm” method (i.e., http://mysite.com/order), and there’s already a “commandBean” session attribute, then “getOrder” is not called. I need to make sure that a new Order object is created in this circumstance. Do I just have to repopulate it manually in getCustomerForm?

Thoughts? Please let me know if I’m not making myself clear.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T15:31:12+00:00Added an answer on June 8, 2026 at 3:31 pm

    Yes, sounds like you may have to repopulate it manually in getCustomerForm – if an attribute is part of the @SessionAttributes and present in the session, then like you said @ModelAttribute method is not called on it.

    An alternative may be to define a new controller with only getCustomerForm method along with the @ModelAttribute method but without the @SessionAttributes on the type so that you can guarantee that @ModelAttribute method is called, and then continue with the existing @RequestMapped methods in the existing controller.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a wizard-style application in Qt that uses a QStackedWidget to organize
I am writing an Eclipse plugin, and I have a wizard that create my
I'm writing an iPhone app that (like most apps) supports auto-rotation: You rotate your
Oracle IDE to visually = wizard (not writing sql) create views? any names? (eg
I'm writing an app that has a wizard type input section. Think MS Windows
I am writing a wizard form in rails; e.g. multiple input pages for one
I have an app that I'm writing a little wizard for. It automated a
I am currently writing a wizard-style application using Qt4. I am not using the
Writing htaccess that allows me to remove index.php from the URL can confuse search
Writing documentation in html requires some code examples. What to do with characters that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.