You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Emi Lu <em...@encs.concordia.ca> on 2007/10/02 22:29:30 UTC

Tiles 2 setup with Struts2

Hello,

I looked at this page:

http://struts.apache.org/2.x/docs/tiles-plugin.html

Done:
=============
[1] Added

<dependency>
   <groupId>org.apache.struts</groupId>
   <artifactId>struts2-tiles-plugin</artifactId>
   <version>${version.tiles}</version>
   <scope>compile</scope>
</dependency>

    to web.xml


[2] Added

<result-types>
   <result-type name="tiles" 
class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>

   to the struts.xml file's package section



[3] Added

    <action name="HelloWorld" class="example.HelloWorld">
       <result name="success" type="tiles">TileHelloWorld</result>
    </action>

     to the struts.xml file


[4] Added
   <definition name="TileHelloWorld" template="/tiles/layout.jsp">
       <put-attribute name="body"   value="/HelloWorld.jsp"/>
   </definition>

    to tiles-defs.xml (this file is saved under /WEB-INF/)

    For struts2, where and how to notify the system to load the 
titles-defs.xml? I suppose that the system will find this file 
auto-matically?



When I tried to access this page from URL, I always get the following 
exception (tomcat5.5.23):

javax.servlet.ServletException: TileHelloWorld

org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419)

root cause
org.apache.tiles.definition.NoSuchDefinitionException: TileHelloWorld
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:392)
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:368)
org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:104)
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178)
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253)


Any clues, which step I did wrong?

Thanks a lot!


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 setup with Struts2

Posted by Roberto Nunnari <ro...@supsi.ch>.
Yes, tiles-default extends struts-default.
Here's the content of struts-plugin.xml from the library
struts2-tiles-plugin-2.0.9.jar

<!DOCTYPE struts PUBLIC
         "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
         "http://struts.apache.org/dtds/struts-2.0.dtd">

<struts>
     <package name="tiles-default" extends="struts-default">
         <result-types>
             <result-type name="tiles" 
class="org.apache.struts2.views.tiles.TilesResult"/>
         </result-types>
     </package>
</struts>


Best regards.

--
Robi


Emi Lu wrote:
> 
>> here's the example:
>>
>>     <package name="default" extends="tiles-default">
>>     ...
>>     </package>
>>
>> see? it's enough that your packages extend tiles-default.
> 
> It works as well! That's nice! Thank you Robi.
> 
> 
> I did:
> ===========================
> [1] deleted
> <result-types>
> <result-type name="tiles"
>              class="org.apache.struts2.views.tiles.TilesResult"/>
> </result-types>
> 
> from struts.xml
> 
> 
> 
> [2] updated struts.xml:
> 
> from
> <package name="example" namespace="/example" extends="struts-default">
> 
> to
> <package name="example" namespace="/example" extends="tiles-default">
> 
> 
> ********************
> I hope "tiles-default" supports/extends all default struts2 setup, right?
> 
> I mean, if package extends "tiles-default", all struts2 properties such as
>       <result type="redirect-action">Menu</result>
>       <result name="success" type="dispatcher">/Success.jsp </result>
>       <result name="input"   type="dispatcher">/Logon.jsp   </result>
>       <result name="error">/Logon.jsp</result>
>   and other parameters will still work.
> 
> Cheers!
> 
> 
> 
> 
> 
> 
> 
> 
>>
>> Emi Lu wrote:
>>> Thank you very much !
>>>
>>> It works!
>>>
>>>
>>> Following Your comments, I did:
>>>
>>>>> =============
>>>>> <dependency>
>>>>>   <groupId>org.apache.struts</groupId>
>>>>>   <artifactId>struts2-tiles-plugin</artifactId>
>>>>>   <version>${version.tiles}</version>
>>>>>   <scope>compile</scope>
>>>>> </dependency>
>>>>>
>>>>>    to web.xml
>>>>
>>>> the above looks like maven stuff.. shouldn't be in web.xml
>>>
>>> Deleted from web.xml
>>>
>>>
>>>>> [2] <result-types>
>>>>>   <result-type name="tiles" 
>>>>> class="org.apache.struts2.views.tiles.TilesResult"/>
>>>>> </result-types>
>>>>>
>>>>>   to the struts.xml file's package section
>>>>
>>>> you could also extends tiles definition instead
>>>
>>> May I get an example? Is it for java action class extends tiles or 
>>> web.xml file update, would you tell me how?
>>>
>>> For now, I did not change this section.
>>>
>>>
>>>>> [3]
>>>>>    <action name="HelloWorld" class="example.HelloWorld">
>>>>>       <result name="success" type="tiles">TileHelloWorld</result>
>>>>>    </action>
>>>>>
>>>>>     to the struts.xml file
>>>>
>>>> ok
>>>
>>> no change.
>>>
>>>
>>>>> [4]   <definition name="TileHelloWorld" template="/tiles/layout.jsp">
>>>>>       <put-attribute name="body"   value="/HelloWorld.jsp"/>
>>>>>   </definition>
>>>>>
>>>>>    to tiles-defs.xml (this file is saved under /WEB-INF/)
>>>>>
>>>>>    For struts2, where and how to notify the system to load the 
>>>>> titles-defs.xml? I suppose that the system will find this file 
>>>>> auto-matically?
>>>>
>>>> that should be in WEB-INF/tiles.xml and not tiles-defs.xml
>>>> unless you include it..
>>>
>>> rename to tile.xml; now the file is loaded auto-matically :)
>>>
>>>
>>>
>>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 setup with Struts2

