The value of Unchecked checkboxes are not passed on the request as part of submitting 
the form.
So a way to work around this is to add hide field right after your checkbox with the 
same property name and set its value to false or F...
This way if the user checks the checkbox the form will submit the checked value 
(true)...if the checkbox is not checked, then you'll get the value set on your hidden 
field (false or F)

Alberto Corona
ObjectWave Corp.

Chitta Ranjan Mishra <[EMAIL PROTECTED]> wrote ..
> Dear Sir,
>    Presently I am working on Struts project...
>    I am struggling with one problem since last 2 days
> regding html:checkbox in Struts.
> 
> My problem is while inserting data into the database
> thru a checkbox field... either check or uncheck the
> checkbox proper value is inserted into the table.
> Now in case of Updating the same field, suppose then
> check box was UNCHECKED earlier and if I CHECK it and
> try to update it ...it's also working fine.
> But the problem occurs :  when the check box was
> CHECKED earlier and I try UNCHECK it update it ...it's
> not working. After submitting the request , the value
> it's taking as the checked value(i.e. in my case if
> the checkbox is checked then 'Y' should be inserted
> and if the checkbox is unchecked then 'N' should be
> inserted) i.e 'Y'.
> 
> I read from the net that ...if a unchecked checkbox is
> submitted then the value passed is null ....so i
> should check in my action class that if it is null,
> then i should explicitely set it to 'N'.
> But in my case 'null' is not passed ...the previous
> value 'Y' is passed .
> So I reques you kindly pl ...help me what to do .
> In my jsp page I am doing like this :
> <html:checkbox name="saListStockUpdateResult"
> property="dirtAsMetalInd" styleClass="edit" value="Y"
> indexed="true" />
> 
> Here saListStockUpdateResult is a list which contains
> many values .
> Now if u say that in the <html:checkbox tag, I should
> not give like : 
> value="Y"  ....even that also i have tried....but the
> result is same....from the request it's taking the
> previously stored value.....
> Even I have used the reset() also in my Action class.
> But the result was same.
> 
> So plz help me what to do.It's very urgent...
> Thanking you,
> Regds
> C.R.Mishra
> 
> 
> 
> 
> 
> 
> ________________________________________________________________________
> Yahoo! India Matrimony: Find your partner online. 
> http://yahoo.shaadi.com/india-matrimony/
> 
> ---------------------------------------------------------------------
> 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]

Reply via email to