struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Pratt <thechrispr...@gmail.com>
Subject JSON Plugin and S:Action
Date Tue, 14 Jul 2009 06:17:19 GMT
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*)

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