[Webwork-devel] Access to the view location
Brought to you by:
baldree,
rickardoberg
From: <Jim...@do...> - 2002-01-15 15:23:04
|
Hi guys, We are developing a large WebWork app for State government, and it is going very well. 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. 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. 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? - jim |