well, blow me - managed to sort my own problem for a change.

Removed the 'value="Y"' from my checkbox definition, defined the attribute
as a boolean within the formBean and the little fella now works like a
charm.

Apologies to Ted for saying there were no examples around, I have now
checked the Artimus example on his website!

regards,
steve

__________________________________ 


-----Original Message-----
From: Steve Earl [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 22, 2002 9:24 AM
To: 'Struts Users Mailing List' (E-mail)
Subject: Retaining checkbox state on redisplay


Hi guys,

As usual with my questions this has probably been done to death but I still
haven't grasped it!! 

Can someone tell me the 'best practice' method of defining checkbox elements
to allow them to be re-populated with the user selected state
when a page is redisplayed.

I currently have a checkbox contained within my jsp which has the following
setup:

<snip>
<html:checkbox property="direct" value="Y" />
<snip>

within my formbean for this page I have direct defined as a string, not a
boolean and set it as follows:
<snip>
public void setDirect(String direct) {
 this.direct = direct;
}
<snip>

The action class then examines the state of the direct attribute within the
formBean and if it's set to "Y" it does some work.

My problem is that on the redisplay of the page the checkbox is shown as
unchecked i.e. it reverts to its original state.

I read some messages on the archive suggesting that the formBean needed to
set the value of direct from within a reset() method
but didn't quite figure out whether that means that direct should be defined
as a boolean or not. Also had a look at most of the 
examples on the struts homepage and couldn't find any which included
checkboxes.

All a bit confused really....a normal Friday feeling..

tia
steve


--
To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to