A <select> element (it's probably best not to refer to an HTML element by its Struts tag in an HTML forum) always has a value. If none is explicitly specified in the markup, that value is the first option in its list.
What is it that you are actually trying to accomplish? If you merely don't want the element's value to be submitted as part of the form, set the element to disabled.
I have a 2 lists. The list at the left contains elements that can be transferred to the list at the right. My problem is this, whenever I try to transfer all the elements from the left list to the right list, the left list is not emptied even if I have set it into null.
When I transfer the elements from left list to right list, the property for the left list is retrieved from the Action Form, this property should contain null value since I have already transferred all elements to the right list. But this is not happening, the property still contains the elements that it previously has thus the elements that have been previously transferred remains in the left list.
[ March 12, 2008: Message edited by: Darren Alexandria ] [ March 12, 2008: Message edited by: Darren Alexandria ]
This is sounding more like a Struts issue. The only values that will get submitted with the form are the selected items in your list. Is your form configured to use session scope? If that is the case then it sounds like you need to implement the reset method on your form to clear the lists.
Originally posted by Brent Sterling: This is sounding more like a Struts issue.
Joined: Feb 08, 2006
I saw a mention of an Action Form and I thought we switched to talking about after the page was submitted, but I think I read that wrong.
If you are trying to remove items from the select element you can call the remove method. I tried setting the options array to null or to a new array but that did not seem to work for me. The following code will clear the list: