You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bhaarat Sharma <bh...@gmail.com> on 2009/04/17 00:48:31 UTC
setting multiple values via struts2 select tag
I have a struts 2 select tag like this:
<s:select emptyOption="true" name="fmrUsers.terminationReason"
multiple="true" headerKey="-1" list="rejectionReasons"
value="%{fmrUsers.terminationReason}" required="true" size="10"/>
everything seems to work OK except that when i select values and click
submit. they are not being updated and not showing on the page that comes
after submit is clicked.
name="fmrUsers.terminationReason" corresponds to the following method:
public void setTerminationReason(String[] terminationReason) {
this.terminationReason = terminationReason;
}
and value="%{fmrUsers.terminationReason}" corresponds to the following
method:
public List getTerminationReason() {
return Arrays.asList(terminationReason);
}
On the page that displays results (comes after submit) I have the following
code which is used to display the rejection reasons
<td class="nav"><s:property value="terminationReason"/></td>
it corresponds to following java code
public List getTerminationReason() {
return Arrays.asList(terminationReason);
}
I have hardcoded some sample data for example:
returnListArray.add(new FormerUsers("123456789", new String[]
{"Reason1","Reason2","Reason3"});
the above code displays the rejections reasons successfully on my list
page. However, when i select other reasons from the edit page and click
submit, the list page is not showing the changes that I made. Why is it not
picking up the data selected in the multiple box? so i need to change the
data type of my methods? if so, to what should i change it to.
If its confusing...I am just trying to see how multiple things can be
selected from a multiple box and stored back into the data...