struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Li Ying <>
Subject Re: Dynamically setting the template directory in an Action
Date Mon, 21 Nov 2011 06:57:33 GMT
(1)I believe the word [template] in struts2 means,
the template file to render a struts2 tag.
for example, the file
is a template file to render the tag <s:form> using theme "xhtml"

(2)what you are trying to do, is to change the jsp file location which
will be used to render the action result. This is different to the
maybe you can use [Parameters in action result definitions], described
by the following document:

2011/11/11 Chris Rijk <>:
> Hi all,
> Referring to this page:
> It says the template directory can be specified in the session, for example to allow
the user to change it on a per-session basis. I've been trying to do this for my application,
but can't get it to work.
> I'm using the conventions library. If I copy WEB-INF/content to WEB-INF/content2 I can
add a tag like @ResultPath(value="/WEB-INF/content2/") to an Action to change the template
directory used to render the results, and this works as expected. However, that works on a
per action/class basis, and I want to do it on a per session basis.
> I've tried setting templateDir in the session but this has no effect. Any ideas?
> For example, I've tried this in an action implementing the ServletRequestAware interface:
>    public void setServletRequest(HttpServletRequest arg0) {
>        HttpSession sess = arg0.getSession(true);
>        sess.setAttribute("templateDir", "/WEB-INF/content2/");
>    }
> I also tried implementing SessionAware, eg:
>    public void setSession(Map<String, Object> session) {
>        session.put("templateDir", "/WEB-INF/content2/");
>    }
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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

View raw message