0

I am using Struts2 JSON plugin to retrieve a list of my events in JSON format, when the page() method is executed. My action is:

public class EventCrud extends WebAppBaseAction implements ModelDriven<Event>, Preparable{

    private static final long serialVersionUID = 4626472213336441724L;
    private com.infopool.dao.Event eventDao;

    private Event model = new Event();
    private GooglePlace placeHolder = new GooglePlace();
    private List<Event> events;

    public String page(){

        if(events == null)
            events = eventDao.findAll();

        return SUCCESS;
    }
}

The problem is that, Strut2 serialize the object returned by getModel(). How i can change this behavior ?.

ramiromd
  • 2,019
  • 8
  • 33
  • 62

1 Answers1

1

I just solve the problem. I only set the JSON root property from struts.xml:

<action name="page" class="com.infopool.action.EventCrud" method="page">
   <result type="json">
        <param name="root">events</param>
    </result>
</action>

So, now i can serialize the "events" property of my Action.

ramiromd
  • 2,019
  • 8
  • 33
  • 62