Spring: multiple checkbox bind

hi experts,

There are seven check boxes html and Java code attached. The Java code just binds boolean code, however I need to buy int values like 1, 2, 8, etc. Can anybody give me a hint how to do this?

Thanks so much.
<tr>
  <td><INPUT TYPE="CHECKBOX" NAME="dayOfWeek" id="dayOfWeek" value=1>Sun</td>
  <td><INPUT TYPE="CHECKBOX" NAME="dayOfWeek" id="dayOfWeek" value=2>Mon</td>
  <td><INPUT TYPE="CHECKBOX" NAME="dayOfWeek" id="dayOfWeek" value=4>Tue</td>
  <td><INPUT TYPE="CHECKBOX" NAME="dayOfWeek" id="dayOfWeek" value=8>Wed</td>
  <td><INPUT TYPE="CHECKBOX" NAME="dayOfWeek" id="dayOfWeek" value=16>Thu</td>
  <td><INPUT TYPE="CHECKBOX" NAME="dayOfWeek" id="dayOfWeek" value=32>Fri</td>
  <td><INPUT TYPE="CHECKBOX" NAME="dayOfWeek" id="dayOfWeek" value=64>Sat</td>

 </tr>

-------------------------
  <c:forEach items="${command.campaign.dayOfWeek}" var="child" varStatus="loopStatus">
     <spring:bind path="command.campaign.dayOfWeek[${loopStatus.index}].selected">
        <input type="hidden" name="_${status.expression}">
        <input type="checkbox" name="${status.expression}" value="true">
            <c:if test="${status.value}">checked</c:if>
     </spring:bind>
   </c:forEach>

Open in new window

davidw88Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

davidw88Author Commented:
Here is more details. The seven check boxes each has an int value. When a user creates a new record, he/she checks any days from Monday to Sunday. Corresponding values to the day will be saved into database.

When a user edits his/her record, the saved checkbox information will be retrieved and these checkboxes should be checked.

Is this clear?

Any help? Thanks a lot.
0
davidw88Author Commented:
I increase the points to 500. I am new in this Spring field therefore any help is much appreciated.
0
Sathish David Kumar NArchitectCommented:
what is ur problem can you tell me clearly as per ur multiple selection is correct
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

davidw88Author Commented:
Thanks dravidnsr for your reply. Let me ask these questions.

(1.) where do I define and assign "Sun", "Mon", "Tue", etc and corresponding values of 1, 2, 3, etc? Is it in Controller class?

The multiple selection Java code does not define and assign these values.  In someplace there should be  something like this:

["Sun":1, "Mon":2, "Tue":3, ...]


(2.) In Dao class "Campaign.java" I define

private Integer [] dayOfWeek;

and related set and get methods. Do I need to do anything else in Dao class?

0
davidw88Author Commented:
How to write this:

There is error with it.
 <tr>
    <spring:bind path="command.campaign.dayOfWeek">
        <td><INPUT TYPE="CHECKBOX" NAME=${status.expression}"  value=1>Sun</td>
        <td><INPUT TYPE="CHECKBOX" NAME=${status.expression}"  value=2>Mon</td>
    </spring:bind>

 </tr>

Open in new window

0
davidw88Author Commented:
This still has error. Can you help to check? Thanks.
<spring:bind path="command.campaign.dayOfWeek">
        <tr>
        <td><INPUT TYPE="CHECKBOX" NAME="${status.expression}"  value="1">Sun</td>
        <td><INPUT TYPE="CHECKBOX" NAME="${status.expression}"  value="2">Mon</td>
        </tr>
    </spring:bind>

Open in new window

0
davidw88Author Commented:
I found the problem. Something was wrong in dao class. The jsp file is ok.
0
Sathish David Kumar NArchitectCommented:
Have found the solution ???
0
davidw88Author Commented:
Yes, it was fixed. However another question comes.

After I have retrieved this record from database, I need to present this record to end users. For checkboxes selected before, I need to show "selected" mark on webpage.

Now assume that "command.campaign.dayOfWeek" is an array of

1, 0, 4, 0, 16, 0, 0

(values greater zero mean that those checkboxes are checked)

and these values correspond to "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", how to modify the attached for loop to show this checked information?

Thanks so much.
<c:forEach items="${command.campaign.dayOfWeek}" var="child" varStatus="loopStatus">
     <spring:bind path="command.campaign.dayOfWeek[${loopStatus.index}].selected">
        <input type="hidden" name="_${status.expression}">
        <input type="checkbox" name="${status.expression}" value="true">
            <c:if test="${status.value}">checked</c:if>
     </spring:bind>
   </c:forEach>

Open in new window

0
davidw88Author Commented:
Hi experts,

No worries... I will work out a solution by myself. So please ignore this thread/post.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.