You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wes Wannemacher <we...@wantii.com> on 2008/10/12 05:15:46 UTC
Re: json-plugin and Annotations (OR, implementations of Result
that DO not inherit from StrutsResultSupport)
It's funny that you happened to ask this tonight, I am working on a JSON
result with annotations as I am writing this...
First off, are you using a plugin to provide the annotations? If so,
which one. I am using struts-2.1.3-snapshot (which might make a
difference) in conjunction with the conventions plugin.
I have an action with the following annotation and it is working fine
for me -
@Action(results={@Result(name="success",type="json")})
On Sun, 2008-10-12 at 05:02 +0200, Alex Coles wrote:
> Using Struts 2.1.2 and json-plugin 0.30.
>
> I've been having issues configuring the json-plugin while using the
> @Result annotations.
>
> @Action(name = "items-json")
> @Results({
> @Result(name = ListItemsJsonAction.SUCCESS, type =
> JSONResult.class, value = "",
> params = { "root", "newsItems" } )
> })
> public class ListItemsJsonAction extends ListItemsAction
> {
> }
>
> The code above results in a OGNException:
> ognl.NoSuchPropertyException:
> com.googlecode.jsonplugin.JSONResult.location
>
> The obvious thing to do would be to remove the value = "" from the
> @Result annotation, but this in turn results in an:
> java.lang.annotation.IncompleteAnnotationException:
> org.apache.struts2.config.Result missing element value
>
>
> It looks as though its impossible to configure a json-plugin with annotations?
> Annotations only appear to work where the Result type has a property
> called "location" - inheriting from StrutsResultSupport provides this
> (and as such, I haven't had any issue with my custom Result types that
> I've written).
>
> This appears to be a bug? For now, the way around this is to use XML
> configuration for this particular action and result.
>
>
> Alex
>
> ---------------------------------------------------------------------
> 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: json-plugin and Annotations (OR, implementations of Result that DO not inherit from StrutsResultSupport)
Posted by Alex Coles <al...@gmail.com>.
On Sun, Oct 12, 2008 at 5:51 AM, Wes Wannemacher <we...@wantii.com> wrote:
> On Sun, 2008-10-12 at 05:29 +0200, Alex Coles wrote:
>> Hi Wes,
>>
>> Thanks for your response!
>>
>> On Sun, Oct 12, 2008 at 5:15 AM, Wes Wannemacher <we...@wantii.com> wrote:
>> > It's funny that you happened to ask this tonight, I am working on a JSON
>> > result with annotations as I am writing this...
>> >
>> > First off, are you using a plugin to provide the annotations? If so,
>> > which one. I am using struts-2.1.3-snapshot (which might make a
>> > difference) in conjunction with the conventions plugin.
>>
>> Sorry, I don't understand what you mean by using a plugin to provide
>> the annotations?
>>
>> I am using several different Result types, most of which I wrote
>> myself. However, in the case of JSON, I went with the json-plugin
>> here: http://cwiki.apache.org/S2PLUGINS/json-plugin.html
>>
>
> The reason I ask is that to do XML-less configuration, I will typically
> grab one of the plugins that helps. In my case, I like the new
> conventions plugin. This provides my @Action annotation... I use the
> org.apache.struts2.convention.annotation.Action annotation.
Thanks! I was using the @org.apache.struts2.config.Action and
@org.apache.struts2.config.Result annotations. I haven't had the
convention plugin enabled.
>> > I have an action with the following annotation and it is working fine
>> > for me -
>> >
>> > @Action(results={@Result(name="success",type="json")})
>> >
>>
>> If I ommit the value = "" parameter from my @Result annotation, then I
>> am getting a java.lang.annotation.IncompleteAnnotationException:
>> org.apache.struts2.config.Result missing element value
>>
>> I am using Struts 2.1.2, and not 2.1.3-SNAPSHOT. Perhaps something
>> changed along the way?
>
> This is my guess as to the culprit. There is another issue that I'm
> wondering about though. In my project, I am using Maven, so I noticed
> right away that the JSON plugin was built against Struts 2.0.x. I had to
> patch it to get Maven to compile it and make it available to my
> project.
>
> Anyhow, I would suggest compiling the latest from SVN and try with
> 2.1.3-SNAPSHOT. If that doesn't work, check the convention plugin -
>
> http://cwiki.apache.org/S2PLUGINS/convention-plugin.html
>
> My @Result annotation comes from this plugin (rather than struts-core)
> and that could be the difference as well.
>
Thanks again, Wes. I should take a look at the conventions plugin. I
think for now I will go with XML configuration for this particular
use-case in my application (as I need to deploy very soon). I am a
pretty new convert to Struts 2 (coming from Spring MVC) and while I
like its power, I find the choices for configuration styles a little
bewildering!
I'll look at the snapshot too - although not for the application I am
about to launch in production!
Thanks,
Alex
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: json-plugin and Annotations (OR, implementations of Result
that DO not inherit from StrutsResultSupport)
Posted by Wes Wannemacher <we...@wantii.com>.
On Sun, 2008-10-12 at 05:29 +0200, Alex Coles wrote:
> Hi Wes,
>
> Thanks for your response!
>
> On Sun, Oct 12, 2008 at 5:15 AM, Wes Wannemacher <we...@wantii.com> wrote:
> > It's funny that you happened to ask this tonight, I am working on a JSON
> > result with annotations as I am writing this...
> >
> > First off, are you using a plugin to provide the annotations? If so,
> > which one. I am using struts-2.1.3-snapshot (which might make a
> > difference) in conjunction with the conventions plugin.
>
> Sorry, I don't understand what you mean by using a plugin to provide
> the annotations?
>
> I am using several different Result types, most of which I wrote
> myself. However, in the case of JSON, I went with the json-plugin
> here: http://cwiki.apache.org/S2PLUGINS/json-plugin.html
>
The reason I ask is that to do XML-less configuration, I will typically
grab one of the plugins that helps. In my case, I like the new
conventions plugin. This provides my @Action annotation... I use the
org.apache.struts2.convention.annotation.Action annotation.
> > I have an action with the following annotation and it is working fine
> > for me -
> >
> > @Action(results={@Result(name="success",type="json")})
> >
>
> If I ommit the value = "" parameter from my @Result annotation, then I
> am getting a java.lang.annotation.IncompleteAnnotationException:
> org.apache.struts2.config.Result missing element value
>
> I am using Struts 2.1.2, and not 2.1.3-SNAPSHOT. Perhaps something
> changed along the way?
This is my guess as to the culprit. There is another issue that I'm
wondering about though. In my project, I am using Maven, so I noticed
right away that the JSON plugin was built against Struts 2.0.x. I had to
patch it to get Maven to compile it and make it available to my
project.
Anyhow, I would suggest compiling the latest from SVN and try with
2.1.3-SNAPSHOT. If that doesn't work, check the convention plugin -
http://cwiki.apache.org/S2PLUGINS/convention-plugin.html
My @Result annotation comes from this plugin (rather than struts-core)
and that could be the difference as well.
-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: json-plugin and Annotations (OR, implementations of Result that DO not inherit from StrutsResultSupport)
Posted by Alex Coles <al...@gmail.com>.
Hi Wes,
Thanks for your response!
On Sun, Oct 12, 2008 at 5:15 AM, Wes Wannemacher <we...@wantii.com> wrote:
> It's funny that you happened to ask this tonight, I am working on a JSON
> result with annotations as I am writing this...
>
> First off, are you using a plugin to provide the annotations? If so,
> which one. I am using struts-2.1.3-snapshot (which might make a
> difference) in conjunction with the conventions plugin.
Sorry, I don't understand what you mean by using a plugin to provide
the annotations?
I am using several different Result types, most of which I wrote
myself. However, in the case of JSON, I went with the json-plugin
here: http://cwiki.apache.org/S2PLUGINS/json-plugin.html
> I have an action with the following annotation and it is working fine
> for me -
>
> @Action(results={@Result(name="success",type="json")})
>
If I ommit the value = "" parameter from my @Result annotation, then I
am getting a java.lang.annotation.IncompleteAnnotationException:
org.apache.struts2.config.Result missing element value
I am using Struts 2.1.2, and not 2.1.3-SNAPSHOT. Perhaps something
changed along the way?
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org