riyana
riyana

Reputation: 21705

struts checkbox problem

i have some checkbox in my jsp page. there are some othe textfields in the jsp page. i can populate the value of textboxs from database. like for name field i can fetch the value 'myname' from database and show it in jsp page. but i can't fetch the value of the checkbox from database. like i have a field agriculture in my database and in jsp page. now i want if the value of agriculture in database is 1 then the checkbox of agriculture in jsp page will be 1 also. and if the value is 0 then the checkbox will be unchecked. how can i do it. please help. this is the code fragment oof my jsp page.

    <td><label class="desc"> Agriculture</label></td>
                    <td>                                
                            <html:text property="loanPurposeCodeInfoDTO.agriculture" styleClass="SingleLineTextField" size="30" tabindex="1"  ></html:text>
            <html:checkbox styleId="checkbox_isall" property="loanPurposeCodeInfoDTO.agriculture" ></html:checkbox>
                    </td>

Upvotes: 0

Views: 1082

Answers (1)

Tommi
Tommi

Reputation: 8608

Make loanPurposeCodeInfoDTO.agriculture a boolean variable, and set its values to true when the value from database is 1, and false when database value is 0.

Upvotes: 1

Related Questions