Posted by Emi Lu <em...@encs.concordia.ca>.
> here's the example:
> 
>     <package name="default" extends="tiles-default">
>     ...
>     </package>
> 
> see? it's enough that your packages extend tiles-default.

It works as well! That's nice! Thank you Robi.


I did:
===========================
[1] deleted
<result-types>
<result-type name="tiles"
              class="org.apache.struts2.views.tiles.TilesResult"/>
</result-types>

from struts.xml



[2] updated struts.xml:

from
<package name="example" namespace="/example" extends="struts-default">

to
<package name="example" namespace="/example" extends="tiles-default">


********************
I hope "tiles-default" supports/extends all default struts2 setup, right?

I mean, if package extends "tiles-default", all struts2 properties such as
       <result type="redirect-action">Menu</result>
       <result name="success" type="dispatcher">/Success.jsp </result>
       <result name="input"   type="dispatcher">/Logon.jsp   </result>
       <result name="error">/Logon.jsp</result>
   and other parameters will still work.

Cheers!








> 
> Emi Lu wrote:
>> Thank you very much !
>>
>> It works!
>>
>>
>> Following Your comments, I did:
>>
>>>> =============
>>>> <dependency>
>>>>   <groupId>org.apache.struts</groupId>
>>>>   <artifactId>struts2-tiles-plugin</artifactId>
>>>>   <version>${version.tiles}</version>
>>>>   <scope>compile</scope>
>>>> </dependency>
>>>>
>>>>    to web.xml
>>>
>>> the above looks like maven stuff.. shouldn't be in web.xml
>>
>> Deleted from web.xml
>>
>>
>>>> [2] <result-types>
>>>>   <result-type name="tiles" 
>>>> class="org.apache.struts2.views.tiles.TilesResult"/>
>>>> </result-types>
>>>>
>>>>   to the struts.xml file's package section
>>>
>>> you could also extends tiles definition instead
>>
>> May I get an example? Is it for java action class extends tiles or 
>> web.xml file update, would you tell me how?
>>
>> For now, I did not change this section.
>>
>>
>>>> [3]
>>>>    <action name="HelloWorld" class="example.HelloWorld">
>>>>       <result name="success" type="tiles">TileHelloWorld</result>
>>>>    </action>
>>>>
>>>>     to the struts.xml file
>>>
>>> ok
>>
>> no change.
>>
>>
>>>> [4]   <definition name="TileHelloWorld" template="/tiles/layout.jsp">
>>>>       <put-attribute name="body"   value="/HelloWorld.jsp"/>
>>>>   </definition>
>>>>
>>>>    to tiles-defs.xml (this file is saved under /WEB-INF/)
>>>>
>>>>    For struts2, where and how to notify the system to load the 
>>>> titles-defs.xml? I suppose that the system will find this file 
>>>> auto-matically?
>>>
>>> that should be in WEB-INF/tiles.xml and not tiles-defs.xml
>>> unless you include it..
>>
>> rename to tile.xml; now the file is loaded auto-matically :)
>>
>>
>>
>>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 setup with Struts2

Posted by Roberto Nunnari <ro...@supsi.ch>.
Hi Emi.

here's the example:

     <package name="default" extends="tiles-default">
	...
     </package>

see? it's enough that your packages extend tiles-default.

Best regards.

--
Robi


