[
https://issues.apache.org/jira/browse/WW-4246?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Lukasz Lenart closed WW-4246.
-----------------------------
Resolution: Not A Problem
Assignee: Lukasz Lenart
Please ask such questions on Struts Users Mailing List <[email protected]>
> Struts 2 JSON interceptor for Custom Maps
> -----------------------------------------
>
> Key: WW-4246
> URL: https://issues.apache.org/jira/browse/WW-4246
> Project: Struts 2
> Issue Type: Improvement
> Components: Plugin - JSON
> Affects Versions: 2.2.3.1
> Reporter: hemantvsn
> Assignee: Lukasz Lenart
> Priority: Critical
>
> I have following POJO's
> {code:java}
> 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
> @Override
> public String execute() {
> //populate "categories" and "categorizedUsers" with some business
> logic
> return SUCCESS;
> }
> }
> {code}
> 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
> {code:xml}
> <action name="mywidget" class="com.struts.action.MyAction">
> <result type="json">
> <param name="includeProperties">
> ^categories\[\d+\]\.id,
> ^categories\[\d+\]\.title,
> </param>
> </result>
> </action>
> {code}
> 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
(v6.1#6144)