sv13
sv13

Reputation: 186

Struts2, How to define @Result type parameter as tiles result

i am having trouble defining 'type' parameter of @Result annotation

here is my action annotation:

@Action(value="login", 
    results=@Result(name="success",location="index.page", type="tiles" ))

where index.page is my tiles definition, how do i define that 'tiles' is actually tiles result ?

before i was using struts.xml for config, and i could just place there

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

whatever i try i always get:

SEVERE: Dispatcher initialization failed
Unable to load configuration. - [unknown location]
...
Caused by: The Result type [tiles] which is defined in the Result annotation ... 
could not be found as a result-type defined for the Struts/XWork package 
[com.action#convention-default#] - [unknown location]

Upvotes: 0

Views: 7823

Answers (2)

SalutonMondo
SalutonMondo

Reputation: 709

you should define your results in a package that extends tiles-default.

<package name="ps" extends="json-default,tiles-default">

and in the action class

@Results({ 
    @Result(name = "success", location = "feedback_management.jsp")
    ,@Result(name = "listPage", 
    type = "tiles" ,location = "table.tiles")
})

Upvotes: 0

Russell Shingleton
Russell Shingleton

Reputation: 3196

Here is the configuration I use in my annotations based rest setup. Your result types need to be wrapped in whatever default package you're using for your actions:

<constant name="struts.convention.default.parent.package" value="restful"/>

<package name="restful"  extends="rest-default, struts-default, json-default">
    <result-types>
        <result-type name="tiles" class="org.apache.struts2.views.tiles.TilesResult" />
        <result-type name="json" class="com.googlecode.jsonplugin.JSONResult"/>
    </result-types> 

</package>

Upvotes: 6

Related Questions