struts2: select tag and parameters property of bean
posted 4 years ago
I have a base class ReportElement which has type property:
ReportElementType is just an enum with specified code and i18nKey properties for each element. I have a couple of subclasses of ReportElement, each of them introducing their own properties. One of them is Plot:
On some page I needed to display a collection of different ReportElement instances, so I just used struts2 select tag:
This worked like a charm for every element except for Plot instaces. Instead of invoking getType().getCode() or getType().getI18nKey() plain toString() was invoked on every instance of Plot! After several hours of fun debugging I noticed that during tag evaluation Plot's getParameters() method is called! So it seems struts was trying to evaluate type.code and type.i18nKey using getParameters() method! Failing to do that it ignored the existence of the properties, that I have clearly specified for usage!
After renaming getParameters to a kind of odd name like getParamms the problem gone. Also the problem with evaluating ognl wasn't spotted when using iterator tag together with property tag.
Does anyone have an idea WHY struts uses parameters property of my bean, when I have clearly specified what property should be used? Is it some "cool" feature or a bug?