Hi,

I had the requirement to have multiple checkboxes with the same name which
would result in multiple request parameters with the same name but different
values. To have these checkboxes checked on redisplay I wrote the following
helper method:

public boolean requestHasParameter(String fieldName, Object value) {
 String[] values = pageContext.getRequest().getParameterValues(fieldName);
 if (null != values)
  return ContainUtil.contains(values, value.toString());
 else
  return false;
}

This method is placed in CheckBoxTag currently, but is perhaps better suited
for ComponentTag. The related checkbox template now look like this:

[...]
<input type=checkbox <webwork:if
test="requestHasParameter(parameters['name'], parameters['fieldValue']) ==
true">CHECKED</webwork:if>
[...]

Is there a better way doing this? I took a look at the select.jsp template,
because the same functionality is needed for multiple select boxes, but
couldn't figure out how this template checks if there are multiple items
selected ...

Greetings
Christoph


_______________________________________________
Webwork-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/webwork-user

Reply via email to