Results 1 to 3 of 3

Thread: Multiple command beans on a page + redirect to originating

  1. #1
    Join Date
    Nov 2004
    Posts
    2

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default

    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.
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  3. #3
    Join Date
    Nov 2004
    Posts
    2

    Default

    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

Similar Threads

  1. Replies: 22
    Last Post: Feb 4th, 2010, 01:37 AM
  2. Pageable data list with Hibernate
    By robmorgan in forum Data
    Replies: 23
    Last Post: Jul 24th, 2006, 06:12 PM
  3. Redirect before rendering page
    By prinsinn in forum Web
    Replies: 5
    Last Post: Oct 21st, 2005, 05:49 PM
  4. Redirect page for unauthorized access
    By gmansoor in forum Security
    Replies: 3
    Last Post: Jul 15th, 2005, 01:20 PM
  5. Replies: 1
    Last Post: Feb 25th, 2005, 07:12 AM

Posting Permissions

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