but what about when i get sent back to the form (perhaps from a validation
error).  How will the "selected" select box repopulate itself if all it has
to go on are the Strings in the associated array?

matt.

-----Original Message-----
From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
Sent: Monday, June 11, 2001 12:35 PM
To: [EMAIL PROTECTED]
Subject: Re: Hacking HTML forms


On Mon, 11 Jun 2001, McShane, Matthew wrote:

> Hello,
> 
> I have created a javascript widget which lets users move options from one
> multi-select to another as input to a search.  For example they can select
> one or many hardcoded options in an "allowed" select box and then click on
> an arrow to move the selected options into the "selected-for-this-search"
> select box.  Just before the form is submitted, I also select all the
> options in all the "selected-for-this-search" boxes so that they are
> submitted.
> 
> My question is, can Struts support this?  From the messages on this list
it
> seems like multi-select box values need to be kept in an Array but I think
> mine need to be in a HashMap
> 
> thanks,
> matt.
> 
> 
> 
> 

In principle, it *should* still work with an array.

The key is that your setter method should take a String array as the arg:

  public void setSelectResults(String selectResults[])

and Struts will then accumulate all of the options that were actually
selected into a String array and call this setter for you.  Because it's a
new array, there is no requirement that the number of selected items be
the same (or anything like that).  Struts does not really care what
happens on the client side before the submit (which is where your
JavaScript manipulations to implement the above takes place).

Craig

Reply via email to