struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Carlos Curotto" <carloscuro...@gmail.com>
Subject Re: Struts 2 + Tiles 2
Date Thu, 30 Oct 2008 11:49:47 GMT
Hi Marcio, First of all, thanks for the response.

I have tried what you told me, to put the result type explicit in the
struts.xml file, but i am getting the same exception.  I am thinking that
this could be related with the version of struts i am using (2.0.12) or with
the version of the struts-tiles plugin (2.0.12), could that be?

Here are my files again:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts
Configuration 2.0//EN" "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
    <package name="home" extends="struts-default">
        <result-types>
               <result-type name="tiles"
class="org.apache.struts2.views.tiles.TilesResult" />
          </result-types>
        <action name="Home"
class="com.sac.panorama.datagrid.console.action.HomeAction">
            <result name="success" type="tiles">home.layout</result>
        </action>
    </package>
</struts>

tiles.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
       "http://jakarta.apache.org/struts/dtds/tiles-config_2_0.dtd">

<tiles-definitions>
    <definition name="home.layout" template="/WEB-INF/layout/common.jsp">
        <put-attribute name="title" value="Panorama Grid Console"/>
        <put-attribute name="header" value="/WEB-INF/layout/header.jsp"/>
        <put-attribute name="body" value="/WEB-INF/view/home.jsp"/>
        <put-attribute name="footer" value="/WEB-INF/layout/footer.jsp"/>
    </definition>
</tiles-definitions>

tiles template:

<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "
http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
        <title><tiles:getAsString name="title"/></title>
    </head>
    <body>
        <table>
            <tr>
                <td>
                    <tiles:insertAttribute name="header" />
                </td>
            </tr>
            <tr>
                <td>
                    <tiles:insertAttribute name="body" />
                </td>
            </tr>
            <tr>
                <td>
                    <tiles:insertAttribute name="footer" />
                </td>
            </tr>
        </table>
    </body>
</html>

Any ideas?

Thanks in advance,

Carlos Curotto.

On Wed, Oct 29, 2008 at 8:16 PM, Márcio Gurgel <marcio.rga@gmail.com> wrote:

