RE: Checkboxes inside a list
Was that for all the checkboxes - or just the ones that were not ticked? Can you show us a snippet of the actionform and the generated html? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, 9 February 2004 16:55 To: [EMAIL PROTECTED] Subject: Checkboxes inside a list Hi, Is it possible to have checkboxes inside a list? I tried this and the table in the JSP was rendered fine and the getters of the list elements were called correctly. However, after pressing submit the setters were not called, and thus the checkbox values were not transmitted into the bean. --markus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkboxes inside a list
Use html:multibox instead of checkbox andd place it in a logi:iterate Nafise -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, February 09, 2004 12:25 PM To: [EMAIL PROTECTED] Subject: Checkboxes inside a list Hi, Is it possible to have checkboxes inside a list? I tried this and the table in the JSP was rendered fine and the getters of the list elements were called correctly. However, after pressing submit the setters were not called, and thus the checkbox values were not transmitted into the bean. --markus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkboxes inside a list
Hi, According to my log printings the setter for the checkbox boolean was never called even if there was checked checkboxes. Is this caused by the fact that the setter for the boolean is embedded inside the list and the setter in the actionform just sets the list? Should the actionform setter do something else? At least now the actionform setter is not called. It is kind of logical actually, the framework should reach into the list and call the correct setter for each item. Obviously a setter that sets the list itself does not help at all. It was just that without really thinking about it writing symmetrical getter and setter seemed logical. Now it feels quite stupid indeed. I should have read that book further... :-) Well, after few trials with different setters I managed to find out that while you can get a boolean array, it only reports the checkboxes that are checked, and is thus useless without position info. I am almost sure that the 'indexed' parameter of the 'html:checkbox' tag would enable position info. However, I am unable to figure out what signature the corresponding setter should have. I have several, and none of them is called... Is there some document that would enlighten me, or could you please help? I would not like to try to look it up from the sources... Another option would be to use 'multibox' tag instead, as suggested by a person. I think the ActionForm contents are not relevant now, only the proper signature for the setter matters. JSP itself seems to be working perfectly. It generates HTML there checkboxes are differentiated by name, as it should be in HTML. I could always rip the information straight from the request, but I would rather use a setter and the form instead. Sorry about rambling at the beginning, at least you can view my not so impressive learning process. :-) tr td align=center input type=checkbox name=ti[0].remove value=on /td tr td align=center input type=checkbox name=ti[1].remove value=on /td --markus -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED] Sent: 09 February 2004 10:59 To: Struts Users Mailing List Subject: RE: Checkboxes inside a list Was that for all the checkboxes - or just the ones that were not ticked? Can you show us a snippet of the actionform and the generated html? -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, 9 February 2004 16:55 To: [EMAIL PROTECTED] Subject: Checkboxes inside a list Hi, Is it possible to have checkboxes inside a list? I tried this and the table in the JSP was rendered fine and the getters of the list elements were called correctly. However, after pressing submit the setters were not called, and thus the checkbox values were not transmitted into the bean. --markus - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkboxes with session-scoped DynaActionForms
If your fields are currently Strings, just put field = new String[0]; in your reset() method. You don't need to change it to a [Bb]oolean. This advice should work for any type. B -Original Message- From: Sgarlata Matt [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 12:48 PM To: Struts Users Mailing List Subject: Checkboxes with session-scoped DynaActionForms Does anyone know a good reference on how to use checkboxes with session-scoped DynaActionForms? The problem I am running into is that when the form bean is session scoped, the checkbox sticks to always being checked even if the user unchecks the checkbox. This makes some sense to me, because I know that if the checkbox is unchecked then a value for the checkbox is not passed along in the request, so the old value is kept. I think with ActionForms this is solved by making the underlying property of the checkbox of type boolean and by setting the value of the checkbox to false in the reset() method of the ActionForm. So, what is the correct setup with DynaActionForms? Should I make my underlying form property of type java.lang.Boolean? Also, It looks like I am going to have to subclass DynaActionForm or DynaValidatorForm so that I can reset the checkboxes in the reset() method of the form bean. That seems like quite a pain (kind of defeats the purpose of Dyna forms, doesn't it?). Is that correct? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkboxes with session-scoped DynaActionForms
From: Sgarlata Matt [mailto:[EMAIL PROTECTED] Also, It looks like I am going to have to subclass DynaActionForm or DynaValidatorForm so that I can reset the checkboxes in the reset() method of the form bean. That seems like quite a pain (kind of defeats the purpose of Dyna forms, doesn't it?). Dyna forms merely free you of the need to write all those get/set methods. Defining the properties in struts-config.xml does not mean you can't or shouldn't override the 'reset' and/or 'validate' methods. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checkboxes with session-scoped DynaActionForms
Wendy Barrett - Thanks for your help! Both of your answers helped me fix the problem I was having with checkboxes and session-scoped DynaActionForms. Wendy - I feel like the reset method of the DynaActionForm should be able to automatically take care of checkboxes, perhaps with a little extra help like specifying clearOnReset=true or isCheckbox=true in the set-property element for the property, but oh well... I'm not going to push it on the dev list. Matt - Original Message - From: Wendy Smoak [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 3:03 PM Subject: RE: Checkboxes with session-scoped DynaActionForms From: Sgarlata Matt [mailto:[EMAIL PROTECTED] Also, It looks like I am going to have to subclass DynaActionForm or DynaValidatorForm so that I can reset the checkboxes in the reset() method of the form bean. That seems like quite a pain (kind of defeats the purpose of Dyna forms, doesn't it?). Dyna forms merely free you of the need to write all those get/set methods. Defining the properties in struts-config.xml does not mean you can't or shouldn't override the 'reset' and/or 'validate' methods. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - 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]
RE: Checkboxes with session-scoped DynaActionForms
I think there is a common misconception that if you use DynaActionForms you don't need to write an ActionForm AT ALL. While this is true, you may also subclass the DynaForm and provide a similar level of functionality as a normal form. Kmart Tech News news://uskihsvtfinsys The essence of knowledge is, having it, to apply it; not having it, to confess your ignorance. -Original Message- From: Sgarlata Matt [mailto:[EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 4:47 PM To: Struts Users Mailing List Subject: Re: Checkboxes with session-scoped DynaActionForms Wendy Barrett - Thanks for your help! Both of your answers helped me fix the problem I was having with checkboxes and session-scoped DynaActionForms. Wendy - I feel like the reset method of the DynaActionForm should be able to automatically take care of checkboxes, perhaps with a little extra help like specifying clearOnReset=true or isCheckbox=true in the set-property element for the property, but oh well... I'm not going to push it on the dev list. Matt - Original Message - From: Wendy Smoak [EMAIL PROTECTED] To: Struts Users Mailing List [EMAIL PROTECTED] Sent: Wednesday, December 17, 2003 3:03 PM Subject: RE: Checkboxes with session-scoped DynaActionForms From: Sgarlata Matt [mailto:[EMAIL PROTECTED] Also, It looks like I am going to have to subclass DynaActionForm or DynaValidatorForm so that I can reset the checkboxes in the reset() method of the form bean. That seems like quite a pain (kind of defeats the purpose of Dyna forms, doesn't it?). Dyna forms merely free you of the need to write all those get/set methods. Defining the properties in struts-config.xml does not mean you can't or shouldn't override the 'reset' and/or 'validate' methods. -- Wendy Smoak Application Systems Analyst, Sr. ASU IA Information Resources Management - 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] - This message and its contents (to include attachments) are the property of Kmart Corporation (Kmart) and may contain confidential and proprietary information. You are hereby notified that any disclosure, copying, or distribution of this message, or the taking of any action based on information contained herein is strictly prohibited. Unauthorized use of information contained herein may subject you to civil and criminal prosecution and penalties. If you are not the intended recipient, you should delete this message immediately. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Checkboxes
Filip wrote: I have a list of 71 Checkboxes and want to have one checkbox to select all of them at once. This works fine but I cannot uncheck this checkbox if it was checked once in order to uncheck all other checkboxes. How are you 'checking' them all? JavaScript or do you require a round trip to the server? If the latter, you should be able to unset the properties in the ActionForm before you forward back to the view. With JavaScript, an onClick on the controller checkbox and run through all the others to uncheck them. Can you post the code that's working, it shouldn't be too hard to modify to make them 'uncheck' if you've got the 'check' part working. -- Wendy Smoak Applications Systems Analyst, Sr. Arizona State University, PA, IRM
RE: Checkboxes
Atachments don't make it through the list, Mike. Best bet would be to make your file available on a publicly accessible website and post the link, or if it's small enough, post the text in the body of your message. Steve -Original Message- From: Mike Jasnowski [mailto:[EMAIL PROTECTED] Sent: August 25, 2003 12:25 PM To: Struts Users Mailing List Subject: RE: Checkboxes The attached JSP may help you, I posted it a couple weeks ago to help solve a similar problem. HTH, mike jasnowski -Original Message- From: Filip Polsakiewicz [mailto:[EMAIL PROTECTED] Sent: Monday, August 25, 2003 4:58 AM To: Struts Users Mailinglist Subject: Checkboxes Hi, I have the following problem: I have a list of 71 Checkboxes and want to have one checkbox to select all of them at once. This works fine but I cannot uncheck this checkbox if it was checked once in order to uncheck all other checkboxes. Can anybody help me on this. Any code samples would be very helpful. Thanks in advance, Filip - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checkboxes
Hi Filip See example on the really cool page of Matt Kruse: http://www.mattkruse.com/javascript/checkboxgroup/ Koni Filip Polsakiewicz wrote: Hi, I have the following problem: I have a list of 71 Checkboxes and want to have one checkbox to select all of them at once. This works fine but I cannot uncheck this checkbox if it was checked once in order to uncheck all other checkboxes. Can anybody help me on this. Any code samples would be very helpful. Thanks in advance, Filip - 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]
RE: Checkboxes
The attached JSP may help you, I posted it a couple weeks ago to help solve a similar problem. HTH, mike jasnowski -Original Message- From: Filip Polsakiewicz [mailto:[EMAIL PROTECTED] Sent: Monday, August 25, 2003 4:58 AM To: Struts Users Mailinglist Subject: Checkboxes Hi, I have the following problem: I have a list of 71 Checkboxes and want to have one checkbox to select all of them at once. This works fine but I cannot uncheck this checkbox if it was checked once in order to uncheck all other checkboxes. Can anybody help me on this. Any code samples would be very helpful. Thanks in advance, Filip - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: checkboxes - ActionForm in session scope
If you need this to work the way you are describing, I would use a hidden field (that matches your form) valued at either 'true' or 'false' and use javascript to link up a checkbox to 1) set the checkbox initial value; 2) toggle the hidden field when the checkbox is toggled; and 3) loose the reset. If you use boolean getters and setters you don't have to worry about coding in the words true and false on the java side. Edgar -Original Message- From: Andrew Hill [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 15, 2003 10:35 PM To: 'Struts Users Mailing List' Subject: RE: checkboxes - ActionForm in session scope snip I call reset method selectively since I am trying to develope wizard style pages with one form. /snip Ah, but if you dont reset the checkbox it will always stay ticked - as nothing (not even an empty string!) is submitted for an unticked checkbox so the forms setter method is never called. THIS is the real reason the reset() method even exists in the first place - its a workaround for this flaw in the html spec. Other fields that need to be reset include multiple-select boxes and textareas. Empty input fields will submit an empty string so they dont need to be reset, and single selects always have something selected so dont need it either. If your doing wizards you should still call reset() but you do the selective stuff inside the code for the reset() method (such that it resets only those fields that were visible on the page just submitted). -Original Message- From: Khalid K. [mailto:[EMAIL PROTECTED] Sent: Wednesday, 16 July 2003 01:54 To: Struts Users Mailing List Subject: checkboxes - ActionForm in session scope Hello All, I have the following problem, and any help is greatly appreciated: 1. html form that has a checkbox which is associated with a Action Form Bean - boolean attribute 2. ActionForm is in session scope 3. I call reset method selectively since I am trying to develope wizard style pages with one form. 4. using struts 1.0.2 problem: When I check a checkbox and submit the form, on the pending page, I see the value as set to true which is OK. Now, When I click on modify which takes me to the html with the form, and I uncheck the checkbox and submit againthe value on the pending page is still set to TRUE. Which it should be set to FALSE. any ideas ?? Khalid - Original Message - From: John M. Corro [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 15, 2003 10:48 AM Subject: Re: Is this really the best way to handle this problem I've seen two ways of dealing w/ this problem, both of which I see as 'hackish' in nature. Solution A: In your getters/setters you implement the following code public MyCustomBean getMyCustomBean(int index) { while(index = myCustomBeanList.size()) { myCustomBeanList.add(new MyCustomBean()); } return (MyCustomBean)myCustomBeanList.get(index); } In that way you'll never encounter the common IndexOutOfBoundsException. The problem here is that you tend to use alot of hidden fields in your UI to repopulate the data back into the dynamically created beans. Solution B: In your reset() method you repopulate your internal Collection of beans. The problem w/ this approach is that often times you have a separate Action that prepopulates your ActionForm. This provides for good separation - the Action is a retriever of a data (nothing more) and the ActionForm is merely a container for data (nothing more). With this approach your ActionForm suddenly starts becoming more intelligent than it really should be. Now it's aware of how to populate itself...not a good thing IMO. I'd be very interested in hearing other solutions to this problem as I find both of the above solutions cumbersome and hackish and would love to stop implementing them. I've been struggling with a problem similar to the one described (and solved) at http://www.mail-archive.com/[EMAIL PROTECTED]/msg50901.h tml . Is this really the recommended way to solve population / repopulation of properties stored in a List() of whatever-data-object-i-need-in-the-form-of-a-bean ? Is there a better way to acheive the same result ? (I.e represent a collection in a form) I've read that a practice often used to represent collections (a DB-table for intstance) is to make a bean that has getters / setters for the properties of a single row and then have the ActionForm contain a List() of those beans. One for every row (in the DB-example). That far I can follow, and see how / why. But is there no better way to update the values in the ActionForm (beans) when the data is submitted than in the URL above ? //Linus Nikander - [EMAIL PROTECTED
RE: checkboxes - ActionForm in session scope
snip I call reset method selectively since I am trying to develope wizard style pages with one form. /snip Ah, but if you dont reset the checkbox it will always stay ticked - as nothing (not even an empty string!) is submitted for an unticked checkbox so the forms setter method is never called. THIS is the real reason the reset() method even exists in the first place - its a workaround for this flaw in the html spec. Other fields that need to be reset include multiple-select boxes and textareas. Empty input fields will submit an empty string so they dont need to be reset, and single selects always have something selected so dont need it either. If your doing wizards you should still call reset() but you do the selective stuff inside the code for the reset() method (such that it resets only those fields that were visible on the page just submitted). -Original Message- From: Khalid K. [mailto:[EMAIL PROTECTED] Sent: Wednesday, 16 July 2003 01:54 To: Struts Users Mailing List Subject: checkboxes - ActionForm in session scope Hello All, I have the following problem, and any help is greatly appreciated: 1. html form that has a checkbox which is associated with a Action Form Bean - boolean attribute 2. ActionForm is in session scope 3. I call reset method selectively since I am trying to develope wizard style pages with one form. 4. using struts 1.0.2 problem: When I check a checkbox and submit the form, on the pending page, I see the value as set to true which is OK. Now, When I click on modify which takes me to the html with the form, and I uncheck the checkbox and submit againthe value on the pending page is still set to TRUE. Which it should be set to FALSE. any ideas ?? Khalid - Original Message - From: John M. Corro [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, July 15, 2003 10:48 AM Subject: Re: Is this really the best way to handle this problem I've seen two ways of dealing w/ this problem, both of which I see as 'hackish' in nature. Solution A: In your getters/setters you implement the following code public MyCustomBean getMyCustomBean(int index) { while(index = myCustomBeanList.size()) { myCustomBeanList.add(new MyCustomBean()); } return (MyCustomBean)myCustomBeanList.get(index); } In that way you'll never encounter the common IndexOutOfBoundsException. The problem here is that you tend to use alot of hidden fields in your UI to repopulate the data back into the dynamically created beans. Solution B: In your reset() method you repopulate your internal Collection of beans. The problem w/ this approach is that often times you have a separate Action that prepopulates your ActionForm. This provides for good separation - the Action is a retriever of a data (nothing more) and the ActionForm is merely a container for data (nothing more). With this approach your ActionForm suddenly starts becoming more intelligent than it really should be. Now it's aware of how to populate itself...not a good thing IMO. I'd be very interested in hearing other solutions to this problem as I find both of the above solutions cumbersome and hackish and would love to stop implementing them. I've been struggling with a problem similar to the one described (and solved) at http://www.mail-archive.com/[EMAIL PROTECTED]/msg50901.html . Is this really the recommended way to solve population / repopulation of properties stored in a List() of whatever-data-object-i-need-in-the-form-of-a-bean ? Is there a better way to acheive the same result ? (I.e represent a collection in a form) I've read that a practice often used to represent collections (a DB-table for intstance) is to make a bean that has getters / setters for the properties of a single row and then have the ActionForm contain a List() of those beans. One for every row (in the DB-example). That far I can follow, and see how / why. But is there no better way to update the values in the ActionForm (beans) when the data is submitted than in the URL above ? //Linus Nikander - [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] John M. Corro Cornerstone Consulting - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Checkboxes - select All
On Monday, July 29, 2002, 5:10:02 PM, Struts wrote: SN Perhaps I'm going about it the wrong way by selecting them with SN Javascript, although I don't see anyother solution (I don't really want SN to post the form just to select the boxes). Personally I think this is a perfect valid task for javascript to handle. You really can't get around using javascript IMHO for this behavior. Sure you can have the user click a Select All box and then submit the form and return it with them all checked but how are you going to get the form to submit? More than likely you'd want a javascript handler to realize the checkbox was checked and then submit- so if that's the case why not just use javascript in the first place and mark them all selected when the box is checked. -- Rick mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
Re: Checkboxes
html:checkbox name=MyForm property=contactbyEmail/ where contactbyEmail is a boolean variable in MyForm Rehana Sheikh (Contractor) wrote: Hi, Can someone pls send me a sample of how to implement checkboxes? I've tried to but think I may be missing something in an action class/config file/bean. Am having the same problem I had with the drop-down box but am ignoring that for now Thanks.