Announcement Announcement Module
Collapse
No announcement yet.
Multiple command beans on a page + redirect to originating Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Multiple command beans on a page + redirect to originating

    I'm considering porting a WebWork app to Spring MVC framework. I'm new to Spring so please bear with me.

    The app has an included login form which allows the user to log in from any page? When successfully logged in the user should be returned to whatever page he/she was on last. This raises two questions:
    • What is the correct way of dealing with the fact that the bean backing the loginform (mine uses <spring:bind ../> )needs to be present in the context on every page? From the examples I've seen, there can be only one bean associated with each form controller. I've probably missed something obvious.

      What is the correct way of obtaining and using the return view? In my WebWork app, I made sure the originating URL was always present in the request, and declared a result like so:
    Code:
    <result name="success" type="redirect">
       <param name="location">$&#123;originUrl&#125;</param>
       <param name="parse">true</param>
    </result>
    I assume there is an equivalent in Spring MVC?

    Would appreciate any assistance, since I need to decide on the MVC framwork pretty soon.

    Thanks,
    - Sven

  • #2
    Hi Sven

    Check out the sample apps in the Spring distribution directory. /petclinic is pretty basic.

    What is the correct way of dealing with the fact that the bean backing the loginform (mine uses <spring:bind ../> )needs to be present in the context on every page?
    If you have that request on your app, then put the loginform backing object in the HttpSession, and retrieve it in every subsequent controller, using either "normal" code or AOP.

    Code:
    What is the correct way of obtaining and using the return view?
    You declare it in the servlet-xml or by method setSuccessView() in the controller.

    Comment


    • #3
      Thanks for the reply.
      If you have that request on your app, then put the loginform backing object in the HttpSession, and retrieve it in every subsequent controller, using either "normal" code or AOP.
      I would think that an interceptor would be the way to go. Otherwise I'd end up with dependencies among completely unrelated controllers. Surprised that there isn't a standard fix around somwhere. I would expect that any app with included "portlet-style" forms would have this problem.
      You declare it in the servlet-xml or by method setSuccessView() in the controller.
      Does spring keep the originating URL around, or do I have to introduce hidden fields in my page template?

      Thanks,
      - S

      Comment

      Working...
      X