Why are you only using the checkbox tag in the "add record" page? Can't you
just set the ActionForm property and use it in the edit page also?
Dave
--- On Tue, 11/25/08, David Barron <[EMAIL PROTECTED]> wrote:
> I'm sure this has been asked before but I haven't had any luck finding
> the answer. I'm having trouble getting the checkbox to work.
>
> My web application uses a database and I have screens that
> add and edit records. One of the fields is a boolean called
> isPermanent. So my ActionForm has a boolean field called
> isPermanent.
>
> public class DataSetForm extends ActionForm {
> private boolean isPermanent;
> public setIsPermanent(boolean b) {
> isPermanent = b;
> }
> public getIsPermanent() {
> return isPermanent;
> }
> etc.
>
> In my addRecord.jsp I've got my form setup and it
> includes this:
> <html:checkbox property="isPermanent"/>
>
> And my Action has this:
> PreparedStatement stmt =
> connection.prepareStatement("insert into blah
> blah isPermanent=?");
> stmt.setBoolean(1, form.getIsPermanent());
> stmt.execute();
>
> All this works great. My question is with the
> editRecord.jsp. I'm
> pulling the record out of the data based on the key field,
> but when I
> display the checkbox how to if set it to checked based on
> the value in
> the data table?
>
> Right now I'm doing something like this (greatly
> abbreviated)
>
> <%
> ResultSet rs = stmt.executeQuery("select
> etc");
> if(rs.next()) {
> boolean isPermanent =
> rs.getBoolean("isPermanent");
> }
> %>
>
> Then further down I do this
>
> <%
> if(isPermanent) {
> %>
> <input type="checkbox"
> name="isPermanent" checked>
> <%
> }
> else {
> %>
> <input type="checkbox"
> name="isPermanent">
> <%
> }
> %>
>
> When I first started working with the checkbox I expected
> it to have a
> value= option the way the other components do, but it
> doesn't appear to
> work the way the other components work. Or am I missing
> something?
>
> Thanks
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]