Checkbox "checked" behaviour is inconsistent with documentation.


There seems to be a problem with the checkbox tag, regarding the behaviour of the "checked" attribute.
Steps to reproduce:

  • Create a simple bean, even one with just a single Long attribute will do, the important thing is that must not be a String.

  • Create a formatter for this kind of bean.

  • Create a simple actionBean that contains a long list of the bean defined above, and a short list of the same beans, containing a few elements of the long list. It's a simple case of many to many matching.

Try to render the list like this:
<c:forEach items="${actionBean.longList}" var="elem" varStatus="status">
<stripes:checkbox name="elems[${status.index}]" value="${elem}" checked="${actionBean.shortList}" />

All checkboxes from the long list are generated, with the correct value, but none is selected.
There seems to be something "strange" (at least for my understanding) in the class InputCheckBoxTag, lines 114-118:

public int doEndInputTag() throws JspException {
// Find out if we have a value from the PopulationStrategy
Object checked = getOverrideValueOrValues();

// If the value of this checkbox is contained in the value or override value, check it
getAttributes().put("value", format(this.value));
if (isItemSelected(this.value, checked)) {

The method isItemSelected is correct, but I don't understand why the "checked" object is obtained by getOverrideValueOrValues() and not using the checked object already in the class. At least, when the checked attribute is a list, the result of getOverrideValueOrValues() seems to be a random element of the list, not the list itself, so the isItemSelected method won't work right. Maybe is this.value that should be assigned from getOverrideValueOrValues() ?






Danilo Ghirardelli




Affects versions