50 likes | 195 Views
Pure Struts web-application. layout.jsp. header.jsp. menu.jsp. body. classical include in servlet response. footer.jsp. mybody.jsp. tiles-def.xml. <definition name=" myPage " extends=" t emplate"> <put name=" body " value="/my body .jsp" /> </definition>. <html:form> …
E N D
Pure Struts web-application layout.jsp header.jsp menu.jsp body classical include in servlet response footer.jsp mybody.jsp tiles-def.xml <definition name="myPage" extends="template"> <put name="body" value="/mybody.jsp" /> </definition> <html:form> … </html:form> + struts-config.xml <action path="/showMyPage" ...> <forward name="success" path="myPage"/> </action>
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 menu.jsp body <bean:write name="body" filter="false" /> footer.jsp tiles-def.xml myJsfPage.jsp <definition name="myPage" extends="template"> </definition> <tiles:insert name="myPage"> <tiles:put name="body" type="string"> </tiles:put> </tiles:insert> + <f:use_faces> <s:form> … </s:form> </f:use_faces> struts-config.xml <action path="/showMyPage" ...> <forward name="success" path="/faces/myJsfPage.jsp"/> </action>
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