Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

includeProperties in Json struts2 plugin not working

I am using struts2-json-plugin-2.2.3.jar. and trying to serialize filterList property of class like this:

struts.xml code

<action name="jsonUserFilterListAction"  class="com.my.fitnessb.actions.UserArticlesAction" method="filterList">
        <result  name="success" type="json">
            <param name="includeProperties">filterList</param>
        </result>
 </action>

Action class

public class UserArticlesAction extends ActionSupport implements SessionAware, ServletRequestAware {

  private List<FilterType> filterList;
  HttpServletRequest request;

  public String filterList() {
    filterList = new ArrayList<FilterType>();
    filterList.add(new FilterType(10, "Latest Articles"));
    filterList.add(new FilterType(1, "Trending Articles"));
    filterList.add(new FilterType(2, "Top Rated Articles"));
    filterList.add(new FilterType(3, "Most Viewd Atricles"));
    filterList.add(new FilterType(4, "All Atricles"));
    return SUCCESS;
  }
  //setter & getter of filterList
}

but I'm not able to get this property of FilterType class.

like image 211
Jeetu Verma Avatar asked Jan 21 '13 06:01

Jeetu Verma


1 Answers

Assuming the fields in your FilterType are named id and desc

Try

<param name="includeProperties">
filterList\[\d+\]\.id,
filterList\[\d+\]\.desc
</param>
like image 93
Quincy Avatar answered Oct 05 '22 15:10

Quincy