You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Pratt <th...@gmail.com> on 2009/07/14 08:17:19 UTC
JSON Plugin and S:Action
I'm having a problem using <s:action executeResult="true"> with an action
whose result type is json. It doesn't insert the results. My Action is
something like:
public class InitCalendarAction {
private List<List<String>> json;
/**
* Get the JSON Object to be Serialized
*
* @return JSON Object
*/
public Object getJson () {
return json;
} //getJson
/**
* Prepare the Object to be Serialized using JSON
*
* @return "success";
*/
public String execute () {
Category cat;
Category[] daily = user.getPlan().getDailyCategories();
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DATE,1);
int first = cal.get(Calendar.DAY_OF_WEEK) - 1;
List<String> row;
json = new ArrayList<List<String>>();
for(int day = 1;day <= cal.getMaximum(Calendar.DATE);day++) {
row = new ArrayList<String>();
row.add("true");
cat = daily[(day + first) % 7];
row.add(cat.name().toLowerCase());
row.add(cat.name());
json.add(row);
}
return "success";
} //execute
} //*InitCalendarAction
I have the action defined as:
<action name="init-calendar" class="initCalendarAction">
<result type="json">
<param name="root">json</param>
</result>
</action>
In my JSP, I have:
var hilights = "<s:action name='init-calendar' namespace='/'
executeResult='/'/>";
But instead of the expected:
var hilights = "[ [ "true", "cardio", "Cardio"], [ "true", "upperbody",
"Upper Body"] ... ]";
I get:
var hilights = "";
There are no errors in the logs and when I write out each row in the array,
everything is there as expected, but there's just no output. Any idea's
why?
(*Chris*)
Re: JSON Plugin and S:Action
Posted by Chris Pratt <th...@gmail.com>.
Yup, I had to change a couple of my helper classes because of that change.
(*Chris*)
On Wed, Jul 15, 2009 at 9:14 AM, Musachy Barroso <mu...@gmail.com> wrote:
> yeah, something did change and I think ti was some signature from
> Map<String, String> to Map<String, Object> or the other way around.
>
> On Wed, Jul 15, 2009 at 9:08 AM, Wes Wannemacher<we...@wantii.com> wrote:
> > That's weird, now you have me more curious, I don't remember making
> > changes to get it working in 2.1, other than updating unit tests...
> > Musachy, do you remember that going from 2.1.2 to 2.1.3? I was using
> > it with 2.1.3-SNAPSHOT quite a bit, so it must have been something
> > that changed shortly after the 2.1.2 release...
> >
> > -Wes
> >
> > On Wed, Jul 15, 2009 at 12:03 PM, Chris Pratt<th...@gmail.com>
> wrote:
> >> It was in one of my earlier posts, but I was getting this:
> >>
> >> java.lang.NoSuchMethodError:
> >>
> com.opensymphony.xwork2.ActionContext.get(Ljava/lang/String;)Ljava/lang/Object;
> >> at
> com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:157)
> >> at
> >>
> com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:355)
> >> at
> >>
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:259)
> >> ...
> >>
> >> (*Chris*)
> >>
> >>
> >> On Wed, Jul 15, 2009 at 9:01 AM, Wes Wannemacher <we...@wantii.com>
> wrote:
> >>
> >>> On Wed, Jul 15, 2009 at 11:56 AM, Chris Pratt<th...@gmail.com>
> >>> wrote:
> >>> > Yup, the latest jar file works with 2.1.6 (but not 2.1.2 for the
> record).
> >>> > (*Chris*)
> >>>
> >>> What went wrong in 2.1.2? This intrigues me :)
> >>>
> >>> -Wes
> >>>
> >>> >
> >>> > On Wed, Jul 15, 2009 at 8:11 AM, Musachy Barroso <mu...@gmail.com>
> >>> wrote:
> >>> >
> >>> >> I think the last release worked with 2.1 right?
> >>> >>
> >>> >> musachy
> >>> >>
> >>>
> >>> --
> >>> Wes Wannemacher
> >>> Author - Struts 2 In Practice
> >>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> >>> http://www.manning.com/wannemacher
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>> For additional commands, e-mail: user-help@struts.apache.org
> >>>
> >>>
> >>
> >
> >
> >
> > --
> > Wes Wannemacher
> > Author - Struts 2 In Practice
> > Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> > http://www.manning.com/wannemacher
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: JSON Plugin and S:Action
Posted by Musachy Barroso <mu...@gmail.com>.
yeah, something did change and I think ti was some signature from
Map<String, String> to Map<String, Object> or the other way around.
On Wed, Jul 15, 2009 at 9:08 AM, Wes Wannemacher<we...@wantii.com> wrote:
> That's weird, now you have me more curious, I don't remember making
> changes to get it working in 2.1, other than updating unit tests...
> Musachy, do you remember that going from 2.1.2 to 2.1.3? I was using
> it with 2.1.3-SNAPSHOT quite a bit, so it must have been something
> that changed shortly after the 2.1.2 release...
>
> -Wes
>
> On Wed, Jul 15, 2009 at 12:03 PM, Chris Pratt<th...@gmail.com> wrote:
>> It was in one of my earlier posts, but I was getting this:
>>
>> java.lang.NoSuchMethodError:
>> com.opensymphony.xwork2.ActionContext.get(Ljava/lang/String;)Ljava/lang/Object;
>> at com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:157)
>> at
>> com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:355)
>> at
>> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:259)
>> ...
>>
>> (*Chris*)
>>
>>
>> On Wed, Jul 15, 2009 at 9:01 AM, Wes Wannemacher <we...@wantii.com> wrote:
>>
>>> On Wed, Jul 15, 2009 at 11:56 AM, Chris Pratt<th...@gmail.com>
>>> wrote:
>>> > Yup, the latest jar file works with 2.1.6 (but not 2.1.2 for the record).
>>> > (*Chris*)
>>>
>>> What went wrong in 2.1.2? This intrigues me :)
>>>
>>> -Wes
>>>
>>> >
>>> > On Wed, Jul 15, 2009 at 8:11 AM, Musachy Barroso <mu...@gmail.com>
>>> wrote:
>>> >
>>> >> I think the last release worked with 2.1 right?
>>> >>
>>> >> musachy
>>> >>
>>>
>>> --
>>> Wes Wannemacher
>>> Author - Struts 2 In Practice
>>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>>> http://www.manning.com/wannemacher
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>
>
>
> --
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
RE: JSON Plugin and S:Action
Posted by Martin Gainty <mg...@hotmail.com>.
version ?
Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.
> Date: Wed, 15 Jul 2009 12:08:50 -0400
> Subject: Re: JSON Plugin and S:Action
> From: wesw@wantii.com
> To: user@struts.apache.org
>
> That's weird, now you have me more curious, I don't remember making
> changes to get it working in 2.1, other than updating unit tests...
> Musachy, do you remember that going from 2.1.2 to 2.1.3? I was using
> it with 2.1.3-SNAPSHOT quite a bit, so it must have been something
> that changed shortly after the 2.1.2 release...
>
> -Wes
>
> On Wed, Jul 15, 2009 at 12:03 PM, Chris Pratt<th...@gmail.com> wrote:
> > It was in one of my earlier posts, but I was getting this:
> >
> > java.lang.NoSuchMethodError:
> > com.opensymphony.xwork2.ActionContext.get(Ljava/lang/String;)Ljava/lang/Object;
> > at com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:157)
> > at
> > com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:355)
> > at
> > com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:259)
> > ...
> >
> > (*Chris*)
> >
> >
> > On Wed, Jul 15, 2009 at 9:01 AM, Wes Wannemacher <we...@wantii.com> wrote:
> >
> >> On Wed, Jul 15, 2009 at 11:56 AM, Chris Pratt<th...@gmail.com>
> >> wrote:
> >> > Yup, the latest jar file works with 2.1.6 (but not 2.1.2 for the record).
> >> > (*Chris*)
> >>
> >> What went wrong in 2.1.2? This intrigues me :)
> >>
> >> -Wes
> >>
> >> >
> >> > On Wed, Jul 15, 2009 at 8:11 AM, Musachy Barroso <mu...@gmail.com>
> >> wrote:
> >> >
> >> >> I think the last release worked with 2.1 right?
> >> >>
> >> >> musachy
> >> >>
> >>
> >> --
> >> Wes Wannemacher
> >> Author - Struts 2 In Practice
> >> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> >> http://www.manning.com/wannemacher
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >> For additional commands, e-mail: user-help@struts.apache.org
> >>
> >>
> >
>
>
>
> --
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
_________________________________________________________________
Insert movie times and more without leaving Hotmail®.
http://windowslive.com/Tutorial/Hotmail/QuickAdd?ocid=TXT_TAGLM_WL_HM_Tutorial_QuickAdd_062009
Re: JSON Plugin and S:Action
Posted by Wes Wannemacher <we...@wantii.com>.
That's weird, now you have me more curious, I don't remember making
changes to get it working in 2.1, other than updating unit tests...
Musachy, do you remember that going from 2.1.2 to 2.1.3? I was using
it with 2.1.3-SNAPSHOT quite a bit, so it must have been something
that changed shortly after the 2.1.2 release...
-Wes
On Wed, Jul 15, 2009 at 12:03 PM, Chris Pratt<th...@gmail.com> wrote:
> It was in one of my earlier posts, but I was getting this:
>
> java.lang.NoSuchMethodError:
> com.opensymphony.xwork2.ActionContext.get(Ljava/lang/String;)Ljava/lang/Object;
> at com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:157)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:355)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:259)
> ...
>
> (*Chris*)
>
>
> On Wed, Jul 15, 2009 at 9:01 AM, Wes Wannemacher <we...@wantii.com> wrote:
>
>> On Wed, Jul 15, 2009 at 11:56 AM, Chris Pratt<th...@gmail.com>
>> wrote:
>> > Yup, the latest jar file works with 2.1.6 (but not 2.1.2 for the record).
>> > (*Chris*)
>>
>> What went wrong in 2.1.2? This intrigues me :)
>>
>> -Wes
>>
>> >
>> > On Wed, Jul 15, 2009 at 8:11 AM, Musachy Barroso <mu...@gmail.com>
>> wrote:
>> >
>> >> I think the last release worked with 2.1 right?
>> >>
>> >> musachy
>> >>
>>
>> --
>> Wes Wannemacher
>> Author - Struts 2 In Practice
>> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
>> http://www.manning.com/wannemacher
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: JSON Plugin and S:Action
Posted by Chris Pratt <th...@gmail.com>.
It was in one of my earlier posts, but I was getting this:
java.lang.NoSuchMethodError:
com.opensymphony.xwork2.ActionContext.get(Ljava/lang/String;)Ljava/lang/Object;
at com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:157)
at
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:355)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:259)
...
(*Chris*)
On Wed, Jul 15, 2009 at 9:01 AM, Wes Wannemacher <we...@wantii.com> wrote:
> On Wed, Jul 15, 2009 at 11:56 AM, Chris Pratt<th...@gmail.com>
> wrote:
> > Yup, the latest jar file works with 2.1.6 (but not 2.1.2 for the record).
> > (*Chris*)
>
> What went wrong in 2.1.2? This intrigues me :)
>
> -Wes
>
> >
> > On Wed, Jul 15, 2009 at 8:11 AM, Musachy Barroso <mu...@gmail.com>
> wrote:
> >
> >> I think the last release worked with 2.1 right?
> >>
> >> musachy
> >>
>
> --
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: JSON Plugin and S:Action
Posted by Wes Wannemacher <we...@wantii.com>.
On Wed, Jul 15, 2009 at 11:56 AM, Chris Pratt<th...@gmail.com> wrote:
> Yup, the latest jar file works with 2.1.6 (but not 2.1.2 for the record).
> (*Chris*)
What went wrong in 2.1.2? This intrigues me :)
-Wes
>
> On Wed, Jul 15, 2009 at 8:11 AM, Musachy Barroso <mu...@gmail.com> wrote:
>
>> I think the last release worked with 2.1 right?
>>
>> musachy
>>
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: JSON Plugin and S:Action
Posted by Chris Pratt <th...@gmail.com>.
Yup, the latest jar file works with 2.1.6 (but not 2.1.2 for the record).
(*Chris*)
On Wed, Jul 15, 2009 at 8:11 AM, Musachy Barroso <mu...@gmail.com> wrote:
> I think the last release worked with 2.1 right?
>
> musachy
>
> On Wed, Jul 15, 2009 at 5:59 AM, Wes Wannemacher<we...@wantii.com> wrote:
> > On Wed, Jul 15, 2009 at 3:35 AM, Chris Pratt<th...@gmail.com>
> wrote:
> >> Ok, now I'm totally confused. The documentation at
> >> http://cwiki.apache.org/S2PLUGINS/json-plugin.html says that the
> plug-in
> >> required 2.0.6 or greater. It clearly did not support 2.1.2, but it
> seems
> >> to support 2.1.6. Is the documentation wrong, should that say 2.1.6
> instead
> >> of 2.0.6?
> >> (*Chris*)
> >>
> >
> > It is probably not clear in the json plugin docs, but in the move to
> > 2.1, the build for the plugin broke. I didn't notice until
> > 2.1.3-SNAPSHOT and we made some changes to get it working again.
> > Fortunately, the changes were only in unit tests, so you can build it
> > by disabling the tests and it should work. If you drop in the jar and
> > it doesn't work, let us know and we can figure it out from there.
> >
> > -Wes
> >
> > --
> > Wes Wannemacher
> > Author - Struts 2 In Practice
> > Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> > http://www.manning.com/wannemacher
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: JSON Plugin and S:Action
Posted by Musachy Barroso <mu...@gmail.com>.
I think the last release worked with 2.1 right?
musachy
On Wed, Jul 15, 2009 at 5:59 AM, Wes Wannemacher<we...@wantii.com> wrote:
> On Wed, Jul 15, 2009 at 3:35 AM, Chris Pratt<th...@gmail.com> wrote:
>> Ok, now I'm totally confused. The documentation at
>> http://cwiki.apache.org/S2PLUGINS/json-plugin.html says that the plug-in
>> required 2.0.6 or greater. It clearly did not support 2.1.2, but it seems
>> to support 2.1.6. Is the documentation wrong, should that say 2.1.6 instead
>> of 2.0.6?
>> (*Chris*)
>>
>
> It is probably not clear in the json plugin docs, but in the move to
> 2.1, the build for the plugin broke. I didn't notice until
> 2.1.3-SNAPSHOT and we made some changes to get it working again.
> Fortunately, the changes were only in unit tests, so you can build it
> by disabling the tests and it should work. If you drop in the jar and
> it doesn't work, let us know and we can figure it out from there.
>
> -Wes
>
> --
> Wes Wannemacher
> Author - Struts 2 In Practice
> Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
> http://www.manning.com/wannemacher
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: JSON Plugin and S:Action
Posted by Wes Wannemacher <we...@wantii.com>.
On Wed, Jul 15, 2009 at 3:35 AM, Chris Pratt<th...@gmail.com> wrote:
> Ok, now I'm totally confused. The documentation at
> http://cwiki.apache.org/S2PLUGINS/json-plugin.html says that the plug-in
> required 2.0.6 or greater. It clearly did not support 2.1.2, but it seems
> to support 2.1.6. Is the documentation wrong, should that say 2.1.6 instead
> of 2.0.6?
> (*Chris*)
>
It is probably not clear in the json plugin docs, but in the move to
2.1, the build for the plugin broke. I didn't notice until
2.1.3-SNAPSHOT and we made some changes to get it working again.
Fortunately, the changes were only in unit tests, so you can build it
by disabling the tests and it should work. If you drop in the jar and
it doesn't work, let us know and we can figure it out from there.
-Wes
--
Wes Wannemacher
Author - Struts 2 In Practice
Includes coverage of Struts 2.1, Spring, JPA, JQuery, Sitemesh and more
http://www.manning.com/wannemacher
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: JSON Plugin and S:Action
Posted by Chris Pratt <th...@gmail.com>.
Ok, now I'm totally confused. The documentation at
http://cwiki.apache.org/S2PLUGINS/json-plugin.html says that the plug-in
required 2.0.6 or greater. It clearly did not support 2.1.2, but it seems
to support 2.1.6. Is the documentation wrong, should that say 2.1.6 instead
of 2.0.6?
(*Chris*)
On Tue, Jul 14, 2009 at 11:16 PM, Chris Pratt <th...@gmail.com>wrote:
> Ok, calling it from AJAX, instead of <s:action>, seems to work, but
> unfortunately it appears the JSON Plugin isn't compatible with Struts 2.1.
> I'm currently using 2.1.2, but the documentation says that it works with
> 2.0.6. Is there any plan to update it to work with 2.1? What I'm seeing
> is:
>
> java.lang.NoSuchMethodError:
> com.opensymphony.xwork2.ActionContext.get(Ljava/lang/String;)Ljava/lang/Object;
> at
> com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:157)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:355)
> at
> com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:259)
> ...
>
> Thanks.
> (*Chris*)
>
>
> On Tue, Jul 14, 2009 at 8:33 AM, Chris Pratt <th...@gmail.com>wrote:
>
>> Don't know, I was trying to initialize the variable using the same action
>> that would be used to update it. And, because of this problem, I haven't
>> been able to initialize it. Maybe I'll give it a try later.
>> (*Chris*)
>>
>>
>> On Tue, Jul 14, 2009 at 7:49 AM, Musachy Barroso <mu...@gmail.com>wrote:
>>
>>> Never thought of this use case before. Does it work if you use the
>>> action directly, instead of calling from a jsp?
>>>
>>> musachy
>>>
>>> On Mon, Jul 13, 2009 at 11:17 PM, Chris Pratt<th...@gmail.com>
>>> wrote:
>>> > I'm having a problem using <s:action executeResult="true"> with an
>>> action
>>> > whose result type is json. It doesn't insert the results. My Action
>>> is
>>> > something like:
>>> >
>>> > public class InitCalendarAction {
>>> > private List<List<String>> json;
>>> >
>>> > /**
>>> > * Get the JSON Object to be Serialized
>>> > *
>>> > * @return JSON Object
>>> > */
>>> > public Object getJson () {
>>> > return json;
>>> > } //getJson
>>> >
>>> > /**
>>> > * Prepare the Object to be Serialized using JSON
>>> > *
>>> > * @return "success";
>>> > */
>>> > public String execute () {
>>> > Category cat;
>>> > Category[] daily = user.getPlan().getDailyCategories();
>>> > Calendar cal = Calendar.getInstance();
>>> > cal.set(Calendar.DATE,1);
>>> > int first = cal.get(Calendar.DAY_OF_WEEK) - 1;
>>> > List<String> row;
>>> > json = new ArrayList<List<String>>();
>>> > for(int day = 1;day <= cal.getMaximum(Calendar.DATE);day++) {
>>> > row = new ArrayList<String>();
>>> > row.add("true");
>>> > cat = daily[(day + first) % 7];
>>> > row.add(cat.name().toLowerCase());
>>> > row.add(cat.name());
>>> > json.add(row);
>>> > }
>>> > return "success";
>>> > } //execute
>>> >
>>> > } //*InitCalendarAction
>>> >
>>> > I have the action defined as:
>>> >
>>> > <action name="init-calendar" class="initCalendarAction">
>>> > <result type="json">
>>> > <param name="root">json</param>
>>> > </result>
>>> > </action>
>>> >
>>> > In my JSP, I have:
>>> >
>>> > var hilights = "<s:action name='init-calendar' namespace='/'
>>> > executeResult='/'/>";
>>> >
>>> > But instead of the expected:
>>> >
>>> > var hilights = "[ [ "true", "cardio", "Cardio"], [ "true",
>>> "upperbody",
>>> > "Upper Body"] ... ]";
>>> >
>>> > I get:
>>> > var hilights = "";
>>> >
>>> > There are no errors in the logs and when I write out each row in the
>>> array,
>>> > everything is there as expected, but there's just no output. Any
>>> idea's
>>> > why?
>>> > (*Chris*)
>>> >
>>>
>>>
>>>
>>> --
>>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>
Re: JSON Plugin and S:Action
Posted by Chris Pratt <th...@gmail.com>.
Ok, calling it from AJAX, instead of <s:action>, seems to work, but
unfortunately it appears the JSON Plugin isn't compatible with Struts 2.1.
I'm currently using 2.1.2, but the documentation says that it works with
2.0.6. Is there any plan to update it to work with 2.1? What I'm seeing
is:
java.lang.NoSuchMethodError:
com.opensymphony.xwork2.ActionContext.get(Ljava/lang/String;)Ljava/lang/Object;
at com.googlecode.jsonplugin.JSONResult.execute(JSONResult.java:157)
at
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:355)
at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:259)
...
Thanks.
(*Chris*)
On Tue, Jul 14, 2009 at 8:33 AM, Chris Pratt <th...@gmail.com>wrote:
> Don't know, I was trying to initialize the variable using the same action
> that would be used to update it. And, because of this problem, I haven't
> been able to initialize it. Maybe I'll give it a try later.
> (*Chris*)
>
>
> On Tue, Jul 14, 2009 at 7:49 AM, Musachy Barroso <mu...@gmail.com>wrote:
>
>> Never thought of this use case before. Does it work if you use the
>> action directly, instead of calling from a jsp?
>>
>> musachy
>>
>> On Mon, Jul 13, 2009 at 11:17 PM, Chris Pratt<th...@gmail.com>
>> wrote:
>> > I'm having a problem using <s:action executeResult="true"> with an
>> action
>> > whose result type is json. It doesn't insert the results. My Action is
>> > something like:
>> >
>> > public class InitCalendarAction {
>> > private List<List<String>> json;
>> >
>> > /**
>> > * Get the JSON Object to be Serialized
>> > *
>> > * @return JSON Object
>> > */
>> > public Object getJson () {
>> > return json;
>> > } //getJson
>> >
>> > /**
>> > * Prepare the Object to be Serialized using JSON
>> > *
>> > * @return "success";
>> > */
>> > public String execute () {
>> > Category cat;
>> > Category[] daily = user.getPlan().getDailyCategories();
>> > Calendar cal = Calendar.getInstance();
>> > cal.set(Calendar.DATE,1);
>> > int first = cal.get(Calendar.DAY_OF_WEEK) - 1;
>> > List<String> row;
>> > json = new ArrayList<List<String>>();
>> > for(int day = 1;day <= cal.getMaximum(Calendar.DATE);day++) {
>> > row = new ArrayList<String>();
>> > row.add("true");
>> > cat = daily[(day + first) % 7];
>> > row.add(cat.name().toLowerCase());
>> > row.add(cat.name());
>> > json.add(row);
>> > }
>> > return "success";
>> > } //execute
>> >
>> > } //*InitCalendarAction
>> >
>> > I have the action defined as:
>> >
>> > <action name="init-calendar" class="initCalendarAction">
>> > <result type="json">
>> > <param name="root">json</param>
>> > </result>
>> > </action>
>> >
>> > In my JSP, I have:
>> >
>> > var hilights = "<s:action name='init-calendar' namespace='/'
>> > executeResult='/'/>";
>> >
>> > But instead of the expected:
>> >
>> > var hilights = "[ [ "true", "cardio", "Cardio"], [ "true",
>> "upperbody",
>> > "Upper Body"] ... ]";
>> >
>> > I get:
>> > var hilights = "";
>> >
>> > There are no errors in the logs and when I write out each row in the
>> array,
>> > everything is there as expected, but there's just no output. Any idea's
>> > why?
>> > (*Chris*)
>> >
>>
>>
>>
>> --
>> "Hey you! Would you help me to carry the stone?" Pink Floyd
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
Re: JSON Plugin and S:Action
Posted by Chris Pratt <th...@gmail.com>.
Don't know, I was trying to initialize the variable using the same action
that would be used to update it. And, because of this problem, I haven't
been able to initialize it. Maybe I'll give it a try later.
(*Chris*)
On Tue, Jul 14, 2009 at 7:49 AM, Musachy Barroso <mu...@gmail.com> wrote:
> Never thought of this use case before. Does it work if you use the
> action directly, instead of calling from a jsp?
>
> musachy
>
> On Mon, Jul 13, 2009 at 11:17 PM, Chris Pratt<th...@gmail.com>
> wrote:
> > I'm having a problem using <s:action executeResult="true"> with an action
> > whose result type is json. It doesn't insert the results. My Action is
> > something like:
> >
> > public class InitCalendarAction {
> > private List<List<String>> json;
> >
> > /**
> > * Get the JSON Object to be Serialized
> > *
> > * @return JSON Object
> > */
> > public Object getJson () {
> > return json;
> > } //getJson
> >
> > /**
> > * Prepare the Object to be Serialized using JSON
> > *
> > * @return "success";
> > */
> > public String execute () {
> > Category cat;
> > Category[] daily = user.getPlan().getDailyCategories();
> > Calendar cal = Calendar.getInstance();
> > cal.set(Calendar.DATE,1);
> > int first = cal.get(Calendar.DAY_OF_WEEK) - 1;
> > List<String> row;
> > json = new ArrayList<List<String>>();
> > for(int day = 1;day <= cal.getMaximum(Calendar.DATE);day++) {
> > row = new ArrayList<String>();
> > row.add("true");
> > cat = daily[(day + first) % 7];
> > row.add(cat.name().toLowerCase());
> > row.add(cat.name());
> > json.add(row);
> > }
> > return "success";
> > } //execute
> >
> > } //*InitCalendarAction
> >
> > I have the action defined as:
> >
> > <action name="init-calendar" class="initCalendarAction">
> > <result type="json">
> > <param name="root">json</param>
> > </result>
> > </action>
> >
> > In my JSP, I have:
> >
> > var hilights = "<s:action name='init-calendar' namespace='/'
> > executeResult='/'/>";
> >
> > But instead of the expected:
> >
> > var hilights = "[ [ "true", "cardio", "Cardio"], [ "true",
> "upperbody",
> > "Upper Body"] ... ]";
> >
> > I get:
> > var hilights = "";
> >
> > There are no errors in the logs and when I write out each row in the
> array,
> > everything is there as expected, but there's just no output. Any idea's
> > why?
> > (*Chris*)
> >
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
Re: JSON Plugin and S:Action
Posted by Musachy Barroso <mu...@gmail.com>.
Never thought of this use case before. Does it work if you use the
action directly, instead of calling from a jsp?
musachy
On Mon, Jul 13, 2009 at 11:17 PM, Chris Pratt<th...@gmail.com> wrote:
> I'm having a problem using <s:action executeResult="true"> with an action
> whose result type is json. It doesn't insert the results. My Action is
> something like:
>
> public class InitCalendarAction {
> private List<List<String>> json;
>
> /**
> * Get the JSON Object to be Serialized
> *
> * @return JSON Object
> */
> public Object getJson () {
> return json;
> } //getJson
>
> /**
> * Prepare the Object to be Serialized using JSON
> *
> * @return "success";
> */
> public String execute () {
> Category cat;
> Category[] daily = user.getPlan().getDailyCategories();
> Calendar cal = Calendar.getInstance();
> cal.set(Calendar.DATE,1);
> int first = cal.get(Calendar.DAY_OF_WEEK) - 1;
> List<String> row;
> json = new ArrayList<List<String>>();
> for(int day = 1;day <= cal.getMaximum(Calendar.DATE);day++) {
> row = new ArrayList<String>();
> row.add("true");
> cat = daily[(day + first) % 7];
> row.add(cat.name().toLowerCase());
> row.add(cat.name());
> json.add(row);
> }
> return "success";
> } //execute
>
> } //*InitCalendarAction
>
> I have the action defined as:
>
> <action name="init-calendar" class="initCalendarAction">
> <result type="json">
> <param name="root">json</param>
> </result>
> </action>
>
> In my JSP, I have:
>
> var hilights = "<s:action name='init-calendar' namespace='/'
> executeResult='/'/>";
>
> But instead of the expected:
>
> var hilights = "[ [ "true", "cardio", "Cardio"], [ "true", "upperbody",
> "Upper Body"] ... ]";
>
> I get:
> var hilights = "";
>
> There are no errors in the logs and when I write out each row in the array,
> everything is there as expected, but there's just no output. Any idea's
> why?
> (*Chris*)
>
--
"Hey you! Would you help me to carry the stone?" Pink Floyd
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org