struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gurcharan Singh <gurcharan.sa...@gmail.com>
Subject Re: Dynamically setting the template directory in an Action
Date Thu, 08 Dec 2011 13:39:35 GMT
In the same line, I've a question - How to setup Struts2 to use templates
which are located outside document root directory. Why we want to do it -
We want to keep UI and Dev work separate and in-case any change is made in
the template, we shouldn't be re-building the whole app.

Thanks
Gurcharan

On Mon, Nov 21, 2011 at 1:19 PM, Josep GarcĂ­a <jgarcia@isigma.es> wrote:

> What I have achieved is to set the template Dir for freemarker result type,
> in web.xml:
>
>    <!-- struts/freemarker additional template loading: folder -->
>    <context-param>
>        <param-name>templatePath</param-name>
>        <param-value>${form.templateDir}</param-value>
>    </context-param>
>
> with ${form.templateDir} being replaced by maven at compile or packaging
> phases.
>
> Cheers,
> Josep
>
>
> 2011/11/21 Li Ying <liying.cn.2010@gmail.com>
>
> > (1)I believe the word [template] in struts2 means,
> > the template file to render a struts2 tag.
> > for example, the file
> >  [struts2-core-2.2.3.jar]/template/xhtml/form.ftl
> > 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
> > [template].
> > maybe you can use [Parameters in action result definitions], described
> > by the following document:
> >
> http://struts.apache.org/2.x/docs/parameters-in-configuration-results.html
> >
> >
> > 2011/11/11 Chris Rijk <chrisrijk@gmail.com>:
> > > Hi all,
> > >
> > > Referring to this page:
> > > http://struts.apache.org/2.2.1/docs/selecting-template-directory.html
> > >
> > > 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: user-unsubscribe@struts.apache.org
> > > For additional commands, e-mail: user-help@struts.apache.org
> > >
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message