You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ts...@nildram.co.uk on 2002/07/16 13:06:05 UTC

html:options

Hi,

We're trying to use the html:options tag (struts 1.0.2) to render a drop list containing the values from a String Tokenizer, which is tokenizing a comma delimited string.  We just want a drop list that contains each of the values in the list, with the value and description identical.

The behaviour we are seeing is that we are getting half the number of options, because the code is sticking the first value from the list as the value, then the second as the description, then the third as the second value, and the forth as the second description. 

This would appear to be bourne out by this code from the tag itself:

      // Otherwise, use the separate iterators mode to render options
        else {

              // Construct iterators for the values and labels collections
              Iterator valuesIterator = getIterator(name, property);
              Iterator labelsIterator = null;
              if ((labelName == null) && (labelProperty == null))
                  labelsIterator = getIterator(name, property); // Same coll.
              else
                  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;
                  if (labelsIterator.hasNext())
                      label = labelsIterator.next().toString();
                  addOption(sb, value, label,
                            selectTag.isMatched(value));
              }
	}

It's using the same iterator for labels and values, and doing a next() twice per row.

Is this a bug?  Am I missing something obvious?

Cheers,

Tim.





--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>