I've read the posts on logic:iterate (and all over google) and have a snag..
I'm iterating over a Vector that contains 'AppPermission' objects.
Each AppPermission object has a boolean property 'cb'.
I use this vector (which is in the session) to prepopulate the checkboxes:
<logic:iterate id="permBoxes" name="<%=AppConstants.UserAPVector%>" indexId="permIndex" type="util.AppPermission">
<html:checkbox indexed="true" name="permBoxes" property="cb" value="true" />
<!--
Struts False Submit -->
<html:hidden indexed="true" name="permBoxes" property="cb" value="false" />
So the checkboxes show up fine, checked as specified in the session's vector. Now, I want to grab any changes to the checks, and update the session vector. To do this, here's my ActionForm code:
// Permissions Checkboxes
private AppPermission [] permBoxes;
public AppPermission [] getPermBoxes() {
return this.permBoxes;
}
public void setPermBoxes(int index, boolean thePerm) {
try {
if (permBoxes == null) {
permBoxes = new AppPermission[100];
}
permBoxes[index].setCb(thePerm);
}
catch (Exception e) {
log("Exception in setPermBoxes: " + e);
}
}
And it doesn't work. The try/catch new AP[100] thing was a suggestion from an earlier post.. might not be needed. The error I'm getting when I try any kind of action from the checkbox page is:
java.lang.NullPointerException
at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:515)
at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:428)
at org.apache.commons.beanutils.PropertyUtils.getNestedProperty(PropertyUtils.java:770)
at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:801)
Will it work to use the vector of AppPermissions' cb values to prepopulate the boxes, and then be able to retrieve the array of checkbox values to update the Vector? For more info, here's a snippet of the generated HTML:
...
...
<input type="checkbox" name="permBoxes[2].cb" value="true">
<!-- Struts False Submit -->
<input type="hidden" name="permBoxes[2].cb" value="false">
...
...