struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Pratt <thechrispr...@gmail.com>
Subject Re: JSON Plugin and S:Action
Date Wed, 15 Jul 2009 06:16:17 GMT
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 <thechrispratt@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 <musachy@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<thechrispratt@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
>>
>>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message