• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to configure tiles with JSF+Struts2 Integration ?  RSS feed

Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
Good day.
I have integrated Struts2 with JSF.But I am not able to configure Tiles with this environment.Because I used
" <package name="jsf" extends="jsf-default"
namespace="/jsf/sample-jsf"> " in struts.xml ...

And I may use Tiles with this scenerio then I have to
"extends = "tiles-default" " in struts.xml...

So I couldn't figure out this issue And I dont know what are the entries would place in struts.xml...If anyone knows give me your suggestion..Thanks in Advance

-Marimuthu Udayakumar
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I remember correctly you *can* extend multiple packages. In this case it's not likely to work, but it's easy enough to try.

When/if it doesn't, you'd need to create a package that merged the two package's peculiarities together (interceptor stacks, whatever else custom they include).
Marimuthu Udayakumar
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear David Newton ,
Thanks for your suggestion , I found the solution that use of extend the multiple packages.
and I have put the entry in web.xml,struts.xml,tiles.xml files like below.Its working fine.I got the flow.





I have implemented jsf tag in all jsp files (layout.jsp.header.jsp,footer.jsp.body.jsp).But i have used <f:view></f:view> in layout jsp only and I used <f:subview id="header"> ..... </f:subview > tag for every content container like header,footer,body.

-Marimuthu Udayakumar

Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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-type name="jsf" class="org.apache.struts2.jsf.FacesResult" />

<interceptor-stack name="jsfFullStack">
<interceptor-ref name="params" />
<interceptor-ref name="basicStack"/>
<interceptor-ref name="jsfStack"/>

<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>


and my web.xml has the below content:




The tiles.xml has content like below:
<definition name="home.get.name" template="/tiles/layout.jsp">
<put-attribute name="body" value="/tiles/home.jsp"/>
<put-attribute name="footer" value="/tiles/footer.jsp"/>

The JSP file home.jsp has JSF core and html tags but I keep getting the following exception message:
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"%>
<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: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:message for="lastName" />
<br />
<h:commandButton value="Say Hello" type="submit" action="#{action.sayHello}"/>


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.
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!