A mix of JSP/javascript. Possibly more javascript than
JSP, but there are some dynamic elements to it.
I'm not sure exactly what the name of the checkbox is.
In your first post it is name="<%= modCode %>"
in the full code it is name="modCode"
Which is it?
From what I can see you have a list of modules.
Each module contains a list of tasks.
You generate a checkbox for each task in a module.
My assumption:
The validator has to make sure that
for each moduleone checkbox is checked.
The javascript:
Here is a javascript function that will check to see if any checkboxes are checked for all the checkboxes in one group.
It also accounts for the cases where there are
- no checkboxes
- one checkbox
- multiple checkboxes.
Now the java/jsp bit.
You just need to call this function from your current validSecurityClass() function.
in the case that you only need one checkbox checked out of all of the checkboxes on the page, and it is name="modCode"
then this will do the trick:
var checkBoxChecked = validateCheckBoxes(thisForm, "modCode");
If it is name="<%= modCode %>"
you need to generate multiple calls to make sure that for each module, at least one task is clicked:
var checkBoxChecked = "true";
// loop for Each module:
checkBoxChecked = checkBoxChecked && validateCheckBoxes(thisForm, "<%= modCode %>");
which will generate code like this:
The final thing I would suggest is to use JSTL for looping rather than scriptlet code. It would be much neater than scriptlet code ;-)
Good luck,
evnafets