My guess is that the headerKey attribute is always evaluated as a string.

Since you're using a List<Integer>, even if the string representations are the 
same, it won't match (see [1]).

That's probably worth an "improvement" JIRA if there isn't one in there 
already, although I haven't looked at it to see how easy/hard the change would 
be.

Dave

[1] Select tag: http://struts.apache.org/2.x/docs/select.html

--- On Fri, 8/29/08, Scott Lewis <[EMAIL PROTECTED]> wrote:

> From: Scott Lewis <[EMAIL PROTECTED]>
> Subject: Problem with creating default selection values in multiple select
> To: user@struts.apache.org
> Date: Friday, August 29, 2008, 1:54 PM
> 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]

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

Reply via email to