struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vish212 <visha...@gmail.com>
Subject RE: Struts2 with Annotation and <sx:a> problem (always returning the default action)
Date Tue, 06 Jan 2009 19:19:43 GMT

Hi Romain,

Possible workaround can be to put both the action, indexAction and your
myAction in different java packages. by default, struts2 annotation
processor keeps all the action within one java package to unique struts
action package. one 2 one mapping. and all the @parentPackage are used to
create parent package for that action. 

may be this helps,



Romain Maton wrote:
> 
> Hi all,
> 
> No more news about that ?
> 
> I read all docs and faqs and I can not find anything...
> 
>  
> 
> ________________________________
> 
> De : Romain Maton 
> Envoyé : jeudi 16 octobre 2008 17:43
> À : 'user-faq@struts.apache.org'; user@struts.apache.org
> Objet : Struts2 with Annotation and <sx:a> problem (always returning the
> default action)
> 
>  
> 
> Hi all,
> 
>  
> 
> Sorry, I don't know which mailing list to contact so...
> 
>  
> 
> I will try to explain as I can my problem :
> 
>  
> 
> *	I use Struts 2, my actions are defined with Annotations.
> *	I have a struts.xml very simple, only defining a default page, here it
> is :
> 
>  
> 
> <?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>
> 
>    <constant name="struts.locale" value="fr_FR" />
> 
>    <package abstract="true" namespace="/" name="welcome"
> extends="struts-default">
> 
>        <default-action-ref name="index"/>
> 
>    </package>
> 
> </struts>
> 
>  
> 
> *	My index action :
> 
>  
> 
> @Namespace("/")
> 
> @ParentPackage("welcome")
> 
> @Results( {@Result(name = "success", value = "/myMain.jsp")})
> 
> @Validation
> 
> public class IndexAction extends ActionSupport {
> 
> // My stuff
> 
> }
> 
>  
> 
> *	In a JSP of my webapp, I use <sx:a> dojo tag to make an ajax call, here
> it is :
> 
>  
> 
> <s:url id="urlMyAction" namespace="/" action="myAction" method="execute">
> 
>    <s:param name="myId">${id}</s:param>
> 
> </s:url>
> 
> <sx:a title="a title" targets="divResult" href="%{ urlMyAction }">click
> me</sx:a>
> 
>  
> 
> *	And my action that extends a default action :
> 
>  
> 
> public class MyActionAction extends DefaultActionAction {
> 
>    @Override
> 
>    public String execute() throws Exception {
> 
>       // My stuff
> 
>       return SUCCESS;
> 
>    }
> 
> }
> 
>  
> 
> @Namespace("/")
> 
> @ParentPackage("struts-default")
> 
> @Results( {@Result(name = "success", value = "aJsp.jsp")})
> 
> @Validation
> 
> public abstract class DefaultActionAction extends ActionSupport {
> 
> // My stuff
> 
> }
> 
>  
> 
> And with that code, I have on my "divResult" that contained, after the
> ajax return, my home page <default-action-ref name="index"/> !!! 
> 
>  
> 
> 2 possible "BAD" correction :
> 
>  
> 
> 1.	Remove my default home page (no more package in struts.xml and
> "struts-default" in parent package of IndexAction) => OK but my URL must
> contain http://...namespace/index.action which is not acceptable.
> 2.	Copy-paste all Struts2 annotations from "DefaultActionAction" to
> "MyActionAction" : work too but not acceptable too.
> 
>  
> 
> I am not sure if the problem is because of annotation and package
> configuration in struts.xml in conflict (resolution 1) or a bug in
> annotation class derivation (resolution 2).
> 
>  
> 
> Does anyone know the problem ??? What is the "GOOD" solution ?
> 
>  
> 
> Thanks all,
> 
>  
> 
> Romain
> 
>  
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts2-with-Annotation-and-%3Csx%3Aa%3E-problem-%28always-returning-the-default-action%29-tp20016957p21317137.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Mime
View raw message