struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "hemantvsn (JIRA)" <>
Subject [jira] [Created] (WW-4246) Struts 2 JSON interceptor for Custom Maps
Date Wed, 20 Nov 2013 05:45:21 GMT
hemantvsn created WW-4246:

             Summary: Struts 2 JSON interceptor for Custom Maps
                 Key: WW-4246
             Project: Struts 2
          Issue Type: Improvement
          Components: Plugin - JSON
    Affects Versions:
            Reporter: hemantvsn
            Priority: Critical

I have following POJO's
public class Category {
    private Integer id;
    private String title;
    private String description;

    //many more attributes below

public class User {
        private Integer id;
        private String name;
        private String address;

           //many more attributes below

public class MyAction extends ActionSupport {
       //list of objects
    List<Category> categories;
       //Complex Map
    private Map<Category, List<User>> categorizedUsers;
       //getters and setters

    public String execute() {
        //populate "categories" and "categorizedUsers" with some business logic
        return SUCCESS;  
I make an AJAX call for this action and expect the data (ie "categories" and "categorizedUsers")
in JSON format. Struts2 provides us with JSON interceptor where I can specifically filter
the parameters to be serailized.

Following is configuration in struts xml file

     <action name="mywidget" class="com.struts.action.MyAction">
                 <result type="json">
                    <param name="includeProperties">

Both the POJOS contain a lot of attributes, but with "includeproperties", I was able to filter
out id and title for each Category in the LIST.

However for the map key as well as value, Im unable to apply any such regex pattern to filter
out desired attributes. (Lets say for the map key (Category), I need id and title, whereas
for each Value (User), I need to filter out id, name only). Please suggest appropriate regex
pattern to be applied on the Map<Category, List<User>>.

This message was sent by Atlassian JIRA

View raw message