> Hi Carlos,
>
> I guess that you forgot to put a tiles result type in your struts.xml.
> Check if adding this (in your struts.xml) works:
>
> <package name="tiles-result" extends="struts-default">
>        <result-types>
>            <result-type name="tiles"
> class="org.apache.struts2.views.tiles.TilesResult" />
>        </result-types>
>    </package>
>
> *To return a tiles result use this sintax:*
>
> <action name="abrirPesquisa" method="abrirPesquisa"
> class="br.com.sgvdba.actions.pedido.PedidoPesquisaAction">
>            <result name="success"
> type="tiles">default.pedidoPesquisa</result>
>        </action>
>
>
> *My tiles.xml*
>
> <!DOCTYPE tiles-definitions PUBLIC
>    "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
>     "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
>
>    <tiles-definitions>
>        <definition name="default"
> template="/template/tiles/DefaultTemplate.jsp">
>            <put-attribute name="title"     value="SGVDBA" type="string" />
>            <put-attribute name="top"
> value="/template/tiles/DefaultTop.jsp"/>
>            <put-attribute name="menu"
> value="/template/tiles/DefaultMenu.jsp"/>
>        </definition>
>
>        <definition name="default.home" extends="default">
>            <put-attribute name="body"         value="/view/Home.jsp" />
>        </definition>
>
>        <!-- USUÁRIO -->
>        <definition name="default.usu" extends="default">
>            <put-attribute name="body"
> value="/view/usuario/UsuDadosGerais.jsp" />
>        </definition>
>
>        <definition name="default.usuPesquisa" extends="default">
>            <put-attribute name="body"
> value="/view/usuario/UsuPesquisa.jsp" />
>        </definition>
>
>        <!-- CLIENTE -->
>        <definition name="default.clienteJur" extends="default">
>            <put-attribute name="body"
> value="/view/cliente/ClienteJur.jsp" />
>        </definition>
>
>        <definition name="default.clienteFsc" extends="default">
>            <put-attribute name="body"
> value="/view/cliente/ClienteFsc.jsp" />
>        </definition>
>
>        <definition name="default.clientePesquisa" extends="default">
>            <put-attribute name="body"
> value="/view/cliente/ClientePesquisa.jsp" />
>        </definition>
>
>        <!-- FORNECEDOR -->
>        <definition name="default.fornecedor" extends="default">
>            <put-attribute name="body"
> value="/view/fornecedor/Fornecedor.jsp" />
>        </definition>
>
>        <definition name="default.fornecedorPesquisa" extends="default">
>            <put-attribute name="body"
> value="/view/fornecedor/FornecedorPesquisa.jsp" />
>        </definition>
>
>        <!-- PRODUTO -->
>        <definition name="default.produto" extends="default">
>            <put-attribute name="body"
> value="/view/produto/Produto.jsp" />
>        </definition>
>
>        <definition name="default.produtoPesquisa" extends="default">
>            <put-attribute name="body"
> value="/view/produto/ProdutoPesquisa.jsp" />
>        </definition>
>
>        <!-- NFE -->
>        <definition name="default.fornecedorNfePesquisa" extends="default">
>            <put-attribute name="body"
> value="/view/fornecedor/FornecedorNfePesquisa.jsp" />
>        </definition>
>        <!-- PEDIDO -->
>        <definition name="default.pedidoPesquisa" extends="default">
>            <put-attribute name="body"
> value="/view/pedido/PedidoPesquisa.jsp" />
>        </definition>
>        <!-- FINANCEIRO -->
>        <definition name="default.pedidoFaturaPesquisa" extends="default">
>            <put-attribute name="body"
> value="/view/financeiro/PedidoFaturaPesquisa.jsp" />
>        </definition>
>        <definition name="default.pedidoFatura" extends="default">
>            <put-attribute name="body"
> value="/view/financeiro/PedidoFatura.jsp" />
>        </definition>
>
>        <!-- PORTAL -->
>        <definition name="default.portalPedido" extends="default">
>            <put-attribute name="body"
> value="/view/portal/Pedidos.jsp" />
>        </definition>
>        <definition name="default.portalProduto" extends="default">
>            <put-attribute name="body"
> value="/view/portal/Produtos.jsp" />
>        </definition>
>        <definition name="default.portalNfe" extends="default">
>            <put-attribute name="body"         value="/view/portal/Nfes.jsp"
> />
>        </definition>
>
>    </tiles-definitions>
>
>
>
> Sorry about non-english code /:
>
> Márcio Gurgel
>
> 2008/10/29 Carlos Curotto <carloscurotto@gmail.com>
>
> > Hi everyone,
> >
> > I am trying to configure Struts 2 version 2.0.12 and Tiles 2.
> >
> > When i call an action that uses tiles, i am getting this exception:
> >
> > javax.servlet.ServletException: Error including path
> > '/WEB-INF/layout/common.jsp'. org/apache/tiles/ListAttribute
> >
> >
> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
> >
> >
> >
> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:421)
> >
> >
> > common.jsp is the file that contains the tiles tamplate, here is that
> file:
> >
> > <%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "
> > http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> >
> > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
> >    <body>
> >        <table>
> >            <tr>
> >                <td>
> >                    <tiles:insertAttribute name="header" />
> >                </td>
> >            </tr>
> >            <tr>
> >                <td>
> >                    <tiles:insertAttribute name="body" />
> >                </td>
> >            </tr>
> >            <tr>
> >                <td>
> >                    <tiles:insertAttribute name="footer" />
> >                </td>
> >            </tr>
> >        </table>
> >    </body>
> > </html>
> >
> > also, here is my tiles.xml
> >
> > <?xml version="1.0" encoding="ISO-8859-1"?>
> > <!DOCTYPE tiles-definitions PUBLIC
> >       "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
> >       "http://jakarta.apache.org/struts/dtds/tiles-config_2_0.dtd">
> >
> > <tiles-definitions>
> >    <definition name="home.layout" template="/WEB-INF/layout/common.jsp">
> >        <put name="title" value="Panorama Grid Console"/>
> >        <put name="header" value="/WEB-INF/layout/header.jsp"/>
> >        <put name="body" value="/WEB-INF/view/home.jsp"/>
> >        <put name="footer" value="/WEB-INF/layout/footer.jsp"/>
> >    </definition>
> > </tiles-definitions>
> >
> > i have tried with put and put-attribute and i am getting the same
> exception
> > for both of them.
> >
> > Finally, here is my web.xml
> >
> > <web-app id="PanoramaGridConsole" version="2.4" xmlns="
> > http://java.sun.com/xml/ns/j2ee" xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
> > http://java.sun.com/xml/ns/j2ee
> > http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
> >
> >    <!-- Struts 2 Filter -->
> >    <filter>
> >        <filter-name>struts2</filter-name>
> >
> >
> <filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
> >    </filter>
> >
> >    <!-- Struts 2 Filter Mapping -->
> >    <filter-mapping>
> >        <filter-name>struts2</filter-name>
> >        <url-pattern>/*</url-pattern>
> >    </filter-mapping>
> >
> >    <!-- Struts 2 Tiles Listener -->
> >    <listener>
> >
> >
> >
> <listener-class>org.apache.struts2.tiles.StrutsTilesListener</listener-class>
> >    </listener>
> >
> > </web-app>
> >
> > Am i missing something? is this a bug related to struts 2??? Anyone have
> > seen this before?
> >
> > Thanks in advance,
> >
> > --
> > Carlos Curotto
> >
>
>
>
> --
> Márcio Gurgel
>



-- 
Carlos Curotto

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message