-
Nov 7th, 2006, 03:01 PM
#1
Redirecting to the original URL from an included FlowController
In my application I have my Spring MVC controllers set up such that there is one controller that draws the "shell" of the page (the html, head, and opening body tags) and uses the portion of the URL after it's mapping to get the actual variable content of the page (generated by another controller, sometimes a SWF FlowController) . For example,
The "shell" controller is mapped to /shell and returns a jsp view that resolves to view.jsp
A request issued for /shell/the/real/content will cause view.jsp to draw the shell, doing a <jsp:include/> of /the/real/content.
The intent of all this is that the controllers that provide the actual content don't have to fool with style, etc., they just focus on the fragment that they know how to generate (somewhat like a portlet).
My problem is that when I enable alwaysRedirectAfterPause, the redirect that is issued is for view.jsp, and I need it to be for /shell/the/real/content (because the information about which content to include is in the URL). I understand why that is happening, but I am wondering if there is some way to force SWF to consider the original request. I have handled this in the non-SWF controllers by using org.springframework.web.util.UrlPathHelper.getRequ estURI(), which "Return[s] the request URI for the given request, detecting an include request URL if called within a RequestDispatcher include."
I would greatly appreciate thoughts or help on this,
Caleb
-
Nov 8th, 2006, 01:11 AM
#2
One option I can think of is to refactor your shell controller into a servlet filter (or possibly a Spring HandlerInterceptor). That's basically the approach taken by SiteMesh to deliver the functionality you're looking for.
Erwin
-
Nov 8th, 2006, 09:19 AM
#3
Erwin, thank you for your suggestion, that definitely gives me some options.
After digging some more I remembered that I really had to come up with my own solution (storing the original URL in the request and writing a taglib to create URLs for posting back) to actually get this to work from my other controllers.
So I am thinking that creating my own ExternalContext that is aware of the way my environment is set up, specfically that request attribute I mentioned, might be the way to go.
I don't know the challenges involved with that, but after looking at the code, that seems to be the right place to plug in the logic. It looks like I can extend FlowController, overriding handleRequestInternal with the only difference being that I instantiate my ExternalContext impl instead of ServletExternalContext.
Does that sound reasonable?
Thanks again.
Last edited by calebphillips; Nov 8th, 2006 at 09:33 AM.
-
Nov 8th, 2006, 09:48 AM
#4
If it works that's a reasonable customization.
Erwin
-
Nov 8th, 2006, 02:47 PM
#5
Thanks, again for you response. I know this isn't strictly SWF related. I did extend FlowController and ServletExternalContext and that allowed SWF to issue redirects for the correct URLs.
I still have the problem that since the controllers are included from the jsp they cannot change the headers or response codes, so the redirect gets ignored, but that's completely unrelated to Spring and is the side effect of my design, so I will look at your suggestion about a filter or interceptor.
Thanks,
Caleb
-
Nov 8th, 2006, 02:51 PM
#6
I already mentioned it, but it might be worthwhile to take a look at SiteMesh (http://www.opensymphony.com/sitemesh/). This is a nice little library that does pretty much what you're trying to do.
Erwin
-
Nov 8th, 2006, 02:55 PM
#7
I certainly will. Thanks for the recommendation.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules