I think the tiles definition attributes should be exposed through the
tiles-plugin XML file. My Wizard action is setting the nextPage so this
would eliminate the need to write a ViewPreparer to set the jsp in the tiles
definition. I am now meddling around in the Preparer trying to construct
the URL that contains the page. For this Preparer to be flexible, I really
don't want to presuppose anything.
ValueStack stack = (ValueStack) tilesContext.getRequestScope().get(
ServletActionContext.STRUTS_VALUESTACK_KEY);
String nextPage = stack.findString("nextPage");
HttpServletRequest request = (HttpServletRequest)
tilesContext.getRequest();
String fullUrl = request.getRequestURL().toString();
// find last slash and strip everything following
// int index = fullUrl.lastIndexOf("/");
// fullUrl = fullUrl.substring(0, index);
// MORE MESSY CODE HERE <-----------
// GROSS!!!
nextPage = "/tiles/wizard/"+nextPage+".jsp";
attributeContext.putAttribute(
"body",
new Attribute(nextPage));
On Thu, Apr 17, 2008 at 2:39 PM, Antonio Petrelli <
[EMAIL PROTECTED]> wrote:
> 2008/4/17, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
> > Right on Antonio! Can you tell me how to fish the web context root from
> the
> > Preparer? I need to construct the page location from this and the
> nextPage
> > itself. Is there a list of key names someplace? Finding this bit of
> data
> > or that on the stack is typically where productivity takes a nosedive.
> I
> > used this key to get the stack:
> >
> > stack = (ValueStack)
> >
>
> tilesContext.getRequestScope().get(ServletActionContext.STRUTS_VALUESTACK_KEY);
>
> Unfortunately, Tiles plugin is not "so integrated" to Struts 2, so you
> have to access the value stack in another way.
> The TilesRequestContext.getRequest returns the request object, simply
> cast it to HttpServletRequest (in most cases).
> And the use the ServletActionContext.getValueStackMethod:
>
> http://struts.apache.org/2.0.11.1/struts2-core/apidocs/org/apache/struts2/ServletActionContext.html#getValueStack(javax.servlet.http.HttpServletRequest)<http://struts.apache.org/2.0.11.1/struts2-core/apidocs/org/apache/struts2/ServletActionContext.html#getValueStack%28javax.servlet.http.HttpServletRequest%29>
>
>
> HTH
> Antonio
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
--
Scott
[EMAIL PROTECTED]