Tiles and JSF
Download
Report
Transcript Tiles and JSF
Pure Struts web-application
layout.jsp
header.jsp
classical
include in
servlet response
body
menu.jsp
footer.jsp
mybody.jsp
tiles-def.xml
<definition name="myPage" extends="template">
<put name="body" value="/mybody.jsp" />
</definition>
+
struts-config.xml
<action path="/showMyPage" ...>
<forward name="success" path="myPage"/>
</action>
<html:form>
…
</html:form>
Pure Struts web-application
When an action forwards to a Tiles page
The top-level template (layout.jsp) is played and runs the
include of the different sections (header, body,..)
Consequences
There is no jsp that is capable of totally displaying the "final"
web page - only the (Tiles)RequestProcessor is able to do it
• Calling "layout.jsp" will fail
• Calling "body.jsp" will partially succeed
Struts-faces web-application
layout.jsp
header.jsp
<bean:write
name="body"
filter="false" />
body
menu.jsp
footer.jsp
tiles-def.xml
<definition name="myPage" extends="template">
</definition>
struts-config.xml
<action path="/showMyPage" ...>
<forward name="success"
path="/faces/myJsfPage.jsp"/>
</action>
myJsfPage.jsp
+
<tiles:insert name="myPage">
<tiles:put name="body" type="string">
<f:use_faces>
<s:form>
…
</s:form>
</f:use_faces>
</tiles:put>
</tiles:insert>
Struts-faces web-application
Action-forwards refer to physical jsp page
• Exactly like a non-Tiles Struts application
• No more possible to foward to a logical Tiles page
Consequences
Every jsp should
• first insert the desired layout (i.e. the Tiles definition)
• then enclose the variable parts (such as its body) as parameters of
the specified layout insertion
The jsp’s are now capable of totally rendering the "final"
web page
• Calling "myJsfPage.jsp" (as JSF is used to do) will succeed