luiscesarinfo 13 de mar. de 2008
o arquivo book.jsp segue abaixo :
< ? xml version = "1.0" ? >
< jsp : root version = "2.0"
xmlns : jsp = "http://java.sun.com/JSP/Page"
xmlns : f = "http://java.sun.com/jsf/core"
xmlns : h = "http://java.sun.com/jsf/html"
xmlns : c = "http://java.sun.com/jsp/jstl/core"
xmlns : tiles = "http://jakarta.apache.org/tiles" >
< jsp : directive . page contentType = "text/html" />
< jsp : output omit - xml - declaration = "no"
doctype - root - element = "html"
doctype - public = "-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype - system = "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
< f : view >
< html xmlns = "http://www.w3.org/1999/xhtml" >
< f : loadBundle basename = "com.corejsf.ch08.ex02.messages" var = "msgs" />
< head >
< link href = "css/styles.css" rel = "stylesheet" type = "text/css" />
< title >< h : outputText value = "#{msgs.bookWindowTitle}" /></ title >
</ head >
< body >
< f : subview id = "book" >
< h : form >
< tiles : insert definition = "book" flush = "false" />
</ h : form >
</ f : subview >
</ body >
</ html >
</ f : view >
</ jsp : root >
luiscesarinfo 13 de mar. de 2008
o arquivo headerMenuContentLayout.jsp segue abaixo:
<% @ taglib uri = "http://java.sun.com/jsf/core" prefix = "f" %>
<% @ taglib uri = "http://java.sun.com/jsf/html" prefix = "h" %>
<% @ taglib uri = "http://jakarta.apache.org/tiles" prefix = "tiles" %>
<tiles:importAttribute scope= "request" />
<h:panelGrid columns= "2" styleClass= "#{gridClass}" headerClass= "#{headerClass}"
columnClasses= "#{menuColumnClass}, #{contentColumnClass}" >
<f:facet name= "header" >
<f:subview id= "header" >
<tiles:insert attribute= "header" flush= "false" />
</f:subview>
</f:facet>
<f:subview id= "menu" >
<tiles:insert attribute= "menu" flush= "false" />
</f:subview>
<f:subview id= "content" >
<tiles:insert attribute= "content" flush= "false" />
</f:subview>
</h:panelGrid>
luiscesarinfo 13 de mar. de 2008
Alguém tem alguma idéia ?
mrmarcondes 13 de mar. de 2008
Fazer essa integracao entre jSF e Tiles eh um porre. Mas segue um exemplo.
Lembro-me que obrigatoriamente no tiles-defs.xml tem que ter o name da definition terminada com .tiles, senao o tomahawk nao funciona. Esse código deve ter +- 1 ano e usa o tomahawk para fazer a ponte entre jsf e tiles. Talvez com o tiles 2 essa integracao seja mais facil. Acho que eh mais negocio dar uma olhada no facelets ([url]http://facelets.dev.java.net/[/url ].
tiles-defs.xml:
<definition extends= "template" name= "/loja/paginas/produto/detalheProduto.tiles" >
<put name= "corpo" value= "/loja/paginas/produto/detalheProduto.jsp" />
<put name= "menuLateral" value= "/loja/paginas/template/menuLateralCategorias.jsp" />
</definition>
faces-config.xml:
<navigation-rule>
<navigation-case>
<from-outcome> mostrarDetalheProduto</from-outcome>
<to-view-id> /loja/paginas/produto/detalheProduto.jsf</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
<application>
<view-handler> org.apache.myfaces.tomahawk.application.jsp.JspTilesViewHandlerImpl</view-handler>
</application>
template.jsp
<% @ taglib uri = "http://java.sun.com/jsf/core" prefix = "f" %>
<% @ taglib uri = "http://java.sun.com/jsf/html" prefix = "h" %>
<% @taglib uri = "http://struts.apache.org/tags-tiles" prefix = "tiles" %>
<html xmlns:fo= "http://www.w3.org/1999/XSL/Format" >
<head><meta http-equiv= "Content-Type" content= "text/html; charset=UTF-8" >
<title><tiles:getAsString name= "titulo" /></title>
<link href= "styles.css" rel= "stylesheet" type= "text/css" >
<link href= "home.css" rel= "stylesheet" type= "text/css" >
<link href= "topnav.css" rel= "stylesheet" type= "text/css" >
</head>
<f:view>
<BODY MARGINHEIGHT= "0" MARGINWIDTH= "0" TOPMARGIN= "0" RIGHTMARGIN= "0" BOTTOMMARGIN= "0" LEFTMARGIN= "0" >
<TABLE WIDTH= "780" HEIGHT= "100%" CELLPADDING= "0" CELLSPACING= "0" BORDER= "0" >
<TR>
<div id= "cabecalho" >
<f:subview id= "cabecalho" >
<tiles:insert name= "cabecalho" flush= "false" />
</f:subview>
</div>
</TR>
<TR>
<div id= "menuCabecalho" >
<f:subview id= "menuCabecalho" >
<tiles:insert name= "menuCabecalho" flush= "false" />
</f:subview>
</div>
</TR>
<TR>
<TD colspan= "3" height= "6" bgcolor= "#E6E7E9" ></TD>
</TR>
<TR>
<TD colspan= "3" height= "6" ></TD>
</TR>
<TR>
<f:subview id= "menuLateral" >
<tiles:insert name= "menuLateral" flush= "false" />
</f:subview>
<f:subview id= "corpo" >
<tiles:insert name= "corpo" flush= "false" />
</f:subview>
<TD width= "108" height= "26" valign= "top" >
</TD>
</TR>
<TR>
<TD height= "26" ></TD>
<TD></TD>
<TD height= "26" ></TD>
</TR>
<TR>
<TD colspan= "3" width= "780" height= "30" >
</TD>
</TR>
<TR>
<tiles:insert name= "rodape" flush= "false" />
</TR>
</TABLE>
</BODY>
</f:view>
</html>
Marco.
luiscesarinfo 13 de mar. de 2008
Obrigado pela resposta… Tenho mais uma pergunta: tiles é muito utilizado ? ou está em desuso ?
[]'s Luis Cesar
mrmarcondes 13 de mar. de 2008
Tiles eh mais utilizado com Struts, pois era um subprojeto desse. Porem, agora virou um projeto separado e a tendencia eh que facilite a integracao com outros frameworks. O problema eh que os releases novos estao muito demorados.
Marco
luiscesarinfo 13 de mar. de 2008
Muito Obrigado pela atenção…
[]'s Luis Cesar