struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stone, Sam" <sst...@constantcontact.com>
Subject Tiles 2 - How to dispatch to tiles servlet????
Date Mon, 04 Dec 2006 22:30:50 GMT
I am using tiles-core-2.0-SNAPSHOT.jar from Sep 2006.

 

I have a servlet MyServlet and also a servlet named tiles in the same
war file. Everything works if I do launch a jsp page that has a
tiles:insert in it. However, I'd like to dispatch directlry from
MyServlet to a tiles definition.

 

I can instantiate the DefinitionsFactory. I can get a
ComponentDefinition OK. I cannot figure out how to forward the request
from MyServlet to dispatch to my tiles servlet. Any help is greatly
appreciated.

 

All the following ocde seems to work. The printlns dump out the expected
information. I just can't figure out how to transfer control to my tiles
servlet.

 

            DefinitionsFactory definitionsFactory = null;            

            DefinitionsFactoryConfig definitionsConfig;

     

            definitionsConfig = new DefinitionsFactoryConfig();

            TilesContext stc = new
ServletTilesContext(s.getServletContext()); 

            

 

            /* load the tiles definitions */

 
definitionsConfig.setDefinitionConfigFiles("WEB-INF/tiles-defs-base.xml,
WEB-INF/tiles-defs-site.xml");

            try {

                definitionsFactory =
TilesUtil.createDefinitionsFactory(stc, definitionsConfig);

                System.out.println("Tiles Definitions loaded!");

            } catch (DefinitionsFactoryException dfe) {

                System.out.println("Error reading tiles definitions
file: " +

                        dfe.getMessage());

            }

           

            try

            {

                        ComponentDefinition definition =
definitionsFactory.readDefinitions().getDefinition("site.home");

                        System.out.println("definition=" + definition);


            }

            catch (Exception de)

            {

                System.out.println(de);

            }

 

 

Following is from my web.xml:

 

<servlet id="Servlet_1159386011442">

<servlet-name>tiles</servlet-name>

<servlet-class>org.apache.tiles.servlet.TilesServlet</servlet-class>

<init-param id="InitParam_1159386019739">

<param-name>definitions-config</param-name>

<param-value>

/WEB-INF/tiles-defs-base.xml,

/WEB-INF/tiles-defs-site.xml

</param-value>

</init-param>

<load-on-startup>2</load-on-startup>

</servlet>


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