Wendy Smoak wrote:

Given the following structure:
/path/to/tomcat/webapps/myApp/three.jsp
/path/to/tomcat/webapps/myApp/four.jsp
/path/to/tomcat/webapps/myApp/WEB-INF/jsp/one.jsp
/path/to/tomcat/webapps/myApp/WEB-INF/jsp/two.jsp
/path/to/tomcat/webapps/myApp/WEB-INF/jsp/header.jsp
/path/to/tomcat/webapps/myApp/WEB-INF/jsp/footer.jsp
/path/to/tomcat/webapps/myApp/WEB-INF/jsp/menu.jsp

When I use classicLayout, all of the "put" calls seem to be relative to the
location of the layout file:

The "put" call end up with a <tiles:insert attribute="attributeName" /> which internally do an include of the URL associated to the attribute.
If the URL is relative, the include call is relative to the current context path, which is generally the layout.

<tiles:insert page="WEB-INF/jsp/classicLayout.jsp" flush="true">
<tiles:put name="title" value="My first page" />
<%-- these are relative to the location of the layout,
so it's looking in WEB-INF/jsp/ --%>
<tiles:put name="menu" value="menu.jsp" />
<tiles:put name="body" value="one.jsp" />
<tiles:put name="header" value="two.jsp" />
<%-- must back up out of WEB-INF to get other files --%>
<tiles:put name="footer" value="../../four.jsp" />
</tiles:insert>

However, for vboxLayout, this is not the case:

<tiles:insert page="WEB-INF\jsp\vboxLayout.jsp" flush="true" >
<tiles:putList name="list" >
<%-- must specify path relative to the webapp root --%>
<tiles:add value="WEB-INF\jsp\header.jsp" />
<tiles:add value="WEB-INF\jsp\aBody.jsp" />
<tiles:add value="three.jsp" />
<tiles:add value="four.jsp" />
<tiles:add value="WEB-INF\jsp\footer.jsp" />
</tiles:putList>
</tiles:insert>

The "vBoxLayout " call end up with a <tiles:insert name="attributeName" /> which internally resolve the name type (attribute, definition name, url, string), and then do an insert accordingly. In the case of an attributeName, the call falls to the previous case (<insert attribute="attributeName"/>). So, both case should behave the same. If it is not the case, there is a bug ;-).
I think that what heppen in your case is that the current context path is not the same if you use vBoxLayout or classicLayout.
Also, using the WEB-INF directory to store pages could lead to strange behavior on some web containers. To check if the problem comes from Tiles or from the WEB-INF location, you should experiment your previous example in a subdirectory not under WEB-INF.

Personnally I avoid using relative paths with Tiles because it leads to some troubles when you reuse the Tiles: you usually don't know what will be the current context path, and so, you can't guess your relatives path. I advise to use absolute paths (but relative to the webapps), starting with a '/'

Also I just noticed that vboxLayout only works with the '\' separator. If I
switch to '/' it can't seem to find any of the files. :( This is running
under Tomcat 4.1.14 and the Struts nightly build from the 18th.
Normally you should be able to use indifferntly "/" or "\". The prefferred Java way is "/". Maybe this problem is linked to the fact that you try to access pages under "WEB-INF" ?


If '/' does not work on Windows, when I move this to HP-UX I suspect that
'\' will stop working.

Is this the expected behavior? I found it a little confusing as a tiles
newbie.



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to