Re: [Webwork-devel] Access to the view location
Brought to you by:
baldree,
rickardoberg
From: Rickard <ri...@mi...> - 2002-01-15 15:37:34
|
Jim...@do... wrote: > We have run into a problem, however, with relative pathing in our web > pages. In the early stages we successfully used relative pathing to access > stylesheets and images from our views. Given the simple structure: > > index.html > css/default.css > cat/index.html > dog/index.html > > We invoke the actions with a URL like http://host/myapp/dog/myaction.action > > The view.properties file contains: > myaction.action.success=index.html > > The file /dog/index.html references the stylesheet as ../css/default.css. > All is well. Our HTML tools like it, and all works fine. > > The problems begin when an action can map to more than one view that may > be in different directory hierarchies. In this case, an action that is in > the "root" directory, (ie: http://host/myapp/myaction.action), that forwards to /dog/myaction.action, will end up displaying > incorrectly because the stylesheet could not be located. The problem is > that the paths in the resulting view are relative to the browser's URL, in > this case the action's path. Why don't you invoke the action in the right directory then? > I have seen some attempts to circumvent this problem by using a redirect > page or an action. I find this a little cumbersome, especially when form > parameters need to be passed. You could also reference the CSS by using absolute filenames, but generated with the <url> tag so that the context is included. > We are trying to circumvent the problem by using the <base href=""/> tag > in all of our views. This tag is also auto-generated by our action. The > trick is setting the <base> tag to the URL of the *view*. Unfortunately, > the action does not currently have any knowledge of the view. To alleviate > this problem, we added a request property setting to the > DispatcherServlet: > > aRequest.setAttribute("webwork.view_uri", view); > > Will it be possible to add this as a patch to WebWork? Hm.. maybe, but I want to make sure that this problem cannot be solved through other means first. /Rickard -- Rickard Öberg Author of "Mastering RMI" Chief Architect, TheServerSide.com The Middleware Company - We Build Experts! |