DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://issues.apache.org/bugzilla/show_bug.cgi?id=28965>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://issues.apache.org/bugzilla/show_bug.cgi?id=28965 <html:select> which is not multiple should be able to be used with an array value Summary: <html:select> which is not multiple should be able to be used with an array value Product: Struts Version: 1.1 Final Platform: All OS/Version: All Status: NEW Severity: Enhancement Priority: Other Component: Custom Tags AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] The documentation for the <html:select> struts tag states that if multiple="true" is not selected, the corresponding value must be a scalar type. This prevents the use of placing an <html:select> inside a <logic:iterate> tag. Thus it is not possible to have a dynamic number of select tags and still use the <html:select> and <html:options> struts tag library features. Currently when the type of the value is an array rather than a scalar type, the select and options tag code will cause all the selected values in the array to be selected at all indices. For instance the following jsp code: <logic:iterate name="form" property="arrayFormField" id="val"> <html:select property="arrayFormField"> <html:options collection="options" property="value" labelProperty="label"/> </html:select> </logic:iterate> where "options" is a collection of LabelValueBeans with values "Option 1", "1" "Option 2", "2" "Option 3", "3" and where arrayFormField is type Integer[] with the values 1, 3 will generate the following html: <select name="arrayFormField"><option value="1" selected="true">Option 1</option> <option value="2">Option 2</option> <option value="3" selected="true">Option 3</option> <select> A jsp containing the jsp code above will submit the correct values and struts will popuplate the array form field correctly but when the jsp is redisplayed the html generated will be invalid because multiple options will be selected for each select tag unless all values in the array happen to be the same. One solution to this problem would be to change the select tag to check to see if it has a parent iterate tag and use the index of the iterate tag to choose the value at that index in the associated form property if that property is an array type and the multiple attribute is not set. The problem with this solution that I see is that it is not completely backward compatible. If someone was relying on the incorrect behavior outlined above that occurs when they use an array value for a select which is not multiple (explicitly not supported) then the first solution will cause them a measure of pain. This is perhaps not a bad thing, depending on your perspective. Another solution is to add an attribute that allows the value to be provided as a bean. This solution extends the "value" attribute of the select tag but the value of the attribute is dynamic rather than static text. The problem with this solution is that to be entirely consistent, the bean value should have a name, property, and scope. This introduces a lot of new attributes to a tag library already bloated with attributes. Also there is the problem of what to call these attributes so that their purposes are clear. The benefits of this solution are that it is flexible, such that you can specify any dynamic bean value to use as the value for a given select within a loop, and it is completely backward compatible. I have implemented both solutions and will attach the diff files for each. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
