Checkbox problem still not fixed :(

2001-06-28 Thread Joel Vogt



Hi everyone.

I've tried just about everything in the mail 
archive but can't get check/multi boxes to perform how I want to.
I use an iterate tag over a collection, basically 
on my jsp page I have as follows

form
blah hidden name="pk" blah checkbox 
property="member" 
/form

In my form bean I have an array pk[] and another 
member[].
In the reset method I do:
for(int i = 0;imember.length;i++)
 member[i] = 
"false";

When I check the values off the form in my action 
class, i still only get the values set to true. I need a long list, true, false, 
true, true etc for all the values.

Sorry to be a pain but can someone give me some 
sort of 'exact' steps to solve the problem? I haven't been able to piece 
together all the help on the mail archive.

Thanks,
Joel
[EMAIL PROTECTED]


Re: Checkbox problem still not fixed :(

2001-06-28 Thread Linnea Ahlbeck



Hi! 
I had a similar problem and solved it by changing 
the attribute scope in my 
action in the struts-config.xml file to request 
instead of session.
/Linnéa

  - Original Message - 
  From: 
  Joel Vogt 
  
  To: [EMAIL PROTECTED] 
  Sent: Thursday, June 28, 2001 10:04 
  AM
  Subject: Checkbox problem still not fixed 
  :(
  
  Hi everyone.
  
  I've tried just about everything in the mail 
  archive but can't get check/multi boxes to perform how I want to.
  I use an iterate tag over a collection, basically 
  on my jsp page I have as follows
  
  form
  blah hidden name="pk" blah checkbox 
  property="member" 
  /form
  
  In my form bean I have an array pk[] and another 
  member[].
  In the reset method I do:
  for(int i = 
0;imember.length;i++)
   member[i] = 
  "false";
  
  When I check the values off the form in my action 
  class, i still only get the values set to true. I need a long list, true, 
  false, true, true etc for all the values.
  
  Sorry to be a pain but can someone give me some 
  sort of 'exact' steps to solve the problem? I haven't been able to piece 
  together all the help on the mail archive.
  
  Thanks,
  Joel
  [EMAIL PROTECTED]


Re: Checkbox problem still not fixed :(

2001-06-28 Thread Joel Vogt



Hi all,

I've worked on it a bit more and come up with these 
steps to make it work.

I use a multibox instead of a checkbox like this on 
my form:

html:multibox name="model" property="member" 
value="yes"/

I then also include with this a hidden 
field

html:hidden name="model" property="member" 
value="no"/

The form bean remains the same.


In my action class, I can then get the required 
values by looping like this

 int j = 
0; for (int i = 0; 
imember.length;i++) 
{ if 
(member[j].equals("yes")) 
{ // This person is a 
member so do required 
events; 
j+=1; 
} 
else// this 
person is marked to not be a member
 
j+=1; }

This works because if the multibox was checked to 
true, there will be two values for each user, a true for the multibox and then 
the no from the hidden field.
If the multibox is not checked then we only get one 
entry, a no from the hidden field.

To me this is a bit ineligant. Sure it works, 
but...

Any other solutions?

Btw Thanks to all the people offering help on this, 
it seems struts has a good community going.

Joel.


  - Original Message - 
  From: 
  Joel Vogt 
  
  To: [EMAIL PROTECTED] 
  
  Sent: Thursday, June 28, 2001 10:04 
  AM
  Subject: Checkbox problem still not fixed 
  :(
  
  Hi everyone.
  
  I've tried just about everything in the mail 
  archive but can't get check/multi boxes to perform how I want to.
  I use an iterate tag over a collection, basically 
  on my jsp page I have as follows
  
  form
  blah hidden name="pk" blah checkbox 
  property="member" 
  /form
  
  In my form bean I have an array pk[] and another 
  member[].
  In the reset method I do:
  for(int i = 
0;imember.length;i++)
   member[i] = 
  "false";
  
  When I check the values off the form in my action 
  class, i still only get the values set to true. I need a long list, true, 
  false, true, true etc for all the values.
  
  Sorry to be a pain but can someone give me some 
  sort of 'exact' steps to solve the problem? I haven't been able to piece 
  together all the help on the mail archive.
  
  Thanks,
  Joel
  [EMAIL PROTECTED]