Hi,
I have a Velocity template that is attempting to allow users to select multiple Project Categories;
<table cellpadding="2" cellspacing="2">
#foreach ($projectCategory in $projectCategories)
<tr>
<td><input type="checkbox" name="projectCategories" value="$projectCategory.getId()"
#if (${selectedProjectCategories})
#if (${selectedProjectCategories.contains($projectCategory.getId())})
CHECKED
#end
#end
></td>
<td>#displayConstantIcon ($projectCategory) $projectCategory.getName()</td>
</tr>
#end
</table>
By using the same "name" property for each checkbox, I can access all the selected ids from the parameters;
public Map<String, Object> getDescriptorParams(Map params) {
if (params != null && params.containsKey("projectCategories")){
return MapBuilder.build( "projectCategories", params.get("projectCategories"));
}
return MapBuilder.build( "projectCategories", new ArrayList<String>());
}
However, when I then extract these via the "FunctionDescriptor", the ArrayList is now a string and I am unable to access the original values;
functionDescriptor.getArgs().get("projectCategories")
Any ideas? To get around this I have had to use unique "name" properties prefixed with a common string, and then extract each entry in the params which has a key that starts with the common string. This really smells to me!
Thanks
Robbie
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.