You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Gamble, Wesley (WG10)" <WG...@tmw.com> on 2008/05/20 17:01:21 UTC

Can one use the annotation action specification with Tiles?

All,

 

Can I use the Struts 2 annotation - style of specifying action results
to set a tile name as the target for a Struts action?  In my testing,
I've been unable to, although I have successfully done it with the XML
action specification in struts.xml.  My suspicion is that perhaps the
annotations are processed in some way that precludes the
recognition/detection of tile definitions?

 

Here's my action:

 

@Result(name = "success", value="startApplication")

 

public class ApplicationStartAction {     

      private String pageTitle;

      private String companyName;

      

      public String execute() throws Exception {

            pageTitle = "Start Job Application";

            companyName = "Men's Wearhouse";          

            return "success";

      }

 

...getters and setters here..

}

 

Here's my tiles.xml file:

 

<!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="baseLayout" template="/layouts/base.jsp">

      <put-attribute name="head" value="/tiles/head.jsp"/>

      <put-attribute name="body" value="/tiles/body.jsp"/>

  </definition>

  

  <definition name="startApplication" extends="baseLayout">

  </definition>

</tiles-definitions>

 

When I attempt to execute the ApplicationStartAction, I get the error:
The requested resource (/ApplicantTracking/startApplication) is not
available.

which I assume to mean that the action result mapping to the tile
definition is not working.

 

Thanks,

Wes

 

 


RE: Can one use the annotation action specification with Tiles?

Posted by "Gamble, Wesley (WG10)" <WG...@tmw.com>.
It's interesting is that the "default=true" attribute in the
<result-types> element in struts.xml doesn't seem to influence
annotation-based results specification like it does for the XML
configuration.

In XML, if I set default=true on <result-types>, I don't need to specify
a Tiles result at the action level.

But with annotations, I do need to specify the Tiles result explicitly
on each action.  A minor annoyance at worst.  

Wes


Dave Newton said:

No, I'm saying you didn't define the result type in the result
annotation. The above configuration fragment defines the tiles
result--it doesn't say to *use* it anywhere.

http://struts.apache.org/2.x/docs/result-annotation.html

The @Result annotation takes a "type" parameter.

Dave


---------------------------------------------------------------------
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: Can one use the annotation action specification with Tiles?

Posted by Dave Newton <ne...@yahoo.com>.
--- "Gamble, Wesley (WG10)" <WG...@tmw.com> wrote:
> So, are you saying that this:
> 
> <result-types>
>   <result-type name="tiles"
>                class="org.apache.struts2.views.tiles.TilesResult"
default="true"/>
> </result-types>
> 
> in my struts.xml doesn't influence how the annotation-specified
> result is processed?

No, I'm saying you didn't define the result type in the result
annotation. The above configuration fragment defines the tiles
result--it doesn't say to *use* it anywhere.

http://struts.apache.org/2.x/docs/result-annotation.html

The @Result annotation takes a "type" parameter.

Dave


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


RE: Can one use the annotation action specification with Tiles?

Posted by "Gamble, Wesley (WG10)" <WG...@tmw.com>.
So, are you saying that this:

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

in my struts.xml doesn't influence how the annotation-specified result
is processed?

If so, where should I put whatever annotation directive to specify that
results are tiles in general? Obviously, I'd like to put it in one
place.

Thanks,
Wes

-----Original Message-----
From: Dave Newton [mailto:newton.dave@yahoo.com] 
Sent: Tuesday, May 20, 2008 10:09 AM
To: Struts Users Mailing List
Subject: Re: Can one use the annotation action specification with Tiles?

You're not specifying the result type, so it's trying to use
"dispatcher" results, which aren't Tiles-aware (obviously :)

Dave

--- "Gamble, Wesley (WG10)" <WG...@tmw.com> wrote:
> Can I use the Struts 2 annotation - style of specifying action
> results
> to set a tile name as the target for a Struts action?  In my testing,
> I've been unable to, although I have successfully done it with the
> XML
> action specification in struts.xml.  My suspicion is that perhaps the
> annotations are processed in some way that precludes the
> recognition/detection of tile definitions?
> 
>  
> 
> Here's my action:
> 
>  
> 
> @Result(name = "success", value="startApplication")
> 
>  
> 
> public class ApplicationStartAction {     
> 
>       private String pageTitle;
> 
>       private String companyName;
> 
>       
> 
>       public String execute() throws Exception {
> 
>             pageTitle = "Start Job Application";
> 
>             companyName = "Men's Wearhouse";          
> 
>             return "success";
> 
>       }
> 
>  
> 
> ...getters and setters here..
> 
> }
> 
>  
> 
> Here's my tiles.xml file:
> 
>  
> 
> <!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="baseLayout" template="/layouts/base.jsp">
> 
>       <put-attribute name="head" value="/tiles/head.jsp"/>
> 
>       <put-attribute name="body" value="/tiles/body.jsp"/>
> 
>   </definition>
> 
>   
> 
>   <definition name="startApplication" extends="baseLayout">
> 
>   </definition>
> 
> </tiles-definitions>
> 
>  
> 
> When I attempt to execute the ApplicationStartAction, I get the
> error:
> The requested resource (/ApplicantTracking/startApplication) is not
> available.
> 
> which I assume to mean that the action result mapping to the tile
> definition is not working.
> 
>  
> 
> Thanks,
> 
> Wes
> 
>  
> 
>  
> 
> 


---------------------------------------------------------------------
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: Can one use the annotation action specification with Tiles?

Posted by Dave Newton <ne...@yahoo.com>.
You're not specifying the result type, so it's trying to use
"dispatcher" results, which aren't Tiles-aware (obviously :)

Dave

--- "Gamble, Wesley (WG10)" <WG...@tmw.com> wrote:
> Can I use the Struts 2 annotation - style of specifying action
> results
> to set a tile name as the target for a Struts action?  In my testing,
> I've been unable to, although I have successfully done it with the
> XML
> action specification in struts.xml.  My suspicion is that perhaps the
> annotations are processed in some way that precludes the
> recognition/detection of tile definitions?
> 
>  
> 
> Here's my action:
> 
>  
> 
> @Result(name = "success", value="startApplication")
> 
>  
> 
> public class ApplicationStartAction {     
> 
>       private String pageTitle;
> 
>       private String companyName;
> 
>       
> 
>       public String execute() throws Exception {
> 
>             pageTitle = "Start Job Application";
> 
>             companyName = "Men's Wearhouse";          
> 
>             return "success";
> 
>       }
> 
>  
> 
> ...getters and setters here..
> 
> }
> 
>  
> 
> Here's my tiles.xml file:
> 
>  
> 
> <!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="baseLayout" template="/layouts/base.jsp">
> 
>       <put-attribute name="head" value="/tiles/head.jsp"/>
> 
>       <put-attribute name="body" value="/tiles/body.jsp"/>
> 
>   </definition>
> 
>   
> 
>   <definition name="startApplication" extends="baseLayout">
> 
>   </definition>
> 
> </tiles-definitions>
> 
>  
> 
> When I attempt to execute the ApplicationStartAction, I get the
> error:
> The requested resource (/ApplicantTracking/startApplication) is not
> available.
> 
> which I assume to mean that the action result mapping to the tile
> definition is not working.
> 
>  
> 
> Thanks,
> 
> Wes
> 
>  
> 
>  
> 
> 


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