<bean id="wroFilter" class="ro.isdc.wro.http.ConfigurableWroFilter">
<property name="debug" value="${wrofilter.debug}"/>
<property name="cacheUpdatePeriod" value="${wrofilter.cacheUpdatePeriod}"/>
<property name="modelUpdatePeriod" value="${wrofilter.modelUpdatePeriod}"/>
<property name="disableCache" value="${wrofilter.disableCache}"/>
<property name="encoding" value="${wrofilter.encoding}"/>
<property name="gzipEnabled" value="${wrofilter.gzipEnabled}"/>
<property name="wroManagerFactory" ref="wroManagerFactory"/>
</bean>
<bean id="wroManagerFactory" class="ro.isdc.wro.manager.factory.DefaultWroManagerFactory">
<property name="preProcessors" value="${wrofilter.preprocessors}"/>
<property name="postProcessors" value="${wrofilter.postprocessors}"/>
</bean>
Can you please provide an example about how to specify the processors with Spring?
For example I have a controller method like the following:
@RequestMapping(value="/script.js", method = RequestMethod.GET)
public String login(ModelMap model) {
return "script";
}
Then in "script.jsp" I have some javascript created dynamically, for example:
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>
var role = "";
<sec:authorize ifAllGranted="role1">
role += "role1";
</sec:authorize>
<sec:authorize ifAllGranted="role2">
role += "role2";
</sec:authorize>
alert(role);
Finally in wro.xml i have:
<group name="g1">
<js>/script.js</js>
</group>
At the moment when i try to access /wro/g1.js I get the following error:
Grave: Servlet.service() for servlet jsp threw exceptionjava.lang.NullPointerExceptionat org.apache.jsp.WEB_002dINF.pages.js_jsp._jspService(js_jsp.java:150)
I was wondering:
- Is this approach correct?
- If not, what's the correct way to process javascript in JSP (if any..)?
- If yes, do you see any glitch in my code or maybe you can provide a snippet of working code?
uriLocators=servletContext.DISPATCHER_FIRST
I can't help you with wro4j, but what I generally do instead of dynamically generating scripts is to create a namespaced data object in the page, that other functions access. In your case, that might be
APP.security = { roles: [...] };
That way, static scripts can expect the roles array to be filled. Seems simpler to me than generating whole scripts via wro4j.