I tried it and still form is not retaining the value

this is the select i declared in my jsp
<html:select size="6"  property="s2" multiple="5"   style="width: 80px" >
                </html:select>



there were another issue in the function which map the fields to the form

till date my dynaaction form were using just String.
so i got away with 
DynaClass dynaClass = form.getDynaClass();
                DynaProperty[] props = dynaClass.getDynaProperties();
for (int i = 0; i < props.length; i++) {
                        Object propertyNameObj = props[i].getName();
String fieldValue = (String) form.get(propertyNameObj.toString()); 

But when i used string[] this was throwing ClassCast exception. and i couldn't find 
anyway to check if form.get(propertyNameObj.toString()) return a String or 
String[]..So i just put (String) form.get(propertyNameObj.toString()); in  a try/Catch 
block and in the catch block i checked for Classcast Exception and then i did
 String[] temp=(String[]) form.get(propertyNameObj.toString());.....Assuming the 
classcast exception is thrown just because form.get(propertyNameObj.toString() 
returned a String Array......Bad  Programming..but couldn't find any other way to do 
that.....!!!!)


Still i have issues..ie my Form is not retaining the multiselect box value..ie when 
any action in the same form post the form and comes back to the same page, i loose the 
data in the multi select box. i tried by selecting the values in the multi select 
box..but still not working...any ideas..?????

thank you
manoj










-----Original Message-----
From: Andrew Hill [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 04, 2003 9:06 AM
To: Struts Users Mailing List
Subject: RE: issue with the multi select


You need to submit the changes in the field contents to the server. I
presume when you talk about the form being 'refreshed' you actually mean
that it POSTs to some action which does some stuff and then you get
forwarded back to the same jsp again?

The web browser will only submit the values for the _selected_ items in the
respective <select> fields. As far as the browser is concerned there are two
seperate select fields, and the values that are selected are only the ones
that are highlighted! (We know of course that its conceptually one field
with one box being unselected stuff and the other box the selected stuff,
but the browser isnt so smart)

What you need therefore is to ensure that the values are selected
(highlighted) at submit time.
This will involve some fancy javascript coding to go and set the 'selected'
property on all the option elements in both boxes when the form is
submitted.

(Before going ahead and spending time writing javascript to do this you will
probably want to confirm that this actually is the issue by manually
highlighting all the values in both boxes in your page, and invoking the
submit. See how it gets handled and what gets submitted in the request)

<snip>
I HAVE DECLARED 2 STRINGS FOR THESE 2 SELECT BOXES
</snip>

Surely you mean a string array ( String[] ) for each of the 2 fields as they
will both be submitting multiple values?

-----Original Message-----
From: Mathew, Manoj [mailto:[EMAIL PROTECTED]
Sent: Thursday, 4 September 2003 21:43
To: Struts Users Mailing List
Subject: issue with the multi select


Hi all

  I have 2 multi select box( wth size 5)  and have  "ADD" and :remove"
button in a dyna action form. Basically you can select one or more from a
select box and add it to the second one using ADD buton adn remove the
selected using "REMOVE" button. I have some other actions also in the same
page.

issue:

   Add and REmove are working(in java script). but when he entire form is
refreched( when some other actions are executed), the select box is not
retaining the value.So basically "ADD" and"REMOVE" is not updating the form
values. I checked the valuew of the select boxes when the form is posted.
The values are not correct. ie it is not retaing my "ADD" and "REMOVE"
values..

IN STRUCTS_CONFIG, I HAVE DECLARED 2 STRINGS FOR THESE 2 SELECT BOXES

ADD
function add(value,to)
{ 
        var newoption= new Option(value,value);
        document.forms[0].s2.options[document.forms[0].s2.length]=newoption;
                
}
function remove(from) { 
        for (var i=(from.options.length-1); i>=0; i--) { 
                var o=from.options[i]; 
                if (o.selected) { 
                        from.options[i] = null; 
                       
                        } 
                } 
        from.selectedIndex = -1; 
        } 

thank you
manoj

---------------------------------------------------------------------
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]


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

Reply via email to