Emi Lu wrote:
> Thank you very much !
> 
> It works!
> 
> 
> Following Your comments, I did:
> 
>>> =============
>>> <dependency>
>>>   <groupId>org.apache.struts</groupId>
>>>   <artifactId>struts2-tiles-plugin</artifactId>
>>>   <version>${version.tiles}</version>
>>>   <scope>compile</scope>
>>> </dependency>
>>>
>>>    to web.xml
>>
>> the above looks like maven stuff.. shouldn't be in web.xml
> 
> Deleted from web.xml
> 
> 
>>> [2] <result-types>
>>>   <result-type name="tiles" 
>>> class="org.apache.struts2.views.tiles.TilesResult"/>
>>> </result-types>
>>>
>>>   to the struts.xml file's package section
>>
>> you could also extends tiles definition instead
> 
> May I get an example? Is it for java action class extends tiles or 
> web.xml file update, would you tell me how?
> 
> For now, I did not change this section.
> 
> 
>>> [3]
>>>    <action name="HelloWorld" class="example.HelloWorld">
>>>       <result name="success" type="tiles">TileHelloWorld</result>
>>>    </action>
>>>
>>>     to the struts.xml file
>>
>> ok
> 
> no change.
> 
> 
>>> [4]   <definition name="TileHelloWorld" template="/tiles/layout.jsp">
>>>       <put-attribute name="body"   value="/HelloWorld.jsp"/>
>>>   </definition>
>>>
>>>    to tiles-defs.xml (this file is saved under /WEB-INF/)
>>>
>>>    For struts2, where and how to notify the system to load the 
>>> titles-defs.xml? I suppose that the system will find this file 
>>> auto-matically?
>>
>> that should be in WEB-INF/tiles.xml and not tiles-defs.xml
>> unless you include it..
> 
> rename to tile.xml; now the file is loaded auto-matically :)
> 
> 
> 
> 
>>> When I tried to access this page from URL, I always get the following 
>>> exception (tomcat5.5.23):
>>> javax.servlet.ServletException: TileHelloWorld
>>> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515) 
>>> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419) 
> 
> No such errors anymore, and I got my tiles pages displayed successfuly!
> 
> Thank you again!
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 setup with Struts2

Posted by Emi Lu <em...@encs.concordia.ca>.
Thank you very much !

It works!


Following Your comments, I did:

>> =============
>> <dependency>
>>   <groupId>org.apache.struts</groupId>
>>   <artifactId>struts2-tiles-plugin</artifactId>
>>   <version>${version.tiles}</version>
>>   <scope>compile</scope>
>> </dependency>
>>
>>    to web.xml
> 
> the above looks like maven stuff.. shouldn't be in web.xml

Deleted from web.xml


>> [2] 
>> <result-types>
>>   <result-type name="tiles" 
>> class="org.apache.struts2.views.tiles.TilesResult"/>
>> </result-types>
>>
>>   to the struts.xml file's package section
> 
> you could also extends tiles definition instead

May I get an example? Is it for java action class extends tiles or 
web.xml file update, would you tell me how?

For now, I did not change this section.


>> [3] 
>>
>>    <action name="HelloWorld" class="example.HelloWorld">
>>       <result name="success" type="tiles">TileHelloWorld</result>
>>    </action>
>>
>>     to the struts.xml file
> 
> ok

no change.


>> [4] 
>>   <definition name="TileHelloWorld" template="/tiles/layout.jsp">
>>       <put-attribute name="body"   value="/HelloWorld.jsp"/>
>>   </definition>
>>
>>    to tiles-defs.xml (this file is saved under /WEB-INF/)
>>
>>    For struts2, where and how to notify the system to load the 
>> titles-defs.xml? I suppose that the system will find this file 
>> auto-matically?
> 
> that should be in WEB-INF/tiles.xml and not tiles-defs.xml
> unless you include it..

rename to tile.xml; now the file is loaded auto-matically :)




>> When I tried to access this page from URL, I always get the following 
>> exception (tomcat5.5.23):
>> javax.servlet.ServletException: TileHelloWorld
>> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515) 
>> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419) 
No such errors anymore, and I got my tiles pages displayed successfuly!

Thank you again!



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 setup with Struts2

Posted by Roberto Nunnari <ro...@supsi.ch>.
Hello Emi.

see below my comments.


Emi Lu wrote:
> Hello,
> 
> I looked at this page:
> 
> http://struts.apache.org/2.x/docs/tiles-plugin.html
> 
> Done:
> =============
> [1] Added
> 
> <dependency>
>   <groupId>org.apache.struts</groupId>
>   <artifactId>struts2-tiles-plugin</artifactId>
>   <version>${version.tiles}</version>
>   <scope>compile</scope>
> </dependency>
> 
>    to web.xml

