Re: [Webwork-devel] Access to the view location
Brought to you by:
baldree,
rickardoberg
From: <Jim...@do...> - 2002-01-15 15:53:21
|
Ugh...HTML email...sorry about the formatting. We do invoke the actions in the right directory, most of the time. This=20 need arose when we would forward to other actions that were in different=20 directory structures. The web resource urls (images, stylesheets, etc.)=20 would resolve to the action's URL. Also, if two actions in different=20 directory hierarchies use the same view, the same problem occurs. We are not using JSP, but we are using the <base href=3D""> tag to=20 accomplish what we need. It appears to be working fine for the time being. = We set the <base> tag to the URL of the *view*. This is constructed in our = BaseAction class by appending the full URI of the web context with the=20 path to the view. Hence, the view path must be accessible to the action. - jim Rickard <ri...@mi...> 01/15/2002 10:37 AM =20 To: Jim...@do... cc: web...@li... Subject: Re: [Webwork-devel] Access to the view location Jim...@do... wrote: > We have run into a problem, however, with relative pathing in our web=20 > pages. In the early stages we successfully used relative pathing to=20 access=20 > stylesheets and images from our views. Given the simple structure: >=20 > index.html > css/default.css > cat/index.html > dog/index.html >=20 > We invoke the actions with a URL like http://host/myapp/dog/myaction.acti= on >=20 > The view.properties file contains: > myaction.action.success=3Dindex.html >=20 > The file /dog/index.html references the stylesheet as=20 ../css/default.css.=20 > All is well. Our HTML tools like it, and all works fine. >=20 > 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=20 in=20 > the "root" directory, (ie: http://host/myapp/myaction.action), that forwa= rds to /dog/myaction.action, will end up displaying=20 > incorrectly because the stylesheet could not be located. The problem is=20 > that the paths in the resulting view are relative to the browser's URL,=20 in=20 > 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=20 generated with the <url> tag so that the context is included. > We are trying to circumvent the problem by using the <base href=3D""/> ta= g=20 > in all of our views. This tag is also auto-generated by our action. The=20 > 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=20 alleviate=20 > this problem, we added a request property setting to the=20 > DispatcherServlet: >=20 > aRequest.setAttribute("webwork.view=5Furi", view); >=20 > 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=20 through other means first. /Rickard --=20 Rickard =D6berg Author of "Mastering RMI" Chief Architect, TheServerSide.com The Middleware Company - We Build Experts! |