2

I have a scenario where I want to send SelectOption object to action class on change of struts jQuery dropdown, but it seems like it`s not possible.

Is there any workaround or any way out to get this done?

JSP code:

<sj:select href = "%{fetchCountry}" 
             id = "country" 
 onChangeTopics = "reloadsecondlist" 
           name = "country" 
          value = "%{country}"
           list = "countryList" 
        listKey = "key" 
      listValue = "value" 
    emptyOption = "false"
      headerKey = "-1" 
    headerValue = "Please Select a Country" />

Note: DropDown consist of list of SelectOption object.

Update:

<s:url id="fetchState" action="json" method="fetchState" namespace="/"/>

<sj:select href = "%{fetchState}" 
             id = "stateID" 
        formIds = "formSelectReload"
   reloadTopics = "reloadsecondlist" 
           name = "state" 
          value = "%{state}" 
           list = "stateMap" 
        listKey = "key" 
      listValue = "value" 
    emptyOption = "false" 
      headerKey = "-1" 
    headerValue = "Please Select a State" />
Roman C
  • 49,761
  • 33
  • 66
  • 176
Ashutosh Ranjan
  • 333
  • 2
  • 14
  • What is it SelectOption object? – Roman C Jun 23 '15 at 16:47
  • 1
    SelectOtion is a class having members Long key, String value. In my case i used the object of this class to populate countryList like : List countryList = new ArrayList<>(); SelectOption so = new SelectOption(1L,"India"); countryList .add(so); – Ashutosh Ranjan Jun 24 '15 at 04:38
  • Is this list populated? Also I want to see the reload topic handler source code. – Roman C Jun 24 '15 at 07:25
  • 1
    yes this list **countryList** is populated in struts action and i`m using it in Jsp as you can see in above code. I have updated the question for reload topic handler. – Ashutosh Ranjan Jun 25 '15 at 06:11
  • 1
    Define it's not possible. Which error do you get ? And what exactly do you want to achieve, sending value from select1 to load select2 based on that ? – Andrea Ligios Jun 25 '15 at 09:09
  • @AshutoshRanjan You can listen on topic change event and send key/value pair via ajax. The action code/and config is required to populate with parameters – Roman C Jun 25 '15 at 09:19
  • 1
    @Roman C You are right, i can do that and i know how to do that. But I was wondering if it is possible to send whole object instead sending key/value pair independently. This is the main reason i raised this question. In Wicket framework onchange event of DropDown you can get the required object directly, and i`m trying to do the same for my struts2 project. – Ashutosh Ranjan Jun 26 '15 at 11:07
  • @AshutoshRanjan What do you mean to send the whole object, the object could be serialized and sent, and consumer has to deserialize it before the using. You can send the object serialized as key/value pair, there're different serializeres exist. I don't understand the question, because it's probably off-topic. – Roman C Jun 26 '15 at 12:53

0 Answers0