1

I'm trying to use doubleselect tag from Struts2 by using this link as a guide. When I select the telephone country code (ex: 91, 92, 216), it should display three cities from that country.

For this I have a Map<Integer, List<String>. Below is the tag.

<s:doubleselect 
   name="obj.countryCode" id="countryCode" list="countryCodeCityNameMap.keySet()"
   doubleName="obj.cityName" doubleId="cityName" doubleList="countryCodeCityNameMap" />

This yields a different output. In the first drop-down it displays the country code properly. But irrespective of the selected value in the first drop-down it always shows all the values in the second drop-down like this:

[aaa,bbb,ccc]
[ddd,eee,fff]
[ggg,hhh,iii]

How can i use the Map to get the desired output? Should I create a structure like this as per the given link:

List<Makes> // in first drop-down
Makes contains makeId, modelId and List<Models> // List<Models> in second drop-down
Models contains modelId and modelName

If yes, then how does my scenario fit in to this model?

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
RamValli
  • 4,389
  • 2
  • 33
  • 45
  • Your scenarion doesn't, you didn't post any code related to you model. Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example. – Roman C Jun 16 '16 at 20:52

1 Answers1

1

IF the top object is still available, you should be able to subfilter the inner list using it like follows:

<s:doubleselect 
         name="obj.countryCode"    id="countryCode"    list="countryCodeCityNameMap.keySet()"
   doubleName="obj.cityName" doubleId="cityName" doubleList="countryCodeCityNameMap.get(top)"
/>
Community
  • 1
  • 1
Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243