Announcement Announcement Module
Collapse
No announcement yet.
Same Controller, different views Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Same Controller, different views

    Hi,

    I'm developing a web site in which you can login from almost every page. The login action is the same to every page but always it must return to the page from which the action has been launched. My idea is to manage all the login request with the same Spring controller (make it reusable) and depends on the page that called it, forward to it.

    I don't know if it is possible or if there is another way to accomplish my requirements without having to "copy" the same action on each controller.

    Thanks.
    JB.

  • #2
    Why are you reinventing the wheel I suggest using the Spring Security that already provides that functionality out of the box.

    However as a work around you could read the refferer header, store that somewhere in the session and after login redirect to that url.

    Comment


    • #3
      Thanks. You are right, I will use Spring Security as you recommended, but I just wanted to test this functionality because I will have to deal with this issue on other forms. How could I read the reffered header? could you provide me some example?

      Furthermore, once I know where to redirect, I will have to populate different pages with data from the database, so I think I should forward to different controllers instead of returning directly to the page. Do you have any idea how to do this in an elegant way?

      Thanks again.
      JB.

      Comment


      • #4
        Your URLs should point to controllers and not pages directly if they are you already have a wrong architecture imho. You can simply use the getHeader method of the HttpServletRequest to get the referrer header.

        Comment


        • #5
          ok. Yes, URL's point to controllers, but I will need to navigate among controllers. For example, "page A" populate via "controller A". "page A form" point to "controller B" and this controller should be reusable. If I want to come back to "page A" from "controller B" and populate all my web page componets (tables, labels, etc.) I'm thinking in two options: the first one is to copy all the funcionality of "controller A" to "controller B" and return to "page A" or forward to "controller B" and from this controller return to "page A". With the second option i would have to have some cases to fordward to different controllers based on referrer header. I don't know if it is a "clean" way to do this or I'm wrong...

          Comment


          • #6
            If you are implementing wizard style like functionality, which these seems for some reason, I strongly suggest Spring Web Flow instead of trying to implement your own.

            Comment

            Working...
            X