RE: Checkbox Arrays - Internationalising them?!
Do you want bean:message to be able to get the key from a bean method? It doesn't do that now... Since is printing the value of a bean property, your bean property could use the MessageResources class to do the internationalization in your bean method. Inside an action you can get the MessageResource object and the Locale object by calling these methods from the base Action class: Locale locale = getLocale(request); MessageResources messages = getResources(); messages.getMessage(locale,"some.key",args)); where args is an optional String array. I am not sure how easy it would be for you to pass the messages and locale objects into your bean and use them there. Hal > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Friday, May 11, 2001 2:37 PM > To: [EMAIL PROTECTED] > Subject: RE: Checkbox Arrays - Internationalising them?! > > > > > Hal, > > thanks for your input on multi-box - they are working great! > > BUT...I need to get the bean:write internationalized - does > anyone know if this > is possible? > > ie I want to do a bean:message on the output from a bean:write... > > I think this qu has been asked before, but I looked through > the archives and > couldn't find it... > > Thanks, > > Dave > > > > > > "Deadman, Hal" <[EMAIL PROTECTED]> > on 05/10/2001 > 12:20:58 PM > > Please respond to [EMAIL PROTECTED] > > To: [EMAIL PROTECTED] > cc:(bcc: David Hay/Lex/Lexmark) > Subject: RE: Checkbox Arrays > > > > I posted this same response to your Posting Collections > question yesterday. > Here it is again. If you use the html:multibox, you can get > back an array of > key values instead of an array of booleans. They key values > can be Longs, > Strings, whatever, as long as it uniquely identifies the row > that you want > to know was checked. If you haven't used multibox, it > generates an html > checkbox. The array that will be set in your form will only > contain the key > values for the rows that were checked. > > Here is the post from yesterday: > > I think I am doing the same thing that you want to do using the > html:multibox. When the form is submitted you get an array of > the ids that > are checked and then you can go delete them. > > in the jsp form (where restaurant id is a key for the item > being deleted): > > ... > > > > ... > > > > in the form class: > private Long favoriteRestaurantRemoveList[] = new Long[0]; > > public Long[] getFavoriteRestaurantRemoveList() { > return (this.favoriteRestaurantRemoveList); > } > > public void setFavoriteRestaurantRemoveList(Long > favoriteRestaurantRemoveList[]) { > this.favoriteRestaurantRemoveList = > favoriteRestaurantRemoveList; > } > > I am not sure if initializing the array to new Long[0] is necessary, > probably not. > > > -Original Message- > > From: Tony Karas [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, May 10, 2001 11:52 AM > > To: Struts User > > Subject: Checkbox Arrays > > > > > > Can anyone help with this? > > > > I have an array of checkboxes in my ActionForm represented by > > > > boolean[] delete; > > > > and I have a setter function > > > > public void setDelete( boolean[] values ) > > { > >delete = values; > > } > > > > The problem is that I have only checkboxes that are checked > > get sent back - > > so if one checkbox is checked all I get is an array of length > > 1. Therefore, > > it is not possible for me to determine which checkbox has > > been checked. > > > > In the documentation it tells me to use reset() in ActionForm > > to initialise > > the values - but this will only work with single checkboxes > > and not arrays. > > > > I think I'm stuck. Is there anyway I can determine which > > checkbox has been > > checked - maybe I can get the value to differ for each > > checkbox. Will look > > in to that. > > > > Cheers > > Tony > > > > > > > >
RE: Checkbox Arrays - Internationalising them?!
Hal, thanks for your input on multi-box - they are working great! BUT...I need to get the bean:write internationalized - does anyone know if this is possible? ie I want to do a bean:message on the output from a bean:write... I think this qu has been asked before, but I looked through the archives and couldn't find it... Thanks, Dave "Deadman, Hal" <[EMAIL PROTECTED]> on 05/10/2001 12:20:58 PM Please respond to [EMAIL PROTECTED] To: [EMAIL PROTECTED] cc:(bcc: David Hay/Lex/Lexmark) Subject: RE: Checkbox Arrays I posted this same response to your Posting Collections question yesterday. Here it is again. If you use the html:multibox, you can get back an array of key values instead of an array of booleans. They key values can be Longs, Strings, whatever, as long as it uniquely identifies the row that you want to know was checked. If you haven't used multibox, it generates an html checkbox. The array that will be set in your form will only contain the key values for the rows that were checked. Here is the post from yesterday: I think I am doing the same thing that you want to do using the html:multibox. When the form is submitted you get an array of the ids that are checked and then you can go delete them. in the jsp form (where restaurant id is a key for the item being deleted): ... ... in the form class: private Long favoriteRestaurantRemoveList[] = new Long[0]; public Long[] getFavoriteRestaurantRemoveList() { return (this.favoriteRestaurantRemoveList); } public void setFavoriteRestaurantRemoveList(Long favoriteRestaurantRemoveList[]) { this.favoriteRestaurantRemoveList = favoriteRestaurantRemoveList; } I am not sure if initializing the array to new Long[0] is necessary, probably not. > -Original Message- > From: Tony Karas [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 10, 2001 11:52 AM > To: Struts User > Subject: Checkbox Arrays > > > Can anyone help with this? > > I have an array of checkboxes in my ActionForm represented by > > boolean[] delete; > > and I have a setter function > > public void setDelete( boolean[] values ) > { >delete = values; > } > > The problem is that I have only checkboxes that are checked > get sent back - > so if one checkbox is checked all I get is an array of length > 1. Therefore, > it is not possible for me to determine which checkbox has > been checked. > > In the documentation it tells me to use reset() in ActionForm > to initialise > the values - but this will only work with single checkboxes > and not arrays. > > I think I'm stuck. Is there anyway I can determine which > checkbox has been > checked - maybe I can get the value to differ for each > checkbox. Will look > in to that. > > Cheers > Tony >
RE: Checkbox Arrays
I am amazed (and pleased) at your perseverance :-) >From: "Deadman, Hal" <[EMAIL PROTECTED]> >Reply-To: [EMAIL PROTECTED] >To: [EMAIL PROTECTED] >Subject: RE: Checkbox Arrays >Date: Thu, 10 May 2001 13:35:12 -0400 > >Don't use the html:checkbox, use html:multibox and use bean:write in the >body of the tag. An html:multibox resolves to an HTML checkbox. > >Hal > > > -Original Message- > > From: Tony Karas [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, May 10, 2001 12:44 PM > > To: [EMAIL PROTECTED] > > Subject: Re: Checkbox Arrays > > > > > > Yeah - I'm looking at that. My problem now is how to get the > > value for each > > checkbox. My bean has an "id" property - so I have tried > > this kind of > > thing: > > > > > > > > > value=" > name="retailer" property="id"/>"/> > > > > > > > > > > > > But it doesn't like having the bean:write embedded there. Am > > I missing > > something obvious? > > > > Many thanks > > Tony > > > > > > > > >From: Peter Alfors <[EMAIL PROTECTED]> > > >Reply-To: [EMAIL PROTECTED] > > >To: [EMAIL PROTECTED] > > >Subject: Re: Checkbox Arrays > > >Date: Thu, 10 May 2001 11:09:18 -0500 > > > > > >Im not sure how the ActionForm changes things, but without > > an actionform > > >your > > >could do this > > > > > >Each checkbox can have the same name, but a different value. > > >When the form is submitted, the checkboxes that have been > > checked are in > > >the > > >request. > > >You can use the request.getParameterValues("checkBoxName") > > to retrieve a > > >string > > >array of the values for the checked boxes. > > > > > >HTH, > > > Pete > > > > > >Tony Karas wrote: > > > > > > > Can anyone help with this? > > > > > > > > I have an array of checkboxes in my ActionForm represented by > > > > > > > > boolean[] delete; > > > > > > > > and I have a setter function > > > > > > > > public void setDelete( boolean[] values ) > > > > { > > > > delete = values; > > > > } > > > > > > > > The problem is that I have only checkboxes that are > > checked get sent > > >back - > > > > so if one checkbox is checked all I get is an array of length 1. > > >Therefore, > > > > it is not possible for me to determine which checkbox has > > been checked. > > > > > > > > In the documentation it tells me to use reset() in ActionForm to > > >initialise > > > > the values - but this will only work with single > > checkboxes and not > > >arrays. > > > > > > > > I think I'm stuck. Is there anyway I can determine which > > checkbox has > > >been > > > > checked - maybe I can get the value to differ for each > > checkbox. Will > > >look > > > > in to that. > > > > > > > > Cheers > > > > Tony > > ><< peter.alfors.vcf >> > > > > __ > > ___ > > Get Your Private, Free E-mail from MSN Hotmail at >http://www.hotmail.com. _ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
RE: Checkbox Arrays
Ah sorry Hal - thanks for your perseverance - I was assuming, mistakenly, that multibox was something else. I'll take a look at this - cheers. Tony >From: "Deadman, Hal" <[EMAIL PROTECTED]> >Reply-To: [EMAIL PROTECTED] >To: [EMAIL PROTECTED] >Subject: RE: Checkbox Arrays >Date: Thu, 10 May 2001 12:20:58 -0400 > >I posted this same response to your Posting Collections question yesterday. >Here it is again. If you use the html:multibox, you can get back an array >of >key values instead of an array of booleans. They key values can be Longs, >Strings, whatever, as long as it uniquely identifies the row that you want >to know was checked. If you haven't used multibox, it generates an html >checkbox. The array that will be set in your form will only contain the key >values for the rows that were checked. > >Here is the post from yesterday: > >I think I am doing the same thing that you want to do using the >html:multibox. When the form is submitted you get an array of the ids that >are checked and then you can go delete them. > >in the jsp form (where restaurant id is a key for the item being deleted): > >... > > > >... > > > >in the form class: > private Long favoriteRestaurantRemoveList[] = new Long[0]; > > public Long[] getFavoriteRestaurantRemoveList() { > return (this.favoriteRestaurantRemoveList); > } > > public void setFavoriteRestaurantRemoveList(Long >favoriteRestaurantRemoveList[]) { > this.favoriteRestaurantRemoveList = favoriteRestaurantRemoveList; > } > >I am not sure if initializing the array to new Long[0] is necessary, >probably not. > > > -Original Message- > > From: Tony Karas [mailto:[EMAIL PROTECTED]] > > Sent: Thursday, May 10, 2001 11:52 AM > > To: Struts User > > Subject: Checkbox Arrays > > > > > > Can anyone help with this? > > > > I have an array of checkboxes in my ActionForm represented by > > > > boolean[] delete; > > > > and I have a setter function > > > > public void setDelete( boolean[] values ) > > { > > delete = values; > > } > > > > The problem is that I have only checkboxes that are checked > > get sent back - > > so if one checkbox is checked all I get is an array of length > > 1. Therefore, > > it is not possible for me to determine which checkbox has > > been checked. > > > > In the documentation it tells me to use reset() in ActionForm > > to initialise > > the values - but this will only work with single checkboxes > > and not arrays. > > > > I think I'm stuck. Is there anyway I can determine which > > checkbox has been > > checked - maybe I can get the value to differ for each > > checkbox. Will look > > in to that. > > > > Cheers > > Tony > > _ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
RE: Checkbox Arrays
yes please,, please share -Original Message- From: Jeff Trent [mailto:[EMAIL PROTECTED]] Sent: Thursday, May 10, 2001 9:44 PM To: [EMAIL PROTECTED] Subject: Re: Checkbox Arrays I don't know if this is the right thread. But I just got multibox working in my app (including preservation of checkbox entries between forwards). Let me share with you what I have to see if this helps: in Jsp: (cleanSolutionAreaTypes in an Application-scoped Vector) Solutions Area* in Form: protected String[] solutionAreaTypes = new String[0]; public String[] getSolutionAreaTypes() { return solutionAreaTypes; } public void setSolutionAreaTypes(String[] solutionAreaTypes) { this.solutionAreaTypes = solutionAreaTypes; } What was causing me some exceptions was this. I originally used another application-scoped vector called "solutionAreaTypes" for other purposes (like drop-down lists). That Vector contains an entry that has a null ID value (eg. name = "--specify--" value=""). This was causing Struts to throw a non-intuitive exception. I then created another Vector without this entry in it and everything seems to work fine now. Of course I've only gotten it to work about 15 minutes ago so I'll let you know later if it really works ;-) - jeff - Original Message - From: "Peter Alfors" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 10, 2001 2:01 PM Subject: Re: Checkbox Arrays > Try pulling the bean value out into a script variable. > Taglibs cannot be nested within another taglib as an attribute. > > > Tony Karas wrote: > > > Yeah - I'm looking at that. My problem now is how to get the value for each > > checkbox. My bean has an "id" property - so I have tried this kind of > > thing: > > > > > > > > "/> > > > > > > > > > > > > But it doesn't like having the bean:write embedded there. Am I missing > > something obvious? > > > > Many thanks > > Tony > > > > >From: Peter Alfors <[EMAIL PROTECTED]> > > >Reply-To: [EMAIL PROTECTED] > > >To: [EMAIL PROTECTED] > > >Subject: Re: Checkbox Arrays > > >Date: Thu, 10 May 2001 11:09:18 -0500 > > > > > >Im not sure how the ActionForm changes things, but without an actionform > > >your > > >could do this > > > > > >Each checkbox can have the same name, but a different value. > > >When the form is submitted, the checkboxes that have been checked are in > > >the > > >request. > > >You can use the request.getParameterValues("checkBoxName") to retrieve a > > >string > > >array of the values for the checked boxes. > > > > > >HTH, > > > Pete > > > > > >Tony Karas wrote: > > > > > > > Can anyone help with this? > > > > > > > > I have an array of checkboxes in my ActionForm represented by > > > > > > > > boolean[] delete; > > > > > > > > and I have a setter function > > > > > > > > public void setDelete( boolean[] values ) > > > > { > > > > delete = values; > > > > } > > > > > > > > The problem is that I have only checkboxes that are checked get sent > > >back - > > > > so if one checkbox is checked all I get is an array of length 1. > > >Therefore, > > > > it is not possible for me to determine which checkbox has been checked. > > > > > > > > In the documentation it tells me to use reset() in ActionForm to > > >initialise > > > > the values - but this will only work with single checkboxes and not > > >arrays. > > > > > > > > I think I'm stuck. Is there anyway I can determine which checkbox has > > >been > > > > checked - maybe I can get the value to differ for each checkbox. Will > > >look > > > > in to that. > > > > > > > > Cheers > > > > Tony > > ><< peter.alfors.vcf >> > > > > _ > > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. >
Re: Checkbox Arrays
I don't know if this is the right thread. But I just got multibox working in my app (including preservation of checkbox entries between forwards). Let me share with you what I have to see if this helps: in Jsp: (cleanSolutionAreaTypes in an Application-scoped Vector) Solutions Area* in Form: protected String[] solutionAreaTypes = new String[0]; public String[] getSolutionAreaTypes() { return solutionAreaTypes; } public void setSolutionAreaTypes(String[] solutionAreaTypes) { this.solutionAreaTypes = solutionAreaTypes; } What was causing me some exceptions was this. I originally used another application-scoped vector called "solutionAreaTypes" for other purposes (like drop-down lists). That Vector contains an entry that has a null ID value (eg. name = "--specify--" value=""). This was causing Struts to throw a non-intuitive exception. I then created another Vector without this entry in it and everything seems to work fine now. Of course I've only gotten it to work about 15 minutes ago so I'll let you know later if it really works ;-) - jeff - Original Message - From: "Peter Alfors" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 10, 2001 2:01 PM Subject: Re: Checkbox Arrays > Try pulling the bean value out into a script variable. > Taglibs cannot be nested within another taglib as an attribute. > > > Tony Karas wrote: > > > Yeah - I'm looking at that. My problem now is how to get the value for each > > checkbox. My bean has an "id" property - so I have tried this kind of > > thing: > > > > > > > > "/> > > > > > > > > > > > > But it doesn't like having the bean:write embedded there. Am I missing > > something obvious? > > > > Many thanks > > Tony > > > > >From: Peter Alfors <[EMAIL PROTECTED]> > > >Reply-To: [EMAIL PROTECTED] > > >To: [EMAIL PROTECTED] > > >Subject: Re: Checkbox Arrays > > >Date: Thu, 10 May 2001 11:09:18 -0500 > > > > > >Im not sure how the ActionForm changes things, but without an actionform > > >your > > >could do this > > > > > >Each checkbox can have the same name, but a different value. > > >When the form is submitted, the checkboxes that have been checked are in > > >the > > >request. > > >You can use the request.getParameterValues("checkBoxName") to retrieve a > > >string > > >array of the values for the checked boxes. > > > > > >HTH, > > > Pete > > > > > >Tony Karas wrote: > > > > > > > Can anyone help with this? > > > > > > > > I have an array of checkboxes in my ActionForm represented by > > > > > > > > boolean[] delete; > > > > > > > > and I have a setter function > > > > > > > > public void setDelete( boolean[] values ) > > > > { > > > > delete = values; > > > > } > > > > > > > > The problem is that I have only checkboxes that are checked get sent > > >back - > > > > so if one checkbox is checked all I get is an array of length 1. > > >Therefore, > > > > it is not possible for me to determine which checkbox has been checked. > > > > > > > > In the documentation it tells me to use reset() in ActionForm to > > >initialise > > > > the values - but this will only work with single checkboxes and not > > >arrays. > > > > > > > > I think I'm stuck. Is there anyway I can determine which checkbox has > > >been > > > > checked - maybe I can get the value to differ for each checkbox. Will > > >look > > > > in to that. > > > > > > > > Cheers > > > > Tony > > ><< peter.alfors.vcf >> > > > > _ > > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. >
Re: Checkbox Arrays
Try pulling the bean value out into a script variable. Taglibs cannot be nested within another taglib as an attribute. Tony Karas wrote: > Yeah - I'm looking at that. My problem now is how to get the value for each > checkbox. My bean has an "id" property - so I have tried this kind of > thing: > > > > "/> > > > > > > But it doesn't like having the bean:write embedded there. Am I missing > something obvious? > > Many thanks > Tony > > >From: Peter Alfors <[EMAIL PROTECTED]> > >Reply-To: [EMAIL PROTECTED] > >To: [EMAIL PROTECTED] > >Subject: Re: Checkbox Arrays > >Date: Thu, 10 May 2001 11:09:18 -0500 > > > >Im not sure how the ActionForm changes things, but without an actionform > >your > >could do this > > > >Each checkbox can have the same name, but a different value. > >When the form is submitted, the checkboxes that have been checked are in > >the > >request. > >You can use the request.getParameterValues("checkBoxName") to retrieve a > >string > >array of the values for the checked boxes. > > > >HTH, > > Pete > > > >Tony Karas wrote: > > > > > Can anyone help with this? > > > > > > I have an array of checkboxes in my ActionForm represented by > > > > > > boolean[] delete; > > > > > > and I have a setter function > > > > > > public void setDelete( boolean[] values ) > > > { > > > delete = values; > > > } > > > > > > The problem is that I have only checkboxes that are checked get sent > >back - > > > so if one checkbox is checked all I get is an array of length 1. > >Therefore, > > > it is not possible for me to determine which checkbox has been checked. > > > > > > In the documentation it tells me to use reset() in ActionForm to > >initialise > > > the values - but this will only work with single checkboxes and not > >arrays. > > > > > > I think I'm stuck. Is there anyway I can determine which checkbox has > >been > > > checked - maybe I can get the value to differ for each checkbox. Will > >look > > > in to that. > > > > > > Cheers > > > Tony > ><< peter.alfors.vcf >> > > _ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. begin:vcard n:; x-mozilla-html:FALSE org:http://www.irista.com/logo/irista.gif";>Bringing Vision to Your Supply Chain adr:;; version:2.1 end:vcard
RE: Checkbox Arrays
Don't use the html:checkbox, use html:multibox and use bean:write in the body of the tag. An html:multibox resolves to an HTML checkbox. Hal > -Original Message- > From: Tony Karas [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 10, 2001 12:44 PM > To: [EMAIL PROTECTED] > Subject: Re: Checkbox Arrays > > > Yeah - I'm looking at that. My problem now is how to get the > value for each > checkbox. My bean has an "id" property - so I have tried > this kind of > thing: > > > >value=" name="retailer" property="id"/>"/> > > > > > > But it doesn't like having the bean:write embedded there. Am > I missing > something obvious? > > Many thanks > Tony > > > > >From: Peter Alfors <[EMAIL PROTECTED]> > >Reply-To: [EMAIL PROTECTED] > >To: [EMAIL PROTECTED] > >Subject: Re: Checkbox Arrays > >Date: Thu, 10 May 2001 11:09:18 -0500 > > > >Im not sure how the ActionForm changes things, but without > an actionform > >your > >could do this > > > >Each checkbox can have the same name, but a different value. > >When the form is submitted, the checkboxes that have been > checked are in > >the > >request. > >You can use the request.getParameterValues("checkBoxName") > to retrieve a > >string > >array of the values for the checked boxes. > > > >HTH, > > Pete > > > >Tony Karas wrote: > > > > > Can anyone help with this? > > > > > > I have an array of checkboxes in my ActionForm represented by > > > > > > boolean[] delete; > > > > > > and I have a setter function > > > > > > public void setDelete( boolean[] values ) > > > { > > > delete = values; > > > } > > > > > > The problem is that I have only checkboxes that are > checked get sent > >back - > > > so if one checkbox is checked all I get is an array of length 1. > >Therefore, > > > it is not possible for me to determine which checkbox has > been checked. > > > > > > In the documentation it tells me to use reset() in ActionForm to > >initialise > > > the values - but this will only work with single > checkboxes and not > >arrays. > > > > > > I think I'm stuck. Is there anyway I can determine which > checkbox has > >been > > > checked - maybe I can get the value to differ for each > checkbox. Will > >look > > > in to that. > > > > > > Cheers > > > Tony > ><< peter.alfors.vcf >> > > __ > ___ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Re: Checkbox Arrays
the way we solved this was to create a hidden field for each checkbox that holds the value that would be sent if the checkbox were to be checked. I then compare the full value array sent by the hidden values with the partial array sent by the checkboxes to see which ones were checked and which weren't. Both of these, of course, are inside a block. HTH, - eric - Original Message - From: "Tony Karas" <[EMAIL PROTECTED]> To: "Struts User" <[EMAIL PROTECTED]> Sent: Thursday, May 10, 2001 8:52 AM Subject: Checkbox Arrays > Can anyone help with this? > > I have an array of checkboxes in my ActionForm represented by > > boolean[] delete; > > and I have a setter function > > public void setDelete( boolean[] values ) > { > delete = values; > } > > The problem is that I have only checkboxes that are checked get sent back - > so if one checkbox is checked all I get is an array of length 1. Therefore, > it is not possible for me to determine which checkbox has been checked. > > In the documentation it tells me to use reset() in ActionForm to initialise > the values - but this will only work with single checkboxes and not arrays. > > I think I'm stuck. Is there anyway I can determine which checkbox has been > checked - maybe I can get the value to differ for each checkbox. Will look > in to that. > > Cheers > Tony > >
Re: Checkbox Arrays
Yeah - I'm looking at that. My problem now is how to get the value for each checkbox. My bean has an "id" property - so I have tried this kind of thing: "/> But it doesn't like having the bean:write embedded there. Am I missing something obvious? Many thanks Tony >From: Peter Alfors <[EMAIL PROTECTED]> >Reply-To: [EMAIL PROTECTED] >To: [EMAIL PROTECTED] >Subject: Re: Checkbox Arrays >Date: Thu, 10 May 2001 11:09:18 -0500 > >Im not sure how the ActionForm changes things, but without an actionform >your >could do this > >Each checkbox can have the same name, but a different value. >When the form is submitted, the checkboxes that have been checked are in >the >request. >You can use the request.getParameterValues("checkBoxName") to retrieve a >string >array of the values for the checked boxes. > >HTH, > Pete > >Tony Karas wrote: > > > Can anyone help with this? > > > > I have an array of checkboxes in my ActionForm represented by > > > > boolean[] delete; > > > > and I have a setter function > > > > public void setDelete( boolean[] values ) > > { > > delete = values; > > } > > > > The problem is that I have only checkboxes that are checked get sent >back - > > so if one checkbox is checked all I get is an array of length 1. >Therefore, > > it is not possible for me to determine which checkbox has been checked. > > > > In the documentation it tells me to use reset() in ActionForm to >initialise > > the values - but this will only work with single checkboxes and not >arrays. > > > > I think I'm stuck. Is there anyway I can determine which checkbox has >been > > checked - maybe I can get the value to differ for each checkbox. Will >look > > in to that. > > > > Cheers > > Tony ><< peter.alfors.vcf >> _ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
RE: Checkbox Arrays
I posted this same response to your Posting Collections question yesterday. Here it is again. If you use the html:multibox, you can get back an array of key values instead of an array of booleans. They key values can be Longs, Strings, whatever, as long as it uniquely identifies the row that you want to know was checked. If you haven't used multibox, it generates an html checkbox. The array that will be set in your form will only contain the key values for the rows that were checked. Here is the post from yesterday: I think I am doing the same thing that you want to do using the html:multibox. When the form is submitted you get an array of the ids that are checked and then you can go delete them. in the jsp form (where restaurant id is a key for the item being deleted): ... ... in the form class: private Long favoriteRestaurantRemoveList[] = new Long[0]; public Long[] getFavoriteRestaurantRemoveList() { return (this.favoriteRestaurantRemoveList); } public void setFavoriteRestaurantRemoveList(Long favoriteRestaurantRemoveList[]) { this.favoriteRestaurantRemoveList = favoriteRestaurantRemoveList; } I am not sure if initializing the array to new Long[0] is necessary, probably not. > -Original Message- > From: Tony Karas [mailto:[EMAIL PROTECTED]] > Sent: Thursday, May 10, 2001 11:52 AM > To: Struts User > Subject: Checkbox Arrays > > > Can anyone help with this? > > I have an array of checkboxes in my ActionForm represented by > > boolean[] delete; > > and I have a setter function > > public void setDelete( boolean[] values ) > { > delete = values; > } > > The problem is that I have only checkboxes that are checked > get sent back - > so if one checkbox is checked all I get is an array of length > 1. Therefore, > it is not possible for me to determine which checkbox has > been checked. > > In the documentation it tells me to use reset() in ActionForm > to initialise > the values - but this will only work with single checkboxes > and not arrays. > > I think I'm stuck. Is there anyway I can determine which > checkbox has been > checked - maybe I can get the value to differ for each > checkbox. Will look > in to that. > > Cheers > Tony >
Re: Checkbox Arrays
Im not sure how the ActionForm changes things, but without an actionform your could do this Each checkbox can have the same name, but a different value. When the form is submitted, the checkboxes that have been checked are in the request. You can use the request.getParameterValues("checkBoxName") to retrieve a string array of the values for the checked boxes. HTH, Pete Tony Karas wrote: > Can anyone help with this? > > I have an array of checkboxes in my ActionForm represented by > > boolean[] delete; > > and I have a setter function > > public void setDelete( boolean[] values ) > { > delete = values; > } > > The problem is that I have only checkboxes that are checked get sent back - > so if one checkbox is checked all I get is an array of length 1. Therefore, > it is not possible for me to determine which checkbox has been checked. > > In the documentation it tells me to use reset() in ActionForm to initialise > the values - but this will only work with single checkboxes and not arrays. > > I think I'm stuck. Is there anyway I can determine which checkbox has been > checked - maybe I can get the value to differ for each checkbox. Will look > in to that. > > Cheers > Tony begin:vcard n:; x-mozilla-html:FALSE org:http://www.irista.com/logo/irista.gif";>Bringing Vision to Your Supply Chain adr:;; version:2.1 end:vcard
Checkbox Arrays
Can anyone help with this? I have an array of checkboxes in my ActionForm represented by boolean[] delete; and I have a setter function public void setDelete( boolean[] values ) { delete = values; } The problem is that I have only checkboxes that are checked get sent back - so if one checkbox is checked all I get is an array of length 1. Therefore, it is not possible for me to determine which checkbox has been checked. In the documentation it tells me to use reset() in ActionForm to initialise the values - but this will only work with single checkboxes and not arrays. I think I'm stuck. Is there anyway I can determine which checkbox has been checked - maybe I can get the value to differ for each checkbox. Will look in to that. Cheers Tony