[ http://issues.apache.org/struts/browse/STR-301?page=all ] David Evans closed STR-301: ---------------------------
Resolution: Fixed > OptionsTag.doEndTag -> calls method to populate selects twice > ------------------------------------------------------------- > > Key: STR-301 > URL: http://issues.apache.org/struts/browse/STR-301 > Project: Struts Action 1 > Type: Improvement > Components: Taglibs > Versions: Nightly Build > Environment: Operating System: All > Platform: All > Reporter: jduff > Assignee: Craig McClanahan > Priority: Minor > Fix For: 1.2.8 > > When the logic falls into the section of code that uses "separate iterators" > to render the options there is the potential that the getIterator() is > called twice to get an iterator to the same list. It is extremely > inefficient > in the sense that the underlying method that returns the collection for the > iterator may have significant processing involved. From a purists > standpoint, in this situation, there is simply no reason to have to do this > twice, regardless of the degree of inefficiency. This could be corrected by > slightly modifying the code to use a combination of a flag > and only one iterator as noted in the new code included in the bottom of this > file... > public int doEndTag() throws JspException { > ... > if (collection != null) { > ... > else { > // Construct iterators for the values and labels collections > Iterator valuesIterator = getIterator(name, property); > Iterator labelsIterator = null; > boolean labels = false; > if ((labelName != null) || (labelProperty != null)) { > labels = true; > labelsIterator = getIterator(labelName, labelProperty); > } > // Render the options tags for each element of the values coll. > while (valuesIterator.hasNext()) { > String value = valuesIterator.next().toString(); > String label = value; > // Get the label values for each option > if (labels == true) { > if (labelsIterator.hasNext()) { > label = labelsIterator.next().toString(); > } > } else { > // if the label property was not specified the label will > // be the same as the actual value for the option > label = value; > } > addOption(sb, value, label, selectTag.isMatched(value)); > } > } > ... > } > Thanks. > jason -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/struts/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]