AEM: getting states matching country from another

2019-08-09 23:28发布

问题:

I have the following design issue:

  1. I am reading a node which has country and states using which I could create a new json structure of country states.

  2. Using this json structure in point 1, I have consumed country using my country component as a dropdown. Using each country in a drop down in the country component, I can create different selections of countries by dragging multiple instance of country component. I can pull a default sling servlet by calling this authored page by appending .infinity.json which will give me list of countries that was authored using this country component.

  3. Now, I am creating another servlet which reads the above infinity.json page in point 2, how can I refine it further to add states of those countries which I initially read in point 1 and populated in the new JSON structure.

Here is what I have done so far:

in the servlet mentioned in point 1, the following will create a country and state mapping:

MultiMap multi = new MultiMap(); //this has setters and getters
multiMap.put(country.toUpperCase(), state);
LOG.info(this.getMultiMap().entrySet(); //looks good

Here is the issue: in the servlet mentioned in the point 3, I am trying getting the country-states mapping from above multimap but it is null.

MultiMap map = countryStateServlet.getMultiMap(); //this is null

what am I doing wrong ?

It seems to be an inter object communication issue because resource from I/O are read during runtime only(if I am correct). Need some pointers how to proceed further.