the above looks like maven stuff.. shouldn't be in web.xml


> 
> 
> [2] Added
> 
> <result-types>
>   <result-type name="tiles" 
> class="org.apache.struts2.views.tiles.TilesResult"/>
> </result-types>
> 
>   to the struts.xml file's package section

you could also extends tiles definition instead


> 
> 
> 
> [3] Added
> 
>    <action name="HelloWorld" class="example.HelloWorld">
>       <result name="success" type="tiles">TileHelloWorld</result>
>    </action>
> 
>     to the struts.xml file

ok


> 
> 
> [4] Added
>   <definition name="TileHelloWorld" template="/tiles/layout.jsp">
>       <put-attribute name="body"   value="/HelloWorld.jsp"/>
>   </definition>
> 
>    to tiles-defs.xml (this file is saved under /WEB-INF/)
> 
>    For struts2, where and how to notify the system to load the 
> titles-defs.xml? I suppose that the system will find this file 
> auto-matically?

that should be in WEB-INF/tiles.xml and not tiles-defs.xml
unless you include it..


> 
> 
> 
> When I tried to access this page from URL, I always get the following 
> exception (tomcat5.5.23):
> 
> javax.servlet.ServletException: TileHelloWorld
> 
> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419) 
> 
> 
> root cause
> org.apache.tiles.definition.NoSuchDefinitionException: TileHelloWorld
> org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:392) 
> 
> org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:368) 
> 
> org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:104)
> org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178) 
> 
> com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348) 
> 
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253) 
> 
> 
> 
> Any clues, which step I did wrong?
> 
> Thanks a lot!
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 setup with Struts2

Posted by Emi Lu <em...@encs.concordia.ca>.
>> At least for now I have loaded Tiles 2 successfully without BeanUtils
>> and Digester jars :)
> 
> It's impossible, digester is needed to read XML files.

I forgot the tiles jars that I downloaded few days ago :(

Sorry!


The full jar lists I had:
============================
commons-beanutils-1.7.0.jar
commons-digester-1.8.jar
commons-logging-1.0.4.jar
jstl-1.1.2.jar
standard-1.1.2.jar
struts2-tiles-plugin-2.0.9.jar
tiles-core-2.0.4.jar
xwork-2.0.4.jar
freemarker-2.3.8.jar
ognl-2.6.11.jar
struts2-core-2.0.9.jar
tiles-api-2.0.4.jar
tiles-jsp-2.0.4.jar





---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 setup with Struts2

Posted by Antonio Petrelli <an...@gmail.com>.
2007/10/3, Emi Lu <em...@encs.concordia.ca>:
> At least for now I have loaded Tiles 2 successfully without BeanUtils
> and Digester jars :)

It's impossible, digester is needed to read XML files.

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 setup with Struts2

Posted by Emi Lu <em...@encs.concordia.ca>.
> You also need to add the jars that tiles requires:
> 
> copy the Tiles dependencies JARs:
>       * Jakarta Commons BeanUtils 1.7.0 or above;
>       * Jakarta Commons Digester 1.8 or above;
>       * Jakarta Commons Logging (at least API) 1.1 or above
> 
> http://tiles.apache.org/getting_started.html


I believed in struts2 + Tiles 2 docs:
 > > http://struts.apache.org/2.x/docs/tiles-plugin.html

saying that it is good enough to download and install:
http://repo1.maven.org/maven2/org/apache/struts/struts2-tiles-plugin/2.0.9/

For struts 2, would I still need BeanUtils, Digester?

At least for now I have loaded Tiles 2 successfully without BeanUtils 
and Digester jars :)


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 setup with Struts2

Posted by Jason Deffenbaugh <jd...@techtarget.com>.
You also need to add the jars that tiles requires:

copy the Tiles dependencies JARs:
      * Jakarta Commons BeanUtils 1.7.0 or above;
      * Jakarta Commons Digester 1.8 or above;
      * Jakarta Commons Logging (at least API) 1.1 or above

http://tiles.apache.org/getting_started.html

-Jason

