Hi,

I'm relatively new with Struts2, but I'm starting to get a handle on how things work. However, I'm having a problem with creating a "default" list of pre-selected values for an <s:select> tag when using the "multiple=true" option. It works fine when I use single selection, and when the "pre-selected" values are loading by the framework automatically, but I can't seem to get a manually-created list to select anything.


Here is the struts tag I'm using (altered slightly to remove project-specific details):

<s:select headerKey="-1"
       headerValue="Any Item"
       id="pickedItem"
       label="Item"
       list="items"
       listKey="itemId"
       listValue="itemVal"
       multiple="true"
       name="pickedItems"
       size="8"
       value="selectedItems"
/>

the list/listKey/listValue all seem to work fine, as far as I can see. itemId is an integer.

the value of "selectedItems" calls the "getSelectedItems" from an Action class I'm using. The code for that is as follows:

public List<Integer> getSelectedItems() {
       if (pickedItems == null || pickedItems.size() == 0) {
           List<Integer> defaultList = new ArrayList<Integer>();
           defaultList.add(-1);
           return defaultList;
} else { return pickedItems;
       }
   }

pickedItems is sometimes populated automatically by an AJAX-based action call, and the list on the screen is refreshed; the previously selected items remain selected. However, when the page first loads, I want it to automatically select the "Any Item" option.

I'm using Struts 2.0.11.1

Thanks!

Scott

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to