You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Laurie Harper <la...@holoweb.net> on 2007/02/08 07:39:12 UTC
[S2] @Result annotation not working
What do I need to do to make @Result annotations on my action methods
work? I'm using the code-behind and zero-config plugins, and tried to
add the annotation like this:
@Result(value = "users", type = ServletActionRedirectResult.class)
public String save() {
userService.saveUser(user);
return SUCCESS;
}
I've tried a few different variations, with and without a surrounding
@Results annotation, and none of them have any effect. Do I need to
configure an additional interceptor, or otherwise configure something
specially?
I'm working with 2.0.4-SNAPSHOT at the moment, and have the following
artifacts in my classpath:
struts-annotations-1.0-SNAPSHOT.jar
struts2-codebehind-plugin-2.0.3-SNAPSHOT.jar
struts2-spring-plugin-2.0.3-SNAPSHOT.jar
struts2-api-2.0.3-SNAPSHOT.jar
struts2-core-2.0.3-SNAPSHOT.jar
Did I miss anything?
Secondary question: shouldn't the 'value' be optional when using the
code-behind plugin? Since the plugin will automatically find
users-success.jsp / users.jsp, it seems like I should be able to just
say things like:
@Results(
@Result(ServletActionRedirectResult.class)
@Result(name="oops", ServletRedirectResult.class)
)
public String execute() {
if (something)
return SUCCESS;
return "oops";
}
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Result annotation not working
Posted by Dave Newton <ne...@yahoo.com>.
--- Don Brown <do...@gmail.com> wrote:
> True...hmm...well, at the least, we should warn
> people or configure the annotation to not be able to
> be set at the method level.
I had updated the @Result anno wiki docs based on the
OP's woes, but yeah, making it a class-level
annotation would help some.
Dave
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Result annotation not working
Posted by Don Brown <do...@gmail.com>.
True...hmm...well, at the least, we should warn people or configure
the annotation to not be able to be set at the method level.
Don
On 2/9/07, Dave Newton <ne...@yahoo.com> wrote:
> --- Don Brown <do...@gmail.com> wrote:
> > Hm...if it doesn't work on the method level, file a
> > ticket as it should work that way. If nothing else
> > we should document it better.
>
> I first annotated my methods, which failed, and I was
> confused, but... results are defined in the XML file
> for the the Action itself, not its individual methods,
> right?
>
> If that's correct, I'm not sure how the mindset of
> results-per-class vs. results-per-method would be
> reconciled, would you then have to enforce that a
> result was valid only for the annotated method, etc.
>
> d.
>
>
>
>
> ____________________________________________________________________________________
> Expecting? Get great news right away with email Auto-Check.
> Try the Yahoo! Mail Beta.
> http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
>
> ---------------------------------------------------------------------
> 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: [S2] Result annotation not working
Posted by Dave Newton <ne...@yahoo.com>.
--- Don Brown <do...@gmail.com> wrote:
> Hm...if it doesn't work on the method level, file a
> ticket as it should work that way. If nothing else
> we should document it better.
I first annotated my methods, which failed, and I was
confused, but... results are defined in the XML file
for the the Action itself, not its individual methods,
right?
If that's correct, I'm not sure how the mindset of
results-per-class vs. results-per-method would be
reconciled, would you then have to enforce that a
result was valid only for the annotated method, etc.
d.
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Result annotation not working
Posted by Don Brown <do...@gmail.com>.
Hm...if it doesn't work on the method level, file a ticket as it
should work that way. If nothing else we should document it better.
Don
On 2/9/07, Dave Newton <ne...@yahoo.com> wrote:
> --- Dave Newton <ne...@yahoo.com> wrote:
> > --- Laurie Harper <la...@holoweb.net> wrote:
> > > Doh! That was the problem. I could have sworn the
> > > examples I looked at had it at the method level.
> > I added more on the topic [...]
>
> And no, I didn't sneak in and change the examples ;)
>
> d.
>
>
>
>
> ____________________________________________________________________________________
> Expecting? Get great news right away with email Auto-Check.
> Try the Yahoo! Mail Beta.
> http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
>
> ---------------------------------------------------------------------
> 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: [S2] Result annotation not working
Posted by Dave Newton <ne...@yahoo.com>.
--- Dave Newton <ne...@yahoo.com> wrote:
> --- Laurie Harper <la...@holoweb.net> wrote:
> > Doh! That was the problem. I could have sworn the
> > examples I looked at had it at the method level.
> I added more on the topic [...]
And no, I didn't sneak in and change the examples ;)
d.
____________________________________________________________________________________
Expecting? Get great news right away with email Auto-Check.
Try the Yahoo! Mail Beta.
http://advision.webevents.yahoo.com/mailbeta/newmail_tools.html
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Result annotation not working
Posted by Dave Newton <ne...@yahoo.com>.
--- Laurie Harper <la...@holoweb.net> wrote:
> Doh! That was the problem. I could have sworn the
> examples I looked at had it at the method level.
I had done the exact same thing the first time I used
annotations (hence the @Result page :) I added more on
the topic as a result of your issues and highlighted
the class-level bit and actionPackages config.
Dave
____________________________________________________________________________________
Now that's room service! Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
http://farechase.yahoo.com/promo-generic-14795097
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Result annotation not working
Posted by Laurie Harper <la...@holoweb.net>.
Nate Drake wrote:
> The @Result annotation should be at the class level, not the method level.
Doh! That was the problem. I could have sworn the examples I looked at
had it at the method level. Mea culpa!
Thanks,
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] Result annotation not working
Posted by Nate Drake <nd...@gmail.com>.
The @Result annotation should be at the class level, not the method level.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] @Result annotation not working
Posted by Laurie Harper <la...@holoweb.net>.
Dave Newton wrote:
> --- Laurie Harper <la...@holoweb.net> wrote:
>> What do I need to do to make @Result annotations on
>> my action methods work?
>
> What doesn't work/what are the symptoms? I had it
> working under 2.0.4 (w/ the 2.0.4 jars, anyway) until
> it seemed I wouldn't be able to use it because of an
> apparent conflict of interests between slashes in
> action names and the zero-config.
The symptoms are that, no matter what annotations I add, I always get
the same behaviour as if I specify none. I can't map a result name
(return "foo") to a page, or get the result to be a redirect, or
anything else. The @Result annotations always seem to be ignored.
> Do you have slashes turned on?
No, I don't.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] @Result annotation not working
Posted by Ian Roughley <ia...@fdar.com>.
Do you have the web.xml init-param "actionPackages" listing the package
that the action is in?
/Ian
Dave Newton wrote:
> --- Laurie Harper <la...@holoweb.net> wrote:
>
>> What do I need to do to make @Result annotations on
>> my action methods work?
>>
>
> What doesn't work/what are the symptoms? I had it
> working under 2.0.4 (w/ the 2.0.4 jars, anyway) until
> it seemed I wouldn't be able to use it because of an
> apparent conflict of interests between slashes in
> action names and the zero-config.
>
> Do you have slashes turned on?
>
> Dave
>
>
>
>
> ____________________________________________________________________________________
> Food fight? Enjoy some healthy debate
> in the Yahoo! Answers Food & Drink Q&A.
> http://answers.yahoo.com/dir/?link=list&sid=396545367
>
> ---------------------------------------------------------------------
> 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: [S2] @Result annotation not working
Posted by Dave Newton <ne...@yahoo.com>.
--- Laurie Harper <la...@holoweb.net> wrote:
> What do I need to do to make @Result annotations on
> my action methods work?
What doesn't work/what are the symptoms? I had it
working under 2.0.4 (w/ the 2.0.4 jars, anyway) until
it seemed I wouldn't be able to use it because of an
apparent conflict of interests between slashes in
action names and the zero-config.
Do you have slashes turned on?
Dave
____________________________________________________________________________________
Food fight? Enjoy some healthy debate
in the Yahoo! Answers Food & Drink Q&A.
http://answers.yahoo.com/dir/?link=list&sid=396545367
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org