You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Chalmers, Douglas" <Do...@Petrotechnics.com> on 2001/02/21 19:08:24 UTC

Options tag / Form Bean

Use of Struts tags SELECT/OPTIONS

In our application currently under development
(Weblogic5.1/Struts/JSP/EJB) we're trying to do the following: 

Populate a Selectable List Box using an ArrayList (mimics a service
which will eventually come from a db) which at the moment is just
declared within the Event Processor for that page, placed into the
session and retrieved through the OPTIONS tag. Like so:

<html:select style='width:220;height:250;' property='availparts'
size='8' multiple='1'
ondblclick="move(this.form.availparts,this.form.selectparts,this.form.se
lected,'add')">                                      
     <html:options collection="users" property="name"
labelProperty="label"/>
</html:select>

This works fine, the problem occurs when each list member is added to a
second list, which is also selectable to remove members back to the
first list.
I'm trying to find a way of linking the second list to the form bean so
the list contents can be added to an EJB.

After much trying, I've got round the problem by using Java Script to
populate a hidden field as a delimited string, which can then be easily
related to form bean get and set methods.

Is there an easier way to link a list (which is itself a selectable
list) to the form bean to hold all values present in that list. I've
managed to pass the SELECT tag as a String and an Object, but that only
retrieves the selected item.

I've tried various combinations of fields, but the problem still remains
as to what kind of data structure to send/receive. 

I've thought of holding a 'floating' ArrayList in session and passing
values that way but that seems messy (as is the hidden field method).

Cheers  

Doug Chalmers
Software Development
Petrotechnics Ltd
Exploration House
Exploration Drive
Aberdeen
707303 (Ext 14)