struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dave Newton <>
Subject Re: Running external Javascript files through Struts/Freemarker -- access to ActionContext and ValueStack?
Date Sat, 13 Nov 2010 02:09:01 GMT
If the request isn't hitting an action or the S2 interceptor stack and
filter there will not be a value stack... if you just request an ftl it
won't be processed by S2 at all, no?

Options include making an actual S2 request, passing in messages to the JS,
creating a global message object and referencing it from the JS, and so on.

On Nov 12, 2010 8:48 PM, <> wrote:
> I have an action and freemarker result that includes an external
Javascript file. This javascript files needs to be able to use the getText()
method. I figured I'd name it "util.js.ftl" so that accessing it directly
caused the sitemesh-freemarker filter to catch it, but this throws a
NullPointerException (maybe because there's no ActionContext?):
> GET /myservlet/util.js.ftl
> java.lang.NullPointerException
> javax.servlet.http.HttpServlet.service(
> javax.servlet.http.HttpServlet.service(
> rss.web.filter.SkinFilter.doFilter(
> The action is simple and just returns SUCCESS.
> <action name="index" class="com.rgm.action.IndexAction">
> <result name="success" type="freemarker">index.ftl</result>
> </action>
> Is there a recommended way for a result template to load external files
such that they are separate GET requests from the browser, but are still
parsed through the Sitemesh-Freemarker filters and servlets, with access to
the value stack? If I simply <#include "*/util.js.ftl" /> then the content
is inlined -- this is not what I'm after.
> I am using Struts 2.2.1 with Sitemesh+Freemarker Decorators as described
on the sitemesh-plugin.html doc in the "Full Integration" section.
> Sincerely,
> Roland

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