RE: Tiles problem with Struts action path - Tiles and tabbeddisp lay

2002-10-14 Thread Peterkofsky, Don



Eddie -

Thanks for the pointer to the request attribute -- that got me what I
needed.


Cedric -

Here is the code snippet below, that will get the action in a robust way,
and allow us to write out the href in the tabs in a Struts-compatible way;
you may want to update your tabsLayout JSP example accordingly:

<%@ page import="org.apache.struts.config.ActionConfig" %>
<%
  String key = org.apache.struts.Globals.MAPPING_KEY;
  ActionConfig actionConfig = (ActionConfig) request.getAttribute(key);
  String action = actionConfig.getPath();
  
  ...

<% / Struts-tiles tabs rendering logic / %>

<% // compute href
  String href = request.getContextPath() +"/" + action + ".do" +
"?"+parameterName + "=" + index; // get tab link



Don P.


-Original Message-
From: Eddie Bush [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 14, 2002 10:50 AM
To: Struts Users Mailing List
Subject: Re: Tiles problem with Struts action path - Tiles and tabbed
disp lay


The action mapping is available in the request (!) under the key of 
o.a.s.Globals.MAPPING_KEY.


Peterkofsky, Don wrote:

>Cedric -
>
>While this solution will work in IE browsers and Netscape 6+ browsers, it
>isn't a particularly robust solution, as it relies on the URL in the
browser
>"location" string, and this varies depending on the particular browser
>version (try your solution on Netscape 4.7, and see what happens).  
>
>A more robust solution requires that we have access to the action path at
>the JSP level, similar to the way we do in an Action class.  In order to
>robustly render a URL based on a Tiles list, we need to know the action
path
>that initially rendered the Tile.  This suggests to me adding an attribute
>for this to the Tile object, so that a Tile is "aware" of the action path
>from which it was called.  Our other alternative is to have a custom
request
>processor, which gets the action path and puts it into a request attribute,
>which will be accessible in the destination JSP -- this is a less robust
and
>less desirable solution than having direct access to the action path
through
>some Tiles attribute.  For example, I would like to be able to do something
>like:
> action = tile.getActionPath();
>
>
>Don P.
>
-- 
Eddie Bush




--
To unsubscribe, e-mail:

For additional commands, e-mail:




--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




RE: Tiles problem with Struts action path - Tiles and tabbeddisp lay

2002-10-14 Thread Peterkofsky, Don

Cedric -

While this solution will work in IE browsers and Netscape 6+ browsers, it
isn't a particularly robust solution, as it relies on the URL in the browser
"location" string, and this varies depending on the particular browser
version (try your solution on Netscape 4.7, and see what happens).  

A more robust solution requires that we have access to the action path at
the JSP level, similar to the way we do in an Action class.  In order to
robustly render a URL based on a Tiles list, we need to know the action path
that initially rendered the Tile.  This suggests to me adding an attribute
for this to the Tile object, so that a Tile is "aware" of the action path
from which it was called.  Our other alternative is to have a custom request
processor, which gets the action path and puts it into a request attribute,
which will be accessible in the destination JSP -- this is a less robust and
less desirable solution than having direct access to the action path through
some Tiles attribute.  For example, I would like to be able to do something
like:
 action = tile.getActionPath();


Don P.

-Original Message-
From: Cedric Dumoulin [mailto:[EMAIL PROTECTED]]
Sent: Monday, October 14, 2002 2:47 AM
To: Struts Users Mailing List
Subject: Re: Tiles and tabbed display



  Hi,

  You are right that the actual code doesn't works well if you use an 
action URL instead of a jsp URL.
  The solution is to not set the page URI at all when computing the tabs 
href. Like this, the browser use the original URL. To do this, simply 
replace the offending line by:

 // compute href
  String href = "?"+parameterName + "=" + index;

 Cedric

Peterkofsky, Don wrote:

>Cedric -
>
>I've been using Struts/Tiles to implement a tabbed display page, and in
>general it works very nicely.
>
>However, I think there is an oversight in the tabsLayout example, which
will
>cause a problem in use.  This has to do with how the href is calculated for
>the links in the tabs.  In the iteration through the tabsList, this code is
>setting the href for each tab:
>
> // compute href
>  String href = request.getRequestURI() + "?"+parameterName + "=" + index;
>
>By doing this, we will end up with a link to the jsp file of the tabbed
>display page, which we don't want, rather than a link to the action that
>calls the jsp, which is what we do want.  By doing it the way it is done in
>the tabsLayout.jsp, the links from the tabs will not go through an action
>and will not go through the Struts controller, and therefore won't be able
>to process the Tiles.
>
>For example, what we want to see in a tab href is:
>
>http://localhost:8080/wctemplates/tabstemplate.do?tab=1
>
>However, what we do see is:
>
>http://localhost:8080/wctemplates/tabsLayout.jsp?tab=1
>
>
>What needs to happen, is for each tab href to be a link that is made up of
>the action name, i.e."/servlet/tabAction.do?selected=1".
>
>Have you experienced this issue, or had any previous inquiries about this?
>What are your thoughts?
>
>Thanks,
>Don Peterkofsky
>
>
>--
>To unsubscribe, e-mail:

>For additional commands, e-mail:

>
>
>  
>


--
To unsubscribe, e-mail:

For additional commands, e-mail:




--
To unsubscribe, e-mail:   
For additional commands, e-mail: