RE: retaining multi select options with hidden fields

2005-09-23 Thread Vijaya S
If you use the same form bean for the second page and if you do not
initialize the String[] property in your form bean reset method, the form
bean values are available to the second page also.

Vijaya

-Original Message-
From: Tim Dudgeon [mailto:[EMAIL PROTECTED]
Sent: Friday, September 23, 2005 12:59 PM
To: user@struts.apache.org
Subject: retaining multi select options with hidden fields


I need to retain the selections a user has made using a multi-select on one
page by using hidden fields on the next page.

On the first page I have a

html:select multiple=true property=multiSelectProp ...
...
/html:select

multi-select which is populating a String[] property of a form bean, and
then on the second page I need to retain those selections using hidden
fields. What is the syntax I need to use for the hidden fields to ensure
that the String[] property gets set correctly by the BeanUtils magic?

Do I need to iterate through the values of the String[] and write out an
indexed hidden field for each one?

Tim



-
a href=http://Struts_User_List.roomity.com;roomity.com/a
roomity.com is broadband internet. ~~1127460559626~~
-



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



Re: retaining multi select options with hidden fields

2005-09-23 Thread Laurie Harper

Tim Dudgeon wrote:

I need to retain the selections a user has made using a multi-select on one 
page by using hidden fields on the next page.

On the first page I have a

html:select multiple=true property=multiSelectProp ...
...
/html:select

multi-select which is populating a String[] property of a form bean, and then 
on the second page I need to retain those selections using hidden fields. What 
is the syntax I need to use for the hidden fields to ensure that the String[] 
property gets set correctly by the BeanUtils magic?

Do I need to iterate through the values of the String[] and write out an 
indexed hidden field for each one?


Yep, except it needn't be written as an indexed field unless order is 
important. So, something like


  logic:iterate name=MyForm property=multiSelectProp id=value
html:hidden property=multiSelectProp value=${value}/
  /logic:iterate

will do it. If order *is* important, you'll need to include [#] on the 
end of the property name, where # will be the iteration number. 
Something like


  logic:iterate name=MyForm property=multiSelectProp
  id=value indexId=row
html:hidden property=multiSelectProp[${row}] value=${value}/
  /logic:iterate

Note, I haven't tested either solution, but something along those lines 
is what you need.


L.


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