On Tue, 2007-10-02 at 23:33 +0200, Roberto Nunnari wrote:
> Hello Emi.
> 
> see below my comments.
> 
> 
> Emi Lu wrote:
> > Hello,
> > 
> > I looked at this page:
> > 
> > http://struts.apache.org/2.x/docs/tiles-plugin.html
> > 
> > Done:
> > =============
> > [1] Added
> > 
> > <dependency>
> >   <groupId>org.apache.struts</groupId>
> >   <artifactId>struts2-tiles-plugin</artifactId>
> >   <version>${version.tiles}</version>
> >   <scope>compile</scope>
> > </dependency>
> > 
> >    to web.xml
> 
> the above looks like maven stuff.. shouldn't be in web.xml
> 
> 
> > 
> > 
> > [2] Added
> > 
> > <result-types>
> >   <result-type name="tiles" 
> > class="org.apache.struts2.views.tiles.TilesResult"/>
> > </result-types>
> > 
> >   to the struts.xml file's package section
> 
> you could also extends tiles definition instead
> 
> 
> > 
> > 
> > 
> > [3] Added
> > 
> >    <action name="HelloWorld" class="example.HelloWorld">
> >       <result name="success" type="tiles">TileHelloWorld</result>
> >    </action>
> > 
> >     to the struts.xml file
> 
> ok
> 
> 
> > 
> > 
> > [4] Added
> >   <definition name="TileHelloWorld" template="/tiles/layout.jsp">
> >       <put-attribute name="body"   value="/HelloWorld.jsp"/>
> >   </definition>
> > 
> >    to tiles-defs.xml (this file is saved under /WEB-INF/)
> > 
> >    For struts2, where and how to notify the system to load the 
> > titles-defs.xml? I suppose that the system will find this file 
> > auto-matically?
> 
> that should be in WEB-INF/tiles.xml and not tiles-defs.xml
> unless you include it..
> 
> 
> > 
> > 
> > 
> > When I tried to access this page from URL, I always get the following 
> > exception (tomcat5.5.23):
> > 
> > javax.servlet.ServletException: TileHelloWorld
> > 
> > org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
> > org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419) 
> > 
> > 
> > root cause
> > org.apache.tiles.definition.NoSuchDefinitionException: TileHelloWorld
> > org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:392) 
> > 
> > org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:368) 
> > 
> > org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:104)
> > org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178) 
> > 
> > com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348) 
> > 
> > com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253) 
> > 
> > 
> > 
> > Any clues, which step I did wrong?
> > 
> > Thanks a lot!
> > 
> > 
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Tiles 2 setup with Struts2

Posted by Roberto Nunnari <ro...@supsi.ch>.
Hello Emi.

see below my comments.


Emi Lu wrote:
> Hello,
> 
> I looked at this page:
> 
> http://struts.apache.org/2.x/docs/tiles-plugin.html
> 
> Done:
> =============
> [1] Added
> 
> <dependency>
>   <groupId>org.apache.struts</groupId>
>   <artifactId>struts2-tiles-plugin</artifactId>
>   <version>${version.tiles}</version>
>   <scope>compile</scope>
> </dependency>
> 
>    to web.xml

the above looks like maven stuff.. shouldn't be in web.xml


> 
> 
> [2] Added
> 
> <result-types>
>   <result-type name="tiles" 
> class="org.apache.struts2.views.tiles.TilesResult"/>
> </result-types>
> 
>   to the struts.xml file's package section

you could also extends tiles definition instead


> 
> 
> 
> [3] Added
> 
>    <action name="HelloWorld" class="example.HelloWorld">
>       <result name="success" type="tiles">TileHelloWorld</result>
>    </action>
> 
>     to the struts.xml file

ok


> 
> 
> [4] Added
>   <definition name="TileHelloWorld" template="/tiles/layout.jsp">
>       <put-attribute name="body"   value="/HelloWorld.jsp"/>
>   </definition>
> 
>    to tiles-defs.xml (this file is saved under /WEB-INF/)
> 
>    For struts2, where and how to notify the system to load the 
> titles-defs.xml? I suppose that the system will find this file 
> auto-matically?

that should be in WEB-INF/tiles.xml and not tiles-defs.xml
unless you include it..


> 
> 
> 
> When I tried to access this page from URL, I always get the following 
> exception (tomcat5.5.23):
> 
> javax.servlet.ServletException: TileHelloWorld
> 
> org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:515)
> org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:419) 
> 
> 
> root cause
> org.apache.tiles.definition.NoSuchDefinitionException: TileHelloWorld
> org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:392) 
> 
> org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:368) 
> 
> org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:104)
> org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:178) 
> 
> com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:348) 
> 
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:253) 
> 
> 
> 
> Any clues, which step I did wrong?
> 
> Thanks a lot!
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org