tags:

views:

1334

answers:

1

I am using struts2 select tag: http://struts.apache.org/2.0.14/docs/select.html

this is the code

<s:select name="fmrTenant.terminationReason" multiple="true"  headerKey="-1" list="rejectionReasons" value="%{fmrTenant.terminationReason}" required="true" size="10"/>

name="fmrTenant.terminationReason"

refers to the following code

public void setTerminationReason(List terminationReason) {
    this.terminationReason = (String[])terminationReason.toArray();
}

my code is having issues here. Should the parameter type of a variable that stores values coming from select box be List??

I tried looking online for the solution but there seem to be no examples that use struts2 select tag with multiple attribute enabled and show what the java method should look like. I am so confused. I'd appreciate any help

A: 

The following should work just fine (assuming this.terminationReason is a String[]):

public void setTerminationReason(String[] terminationReason) {
    this.terminationReason = terminationReason;
}

Alternatively, if terminationReason is stored as a list the following should work:

private List terminationReason = new ArrayList();

public void setTerminationReason(List terminationReason) {
   this.terminationReason = terminationReason;
}
Rich Kroll