I want to populate some check boxes with apropriate values retrieved from a DB. I have a group of check boxes with the same name. (i.e. multiple can be selected). I know I probably need to get the parameter name before I can access it, but only checked checkboxes are passed back to the server using getParameterValues, and I need access to the entire checkboxes so that I can mark the appropriate ones as checked.
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
I face a similar situation. What I'm thinking of doing is including a count of how many should be there. Each check box is named the same, but it's value relates to the PK of the table.
Then I can run through each returned value, and use the id as an array index. The array contains all possible values (the count of how many there should be), but my checkboxes will only turn on certain array elements. Then I can cycle through this array and see which ones are 'true' and which are 'false'.
This is off the cuff. Anyone have a different idea.?
Joined: Nov 06, 2000
Thanks for the response. The solution I went with is calling a java method when the form is being painted. This method accesses the arrayList of checkboxes that should be checked, and then returns a boolean if the checkbox should be checked or not. Based on the value returned, I check/do not check the checkbox. ex. <% myMethod(chackBoxValue) ? "CHECKED" : "" %> where mymethod is called with the value associated with the particuler checkbox.