Hi,
I am trying to use Strut2 plugins for JSF and Tiles together and I am facing difficulties and getting them configured to work right within a single
Struts 2 application.
My struts.xml contains package as below:
<package name="tiles" extends="tiles-default, jsf-default" namespace="/tiles">
<result-types>
<result-type name="jsf" class="org.apache.struts2.jsf.FacesResult" />
</result-types>
<interceptors>
<interceptor-stack name="jsfFullStack">
<interceptor-ref name="params" />
<interceptor-ref name="basicStack"/>
<interceptor-ref name="jsfStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="jsfFullStack"/>
<action name="Home" class="demo.action.HomeAction">
<result name="success" type="tiles">home.get.name</result>
<result name="redirect" type="tiles">say.hello.name</result>
</action>
</package>
and my web.xml has the below content:
<context-param>
<param-name>org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG</param-name>
<param-value>/WEB-INF/classes/tiles.xml</param-value>
</context-param>
<listener>
<listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
The tiles.xml has content like below:
<definition name="home.get.name" template="/tiles/layout.jsp">
<display-name>home.get.name</display-name>
<put-attribute name="body" value="/tiles/home.jsp"/>
<put-attribute name="footer" value="/tiles/footer.jsp"/>
</definition>
The JSP file home.jsp has JSF core and html tags but I keep getting the following exception message:
java.lang.NullPointerException
at javax.faces.webapp.UIComponentClassicTagBase.setJspId(UIComponentClassicTagBase.java:1858)
at org.apache.jsp.tiles.home_jsp._jspx_meth_h_005fform_005f0(home_jsp.java:119)
at org.apache.jsp.tiles.home_jsp._jspService(home_jsp.java:89)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:433)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
The home.jsp contains the below code:
<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<div>
<p>This example illustrates the Struts 2 /Tiles Plugin with JSF.</p>
<h:form id="enterNameFormId">
<h:outputText value="First Name:" />
<h:inputText id="firstName" size="30"
value="#{action.model.person.name.firstName}" required="true">
<f:validateLength minimum="2" maximum="30" />
</h:inputText>
<h:message for="firstName" />
<br />
<h:outputText value="Last Name:" />
<h:inputText id="lastName" size="30"
value="#{action.model.person.name.lastName}" required="true">
<f:validateLength minimum="2" maximum="30" />
</h:inputText>
<h:message for="lastName" />
<br />
<h:commandButton value="Say Hello" type="submit" action="#{action.sayHello}"/>
</h:form>
</div>
I am using the struts 2.0.14 binary distribution.
If any of you have configured both the plugins for JSF and Tiles in one Struts 2 app please provide me some info on the configuration that needs to be done?
Appreciate your help.
Thank you.