Hi,
Can the following code of the OptionsTag.doEndTag() method
// 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, match);
}
Be changed to this:
// 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));
}
Why the cast?
Why not call the toString() method (if it is a string it returns directly the this)
This is because i have options where the values are a Integer array.
So i want to set a Integer Array as the values.
But the i get a classcast exception because struts wants it to be a String.
Now i must do this (made very simple):
String[] getValues()
{
Integer[] aiValues = database.getValues();
String[] asValues = new String[aiValues.length];
for(int i = aiValues.length; --i >= 0;)
{
asValues[i] = aiValues[i].toString();
}
return asValues;
}
I find this very annoying.
Johan