You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "David Evans (JIRA)" <ji...@apache.org> on 2006/04/27 20:04:18 UTC

[jira] Reopened: (STR-301) OptionsTag.doEndTag -> calls method to populate selects twice

     [ http://issues.apache.org/struts/browse/STR-301?page=all ]
     
David Evans reopened STR-301:
-----------------------------


> 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: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org