public String intercept(ActionInvocation actionInvocation) throws Exception {
Map parameters = actionInvocation.getInvocationContext().getParameters();
Map< String, Object > newParams = new HashMap< String, Object >();
Set< String > keys = parameters.keySet();
for (Iterator< String > iterator = keys.iterator(); iterator.hasNext();) {
String key = iterator.next();
if (key.startsWith("__multiselect_")) {
String name = key.substring("__multiselect_".length());
iterator.remove();
// is this multi-select box submitted?
if (!parameters.containsKey(name)) {
// if not, let's be sure to default the value to an empty string array
newParams.put(name, new String[0]);
}
}
}
parameters.putAll(newParams);
return actionInvocation.invoke();
}
Just as the CheckboxInterceptor checks that if only the hidden field is present, so too does this interceptor.
If the "__multiselect_" request parameter is present and its visible counterpart is not, set a new request parameter
to an empty Sting. |