You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Paul Jackson <pa...@meridianinfo.com> on 2001/03/14 01:00:53 UTC

Checkboxs in a list

Does anyone of the best approach for the following situation?

I wish to have a list of files for processing with a checkbox on the left
hand side of each file to indicate if the file should be processed or not.
I'm looking at how to do this in a single form with a <logic:iterator> tag
to list the files. 

If I use the <html:checkbox> tag the problem is that the names on the
checkboxes are all the same and I can't distinguish between them.

Any ideas?



Paul Jackson
Meridian Informatics
Sydney, Australia

Ph 8233 7564
Fax 8233 7533



RE: Checkboxs in a list

Posted by Palamadai Sriram <pa...@s1.com>.
Thats the correct solution or at least one correct solution.I implemented
with text fields and here is a sample line of code
String[]  amount = (String[])request.getParameterValues("amount");
Name all your checkBoxes as "xx" ("amount" in my case)and get it back in
your action class like above.


-----Original Message-----
From: Martin Cooper [mailto:martin.cooper@tumbleweed.com]
Sent: Tuesday, March 13, 2001 11:59 PM
To: struts-user@jakarta.apache.org
Cc: struts-dev@jakarta.apache.org
Subject: Re: Checkboxs in a list


You can do this with the <html:multibox> tag.

- Use the same 'name' attribute for each checkbox.
- Use a different 'value' attribute for each checkbox (probably obtained
from your iterator).
- Define the corresponding bean property as type String[].

When the form is submitted, your property setter will be called with a
String array containing all of the values for the checkboxes which were
checked.

Hope this helps.

--
Martin Cooper


----- Original Message -----
From: "Paul Jackson" <pa...@meridianinfo.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, March 13, 2001 4:00 PM
Subject: Checkboxs in a list


> Does anyone of the best approach for the following situation?
>
> I wish to have a list of files for processing with a checkbox on the left
> hand side of each file to indicate if the file should be processed or not.
> I'm looking at how to do this in a single form with a <logic:iterator> tag
> to list the files.
>
> If I use the <html:checkbox> tag the problem is that the names on the
> checkboxes are all the same and I can't distinguish between them.
>
> Any ideas?
>
>
>
> Paul Jackson
> Meridian Informatics
> Sydney, Australia
>
> Ph 8233 7564
> Fax 8233 7533
>
>



Re: Checkboxs in a list

Posted by Martin Cooper <ma...@tumbleweed.com>.
You can do this with the <html:multibox> tag.

- Use the same 'name' attribute for each checkbox.
- Use a different 'value' attribute for each checkbox (probably obtained
from your iterator).
- Define the corresponding bean property as type String[].

When the form is submitted, your property setter will be called with a
String array containing all of the values for the checkboxes which were
checked.

Hope this helps.

--
Martin Cooper


----- Original Message -----
From: "Paul Jackson" <pa...@meridianinfo.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, March 13, 2001 4:00 PM
Subject: Checkboxs in a list


> Does anyone of the best approach for the following situation?
>
> I wish to have a list of files for processing with a checkbox on the left
> hand side of each file to indicate if the file should be processed or not.
> I'm looking at how to do this in a single form with a <logic:iterator> tag
> to list the files.
>
> If I use the <html:checkbox> tag the problem is that the names on the
> checkboxes are all the same and I can't distinguish between them.
>
> Any ideas?
>
>
>
> Paul Jackson
> Meridian Informatics
> Sydney, Australia
>
> Ph 8233 7564
> Fax 8233 7533
>
>



Re: Checkboxs in a list

Posted by Martin Cooper <ma...@tumbleweed.com>.
You can do this with the <html:multibox> tag.

- Use the same 'name' attribute for each checkbox.
- Use a different 'value' attribute for each checkbox (probably obtained
from your iterator).
- Define the corresponding bean property as type String[].

When the form is submitted, your property setter will be called with a
String array containing all of the values for the checkboxes which were
checked.

Hope this helps.

--
Martin Cooper


----- Original Message -----
From: "Paul Jackson" <pa...@meridianinfo.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, March 13, 2001 4:00 PM
Subject: Checkboxs in a list


> Does anyone of the best approach for the following situation?
>
> I wish to have a list of files for processing with a checkbox on the left
> hand side of each file to indicate if the file should be processed or not.
> I'm looking at how to do this in a single form with a <logic:iterator> tag
> to list the files.
>
> If I use the <html:checkbox> tag the problem is that the names on the
> checkboxes are all the same and I can't distinguish between them.
>
> Any ideas?
>
>
>
> Paul Jackson
> Meridian Informatics
> Sydney, Australia
>
> Ph 8233 7564
> Fax 8233 7533
>
>



Re: Checkboxs in a list

Posted by Nick Pellow <ni...@cortexebusiness.com.au>.

Paul Jackson wrote:
> 
> Does anyone of the best approach for the following situation?
> 
> I wish to have a list of files for processing with a checkbox on the left
> hand side of each file to indicate if the file should be processed or not.
> I'm looking at how to do this in a single form with a <logic:iterator> tag
> to list the files.
> 
> If I use the <html:checkbox> tag the problem is that the names on the
> checkboxes are all the same and I can't distinguish between them.
> 
> Any ideas?

Paul, 
I have ideas on how to solve this and have indeed done so for the
html:text tag.
It would be very easy for me to do the same for checkboxes.
I implemented my proposal as suggested on the dev list with the subject
BaseFieldTag. It seems to work fine. I am not sure though if it is the
ideal
solution but would not mind getting some feedback on it. 
Michael Westbay seemed to like it.

All that happens is the output of the actual hmtl is delayed until
the doAfterBody method. this allows you to configure the tag at runtime
using nested elements. It blows out the taglibs in the Jsp but it still
better than having any java code there. At the moment it does not
automagically 
repopulate either, however this could be achieved.


Nick


 Informatics
> Sydney, Australia
> 
> Ph 8233 7564
> Fax 8233 7533

Re: Checkboxs in a list

Posted by Vinicios Torres <vt...@netpar.com.br>.
Im studying Struts yet, but I do this as follow:

<input type="checkbox" name="file" value="file1.ext">
<input type="checkbox" name="file" value="file2.ext">
<input type="checkbox" name="file" value="file3.ext">

To process all files marked (the files not marked doesnt appear:

String[] files = request.getParameterValues("file");
if (files != null) {
   for (int x = 0; x < files.length; x++) {
        ***** process files[x];
   }
}


Is there another way more easily?
Is possible do the same thing with tag <html:checkbox> ?



Vinicios Torres
ICHTUS Webmaster
vinicios@ICHTUS.com.br
http://www.ICHTUS.com.br

----- Original Message ----- 
From: "Paul Jackson" <pa...@meridianinfo.com>
To: <st...@jakarta.apache.org>
Sent: Tuesday, March 13, 2001 9:00 PM
Subject: Checkboxs in a list


> Does anyone of the best approach for the following situation?
> 
> I wish to have a list of files for processing with a checkbox on the left
> hand side of each file to indicate if the file should be processed or not.
> I'm looking at how to do this in a single form with a <logic:iterator> tag
> to list the files. 
> 
> If I use the <html:checkbox> tag the problem is that the names on the
> checkboxes are all the same and I can't distinguish between them.
> 
> Any ideas?
> 
> 
> 
> Paul Jackson
> Meridian Informatics
> Sydney, Australia
> 
> Ph 8233 7564
> Fax 8233 7533
> 
>