Re: Design Problem: Multiple Object Update
So, I've been following this thread, but I'm a bit confused on how you would access the ArrayList of beans from the Action (assuming a DynaForm implementation). Which method of PropertyUtils or BeanUtils should be used if any? Taylor, Jason wrote: Yeah, I've done this stuff a fair bit. You definitely need 1.1 because the indexed attribute has been added to the html:xxx tags and the nested extension has been folded into the core distribution. You can definitely declare an array or ArrayList of objects as a form-property of a DynaActionForm. The objects in the lists I use are regular beans with getter/setters since I haven't gotten around to figuring out how to nest DynaActionForms in such a way as to have the controller handle population for me. Anyway, it definitely works with the custom beans I define as ad hoc classes-- the controller can populate any bean so long as it can find the class that defines it. You define the form elements on the JSP doing the submission using logic:iterate and the indexed attribute of your html:xxx/ tags. My rule is to use indexed tags with one dimension of arbitrary length and nested with more than that and never both-- noone to my knowledge has yet contradicted me in this forum so I think it's reasonably good rule of thumb. In general, this approach is *way* better than parsing the request attributes in your code. Let me know if I'm not clear-- it is after all Friday-- but anyway it's totally do-able. The problem I've had is with elements like checkboxes that require some activity in the reset() method. Since you're building an array dynamically from the DB you have to work out some strategy for handling exceptions that leave your form less than totally initialized. I'm thinking I could do something with declarative exceptions, but again I haven't gotten around to it. -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:28 AM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update you still need to declare your variables in the config file eith a DynaActionForm. This form is dependent on whats in the db at that time. does any one else have any suggestions for this design issue? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:27 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update Oh...have you looked into DynaActionForm? -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 1:22 PM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update Mark, I dont think you really read my email before responding. I understand the importance of the Form Action Paradigm, and why it exisits. I am using it in most places in my application. In this particular form, I have a list of objects, with multiple attributes. Each attribute name is preceded by the objects id. this list is dynamically created, so i would not know how to create the form beforehand. I was wondering if there was some struts feature that could help me with the semi-common wbe form problem. any ideas? thanks, mark s. -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:19 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update I was only suggesting upgrading. By bypassing the ActionForm you do not allow Struts to do what it does best - set the state of a bean with values gathered from an HTML form upon submit. Your users are not really updating dynamically - that would mean in real time. They are inputting values into a form and then submitting the form. If you have an Action class and ActionForm declared and mapped in struts-config.xml, Struts will set the state of all associated variables in the ActionForm (JavaBean) automatically. Then you can use the associated Action class to do whatever you want with the values - store in a database, pass to another action, return to the user for verification, etc. Mark -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 12:52 PM How will upgrading to 1.1b2 help me here? does it provide some feature that does what i need? i cannot seem to find it. i understand i shouldn't bypass the form, but HOW can i avoid it since these are all dynamically created inputs based on an id list? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 4:29 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update a. upgrade to 1.1b2 b. don't bypass the ActionForm -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 03, 2002 8:40 PM To: Struts Users Mailing List Subject: Design Problem: Multiple Object Update How
RE: Design Problem: Multiple Object Update
a. upgrade to 1.1b2 b. don't bypass the ActionForm -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 03, 2002 8:40 PM To: Struts Users Mailing List Subject: Design Problem: Multiple Object Update How would you strut gurus approach this in a Struts oriented way ( I am currently using Struts 1.0.2) I have a list of objects on the screen, and i want to be able to make mass updates to. For example, i have a list of users, with Various Attributes (name, isActive checkbox, etc). I want the user to be able to make edits on the whole screen, and then submit it. What is the best way to keep the data together in terms of naming of the fields. currently I precede each value with the userId and an underscore. User = Mark Silva userId = 101 name field -- 101_name isActiveField -- 101_isActive then to get all the data, i have to parse through the parameter list in the request, and piece this all together. Notice I am bypassing the Form object. Is there a Struts way to do this? thanks, Mark -- 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]
RE: Design Problem: Multiple Object Update
How will upgrading to 1.1b2 help me here? does it provide some feature that does what i need? i cannot seem to find it. i understand i shouldn't bypass the form, but HOW can i avoid it since these are all dynamically created inputs based on an id list? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 4:29 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update a. upgrade to 1.1b2 b. don't bypass the ActionForm -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 03, 2002 8:40 PM To: Struts Users Mailing List Subject: Design Problem: Multiple Object Update How would you strut gurus approach this in a Struts oriented way ( I am currently using Struts 1.0.2) I have a list of objects on the screen, and i want to be able to make mass updates to. For example, i have a list of users, with Various Attributes (name, isActive checkbox, etc). I want the user to be able to make edits on the whole screen, and then submit it. What is the best way to keep the data together in terms of naming of the fields. currently I precede each value with the userId and an underscore. User = Mark Silva userId = 101 name field -- 101_name isActiveField -- 101_isActive then to get all the data, i have to parse through the parameter list in the request, and piece this all together. Notice I am bypassing the Form object. Is there a Struts way to do this? thanks, Mark -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Design Problem: Multiple Object Update
I was only suggesting upgrading. By bypassing the ActionForm you do not allow Struts to do what it does best - set the state of a bean with values gathered from an HTML form upon submit. Your users are not really updating dynamically - that would mean in real time. They are inputting values into a form and then submitting the form. If you have an Action class and ActionForm declared and mapped in struts-config.xml, Struts will set the state of all associated variables in the ActionForm (JavaBean) automatically. Then you can use the associated Action class to do whatever you want with the values - store in a database, pass to another action, return to the user for verification, etc. Mark -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 12:52 PM How will upgrading to 1.1b2 help me here? does it provide some feature that does what i need? i cannot seem to find it. i understand i shouldn't bypass the form, but HOW can i avoid it since these are all dynamically created inputs based on an id list? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 4:29 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update a. upgrade to 1.1b2 b. don't bypass the ActionForm -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 03, 2002 8:40 PM To: Struts Users Mailing List Subject: Design Problem: Multiple Object Update How would you strut gurus approach this in a Struts oriented way ( I am currently using Struts 1.0.2) I have a list of objects on the screen, and i want to be able to make mass updates to. For example, i have a list of users, with Various Attributes (name, isActive checkbox, etc). I want the user to be able to make edits on the whole screen, and then submit it. What is the best way to keep the data together in terms of naming of the fields. currently I precede each value with the userId and an underscore. User = Mark Silva userId = 101 name field -- 101_name isActiveField -- 101_isActive then to get all the data, i have to parse through the parameter list in the request, and piece this all together. Notice I am bypassing the Form object. Is there a Struts way to do this? thanks, Mark -- 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] -- 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]
RE: Design Problem: Multiple Object Update
Mark, I dont think you really read my email before responding. I understand the importance of the Form Action Paradigm, and why it exisits. I am using it in most places in my application. In this particular form, I have a list of objects, with multiple attributes. Each attribute name is preceded by the objects id. this list is dynamically created, so i would not know how to create the form beforehand. I was wondering if there was some struts feature that could help me with the semi-common wbe form problem. any ideas? thanks, mark s. -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:19 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update I was only suggesting upgrading. By bypassing the ActionForm you do not allow Struts to do what it does best - set the state of a bean with values gathered from an HTML form upon submit. Your users are not really updating dynamically - that would mean in real time. They are inputting values into a form and then submitting the form. If you have an Action class and ActionForm declared and mapped in struts-config.xml, Struts will set the state of all associated variables in the ActionForm (JavaBean) automatically. Then you can use the associated Action class to do whatever you want with the values - store in a database, pass to another action, return to the user for verification, etc. Mark -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 12:52 PM How will upgrading to 1.1b2 help me here? does it provide some feature that does what i need? i cannot seem to find it. i understand i shouldn't bypass the form, but HOW can i avoid it since these are all dynamically created inputs based on an id list? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 4:29 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update a. upgrade to 1.1b2 b. don't bypass the ActionForm -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 03, 2002 8:40 PM To: Struts Users Mailing List Subject: Design Problem: Multiple Object Update How would you strut gurus approach this in a Struts oriented way ( I am currently using Struts 1.0.2) I have a list of objects on the screen, and i want to be able to make mass updates to. For example, i have a list of users, with Various Attributes (name, isActive checkbox, etc). I want the user to be able to make edits on the whole screen, and then submit it. What is the best way to keep the data together in terms of naming of the fields. currently I precede each value with the userId and an underscore. User = Mark Silva userId = 101 name field -- 101_name isActiveField -- 101_isActive then to get all the data, i have to parse through the parameter list in the request, and piece this all together. Notice I am bypassing the Form object. Is there a Struts way to do this? thanks, Mark -- 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] -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Design Problem: Multiple Object Update
Oh...have you looked into DynaActionForm? -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 1:22 PM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update Mark, I dont think you really read my email before responding. I understand the importance of the Form Action Paradigm, and why it exisits. I am using it in most places in my application. In this particular form, I have a list of objects, with multiple attributes. Each attribute name is preceded by the objects id. this list is dynamically created, so i would not know how to create the form beforehand. I was wondering if there was some struts feature that could help me with the semi-common wbe form problem. any ideas? thanks, mark s. -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:19 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update I was only suggesting upgrading. By bypassing the ActionForm you do not allow Struts to do what it does best - set the state of a bean with values gathered from an HTML form upon submit. Your users are not really updating dynamically - that would mean in real time. They are inputting values into a form and then submitting the form. If you have an Action class and ActionForm declared and mapped in struts-config.xml, Struts will set the state of all associated variables in the ActionForm (JavaBean) automatically. Then you can use the associated Action class to do whatever you want with the values - store in a database, pass to another action, return to the user for verification, etc. Mark -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 12:52 PM How will upgrading to 1.1b2 help me here? does it provide some feature that does what i need? i cannot seem to find it. i understand i shouldn't bypass the form, but HOW can i avoid it since these are all dynamically created inputs based on an id list? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 4:29 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update a. upgrade to 1.1b2 b. don't bypass the ActionForm -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 03, 2002 8:40 PM To: Struts Users Mailing List Subject: Design Problem: Multiple Object Update How would you strut gurus approach this in a Struts oriented way ( I am currently using Struts 1.0.2) I have a list of objects on the screen, and i want to be able to make mass updates to. For example, i have a list of users, with Various Attributes (name, isActive checkbox, etc). I want the user to be able to make edits on the whole screen, and then submit it. What is the best way to keep the data together in terms of naming of the fields. currently I precede each value with the userId and an underscore. User = Mark Silva userId = 101 name field -- 101_name isActiveField -- 101_isActive then to get all the data, i have to parse through the parameter list in the request, and piece this all together. Notice I am bypassing the Form object. Is there a Struts way to do this? thanks, Mark -- 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] -- 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] -- 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]
RE: Design Problem: Multiple Object Update
you still need to declare your variables in the config file eith a DynaActionForm. This form is dependent on whats in the db at that time. does any one else have any suggestions for this design issue? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:27 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update Oh...have you looked into DynaActionForm? -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 1:22 PM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update Mark, I dont think you really read my email before responding. I understand the importance of the Form Action Paradigm, and why it exisits. I am using it in most places in my application. In this particular form, I have a list of objects, with multiple attributes. Each attribute name is preceded by the objects id. this list is dynamically created, so i would not know how to create the form beforehand. I was wondering if there was some struts feature that could help me with the semi-common wbe form problem. any ideas? thanks, mark s. -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:19 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update I was only suggesting upgrading. By bypassing the ActionForm you do not allow Struts to do what it does best - set the state of a bean with values gathered from an HTML form upon submit. Your users are not really updating dynamically - that would mean in real time. They are inputting values into a form and then submitting the form. If you have an Action class and ActionForm declared and mapped in struts-config.xml, Struts will set the state of all associated variables in the ActionForm (JavaBean) automatically. Then you can use the associated Action class to do whatever you want with the values - store in a database, pass to another action, return to the user for verification, etc. Mark -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 12:52 PM How will upgrading to 1.1b2 help me here? does it provide some feature that does what i need? i cannot seem to find it. i understand i shouldn't bypass the form, but HOW can i avoid it since these are all dynamically created inputs based on an id list? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 4:29 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update a. upgrade to 1.1b2 b. don't bypass the ActionForm -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 03, 2002 8:40 PM To: Struts Users Mailing List Subject: Design Problem: Multiple Object Update How would you strut gurus approach this in a Struts oriented way ( I am currently using Struts 1.0.2) I have a list of objects on the screen, and i want to be able to make mass updates to. For example, i have a list of users, with Various Attributes (name, isActive checkbox, etc). I want the user to be able to make edits on the whole screen, and then submit it. What is the best way to keep the data together in terms of naming of the fields. currently I precede each value with the userId and an underscore. User = Mark Silva userId = 101 name field -- 101_name isActiveField -- 101_isActive then to get all the data, i have to parse through the parameter list in the request, and piece this all together. Notice I am bypassing the Form object. Is there a Struts way to do this? thanks, Mark -- 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] -- 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] -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Design Problem: Multiple Object Update
On Fri, 4 Oct 2002, Mark Silva wrote: In this particular form, I have a list of objects, with multiple attributes. Each attribute name is preceded by the objects id. this list is dynamically created, so i would not know how to create the form beforehand. I was wondering if there was some struts feature that could help me with the semi-common wbe form problem. See http://husted.com/struts/tips/006.html - is this what you're looking for? Pavel -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Design Problem: Multiple Object Update
this may be what i am looking for. i have a question about this example... how does struts match the parameters, whose names are all the same. his examples uses. category=XYZkey=123 so if you had a bunch of parameters like so category=XYZkey=123category=ABCkey=256category=AAA how does struts correspond the category to the key? in my app i am currently doing this like so, 123_category=XYZ124_category=ABC129_category=AAA and parsing through the parameter list. I also have more than one parameter type per key, like so. 123_category=XYZ124_category=ABC129_category=AAA123_color=green124_color=red129_color=blue123_type=1124_type=1129_type=2 so the question remains, how do i correspond a key, to multiple attributes. i cannot tell if the example given will actually do this, and if so, how? struts magic? ;-) ---mark -Original Message- From: Pavel Kolesnikov [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:29 AM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update On Fri, 4 Oct 2002, Mark Silva wrote: In this particular form, I have a list of objects, with multiple attributes. Each attribute name is preceded by the objects id. this list is dynamically created, so i would not know how to create the form beforehand. I was wondering if there was some struts feature that could help me with the semi-common wbe form problem. See http://husted.com/struts/tips/006.html - is this what you're looking for? Pavel -- 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]
RE: Design Problem: Multiple Object Update
On Fri, 4 Oct 2002, Mark Silva wrote: so if you had a bunch of parameters like so category=XYZkey=123category=ABCkey=256category=AAA how does struts correspond the category to the key? They don't. You have to go manually through all the arrays (getCategory, getKey etc) and suppose all the values are set in the appropriate order. So you can do somthing like: for (i = 0; i key.size i category.size; i++) { System.out.println (key: + key[i] + , category: + category[i]); } I think it's nicer than parsing stuff like 123_category=XYZ124_category=ABC129_category=AAA123_color ... ;) Pavel -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Design Problem: Multiple Object Update
Pavel, Can we assume that the parameters will be sent in the right order? I have always assumed that this was something that could not be guarenteed with a form submission? i could be wrong about this point. thanks, mark -Original Message- From: Pavel Kolesnikov [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:57 AM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update On Fri, 4 Oct 2002, Mark Silva wrote: so if you had a bunch of parameters like so category=XYZkey=123category=ABCkey=256category=AAA how does struts correspond the category to the key? They don't. You have to go manually through all the arrays (getCategory, getKey etc) and suppose all the values are set in the appropriate order. So you can do somthing like: for (i = 0; i key.size i category.size; i++) { System.out.println (key: + key[i] + , category: + category[i]); } I think it's nicer than parsing stuff like 123_category=XYZ124_category=ABC129_category=AAA123_color ... ;) Pavel -- 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]
RE: Design Problem: Multiple Object Update
Not sure, but the only way I can see to do it is manually in your Action class. Mark -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 1:45 PM this may be what i am looking for. i have a question about this example... how does struts match the parameters, whose names are all the same. his examples uses. category=XYZkey=123 so if you had a bunch of parameters like so category=XYZkey=123category=ABCkey=256category=AAA how does struts correspond the category to the key? in my app i am currently doing this like so, 123_category=XYZ124_category=ABC129_category=AAA and parsing through the parameter list. I also have more than one parameter type per key, like so. 123_category=XYZ124_category=ABC129_category=AAA123_color=green124_color =red129_color=blue123_type=1124_type=1129_type=2 so the question remains, how do i correspond a key, to multiple attributes. i cannot tell if the example given will actually do this, and if so, how? struts magic? ;-) ---mark -Original Message- From: Pavel Kolesnikov [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:29 AM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update On Fri, 4 Oct 2002, Mark Silva wrote: In this particular form, I have a list of objects, with multiple attributes. Each attribute name is preceded by the objects id. this list is dynamically created, so i would not know how to create the form beforehand. I was wondering if there was some struts feature that could help me with the semi-common wbe form problem. See http://husted.com/struts/tips/006.html - is this what you're looking for? Pavel -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Design Problem: Multiple Object Update
Yes, you can be sure, because form elements are actually an array, and one element will follow another. Mark -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 1:59 PM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update Pavel, Can we assume that the parameters will be sent in the right order? I have always assumed that this was something that could not be guarenteed with a form submission? i could be wrong about this point. thanks, mark -Original Message- From: Pavel Kolesnikov [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:57 AM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update On Fri, 4 Oct 2002, Mark Silva wrote: so if you had a bunch of parameters like so category=XYZkey=123category=ABCkey=256category=AAA how does struts correspond the category to the key? They don't. You have to go manually through all the arrays (getCategory, getKey etc) and suppose all the values are set in the appropriate order. So you can do somthing like: for (i = 0; i key.size i category.size; i++) { System.out.println (key: + key[i] + , category: + category[i]); } I think it's nicer than parsing stuff like 123_category=XYZ124_category=ABC129_category=AAA123_color ... ;) Pavel -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED]
RE: Design Problem: Multiple Object Update
Yeah, I've done this stuff a fair bit. You definitely need 1.1 because the indexed attribute has been added to the html:xxx tags and the nested extension has been folded into the core distribution. You can definitely declare an array or ArrayList of objects as a form-property of a DynaActionForm. The objects in the lists I use are regular beans with getter/setters since I haven't gotten around to figuring out how to nest DynaActionForms in such a way as to have the controller handle population for me. Anyway, it definitely works with the custom beans I define as ad hoc classes-- the controller can populate any bean so long as it can find the class that defines it. You define the form elements on the JSP doing the submission using logic:iterate and the indexed attribute of your html:xxx/ tags. My rule is to use indexed tags with one dimension of arbitrary length and nested with more than that and never both-- noone to my knowledge has yet contradicted me in this forum so I think it's reasonably good rule of thumb. In general, this approach is *way* better than parsing the request attributes in your code. Let me know if I'm not clear-- it is after all Friday-- but anyway it's totally do-able. The problem I've had is with elements like checkboxes that require some activity in the reset() method. Since you're building an array dynamically from the DB you have to work out some strategy for handling exceptions that leave your form less than totally initialized. I'm thinking I could do something with declarative exceptions, but again I haven't gotten around to it. -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:28 AM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update you still need to declare your variables in the config file eith a DynaActionForm. This form is dependent on whats in the db at that time. does any one else have any suggestions for this design issue? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:27 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update Oh...have you looked into DynaActionForm? -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 1:22 PM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update Mark, I dont think you really read my email before responding. I understand the importance of the Form Action Paradigm, and why it exisits. I am using it in most places in my application. In this particular form, I have a list of objects, with multiple attributes. Each attribute name is preceded by the objects id. this list is dynamically created, so i would not know how to create the form beforehand. I was wondering if there was some struts feature that could help me with the semi-common wbe form problem. any ideas? thanks, mark s. -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:19 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update I was only suggesting upgrading. By bypassing the ActionForm you do not allow Struts to do what it does best - set the state of a bean with values gathered from an HTML form upon submit. Your users are not really updating dynamically - that would mean in real time. They are inputting values into a form and then submitting the form. If you have an Action class and ActionForm declared and mapped in struts-config.xml, Struts will set the state of all associated variables in the ActionForm (JavaBean) automatically. Then you can use the associated Action class to do whatever you want with the values - store in a database, pass to another action, return to the user for verification, etc. Mark -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 12:52 PM How will upgrading to 1.1b2 help me here? does it provide some feature that does what i need? i cannot seem to find it. i understand i shouldn't bypass the form, but HOW can i avoid it since these are all dynamically created inputs based on an id list? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 4:29 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update a. upgrade to 1.1b2 b. don't bypass the ActionForm -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 03, 2002 8:40 PM To: Struts Users Mailing List Subject: Design Problem: Multiple Object Update How would you strut gurus approach this in a Struts oriented way ( I am currently using Struts 1.0.2) I have a list of objects on the screen, and i want to be able to make mass updates to. For example, i have a list of users, with Various Attributes (name
RE: Design Problem: Multiple Object Update
I started with Ted's example too, but I prefer to have one list of beans that contain all the properties rather than a bunch of lists of primitives. When you use the indexed attribute the controller automatically converts your form elements to request parameters that look like this: foo.do?beans[0].property1=xxxbeans[0].property2=yyybeans[1].property1= zzzbeans[1].property2=areyousleepy -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:45 AM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update this may be what i am looking for. i have a question about this example... how does struts match the parameters, whose names are all the same. his examples uses. category=XYZkey=123 so if you had a bunch of parameters like so category=XYZkey=123category=ABCkey=256category=AAA how does struts correspond the category to the key? in my app i am currently doing this like so, 123_category=XYZ124_category=ABC129_category=AAA and parsing through the parameter list. I also have more than one parameter type per key, like so. 123_category=XYZ124_category=ABC129_category=AAA123_color=green124_color =red129_color=blue123_type=1124_type=1129_type=2 so the question remains, how do i correspond a key, to multiple attributes. i cannot tell if the example given will actually do this, and if so, how? struts magic? ;-) ---mark -Original Message- From: Pavel Kolesnikov [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:29 AM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update On Fri, 4 Oct 2002, Mark Silva wrote: In this particular form, I have a list of objects, with multiple attributes. Each attribute name is preceded by the objects id. this list is dynamically created, so i would not know how to create the form beforehand. I was wondering if there was some struts feature that could help me with the semi-common wbe form problem. See http://husted.com/struts/tips/006.html - is this what you're looking for? Pavel -- 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]
Re: Design Problem: Multiple Object Update
Here is what I have done: 1. Test that each contained object/bean updates on it's own. The contained beans implement a collection so I can have getRow, next(), etc. (OT: I use reflection and metedata to auto generate the SQL updates). 2. The main objects update and populate calls the contained objects populate and updates in order. I also create a Object getBeanObjecA() that returns one of the contained objects. And a getBeanObjectB() that returns the other contained object, etc. 3. In JSP, you can say bean.beanObjcetA.property1. 4. On a submit, in Struts 1.1 Struts automaticaly uses getRow index property to call the setters in order. 5. In action, I say object.save() (See #2, which in turn calls contained collections save()). hth, .V Taylor, Jason wrote: Yeah, I've done this stuff a fair bit. You definitely need 1.1 because the indexed attribute has been added to the html:xxx tags and the nested extension has been folded into the core distribution. You can definitely declare an array or ArrayList of objects as a form-property of a DynaActionForm. The objects in the lists I use are regular beans with getter/setters since I haven't gotten around to figuring out how to nest DynaActionForms in such a way as to have the controller handle population for me. Anyway, it definitely works with the custom beans I define as ad hoc classes-- the controller can populate any bean so long as it can find the class that defines it. You define the form elements on the JSP doing the submission using logic:iterate and the indexed attribute of your html:xxx/ tags. My rule is to use indexed tags with one dimension of arbitrary length and nested with more than that and never both-- noone to my knowledge has yet contradicted me in this forum so I think it's reasonably good rule of thumb. In general, this approach is *way* better than parsing the request attributes in your code. Let me know if I'm not clear-- it is after all Friday-- but anyway it's totally do-able. The problem I've had is with elements like checkboxes that require some activity in the reset() method. Since you're building an array dynamically from the DB you have to work out some strategy for handling exceptions that leave your form less than totally initialized. I'm thinking I could do something with declarative exceptions, but again I haven't gotten around to it. -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:28 AM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update you still need to declare your variables in the config file eith a DynaActionForm. This form is dependent on whats in the db at that time. does any one else have any suggestions for this design issue? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:27 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update Oh...have you looked into DynaActionForm? -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 1:22 PM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update Mark, I dont think you really read my email before responding. I understand the importance of the Form Action Paradigm, and why it exisits. I am using it in most places in my application. In this particular form, I have a list of objects, with multiple attributes. Each attribute name is preceded by the objects id. this list is dynamically created, so i would not know how to create the form beforehand. I was wondering if there was some struts feature that could help me with the semi-common wbe form problem. any ideas? thanks, mark s. -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:19 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update I was only suggesting upgrading. By bypassing the ActionForm you do not allow Struts to do what it does best - set the state of a bean with values gathered from an HTML form upon submit. Your users are not really updating dynamically - that would mean in real time. They are inputting values into a form and then submitting the form. If you have an Action class and ActionForm declared and mapped in struts-config.xml, Struts will set the state of all associated variables in the ActionForm (JavaBean) automatically. Then you can use the associated Action class to do whatever you want with the values - store in a database, pass to another action, return to the user for verification, etc. Mark -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 12:52 PM How will upgrading to 1.1b2 help me here? does it provide some feature that does what i
RE: Design Problem: Multiple Object Update
Try this url - it uses the nested:iterate tag to good effect: http://www.keyboardmonkey.com/StrutMonkey/monkey-action-v2.do You can go http://www.keyboardmonkey.com to find out more about how it works. -Peter On Fri, 2002-10-04 at 13:28, Mark Silva wrote: you still need to declare your variables in the config file eith a DynaActionForm. This form is dependent on whats in the db at that time. does any one else have any suggestions for this design issue? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:27 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update Oh...have you looked into DynaActionForm? -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 1:22 PM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update Mark, I dont think you really read my email before responding. I understand the importance of the Form Action Paradigm, and why it exisits. I am using it in most places in my application. In this particular form, I have a list of objects, with multiple attributes. Each attribute name is preceded by the objects id. this list is dynamically created, so i would not know how to create the form beforehand. I was wondering if there was some struts feature that could help me with the semi-common wbe form problem. any ideas? thanks, mark s. -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:19 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update I was only suggesting upgrading. By bypassing the ActionForm you do not allow Struts to do what it does best - set the state of a bean with values gathered from an HTML form upon submit. Your users are not really updating dynamically - that would mean in real time. They are inputting values into a form and then submitting the form. If you have an Action class and ActionForm declared and mapped in struts-config.xml, Struts will set the state of all associated variables in the ActionForm (JavaBean) automatically. Then you can use the associated Action class to do whatever you want with the values - store in a database, pass to another action, return to the user for verification, etc. Mark -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 12:52 PM How will upgrading to 1.1b2 help me here? does it provide some feature that does what i need? i cannot seem to find it. i understand i shouldn't bypass the form, but HOW can i avoid it since these are all dynamically created inputs based on an id list? thanks, mark -Original Message- From: Galbreath, Mark [mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 4:29 AM To: 'Struts Users Mailing List' Subject: RE: Design Problem: Multiple Object Update a. upgrade to 1.1b2 b. don't bypass the ActionForm -Original Message- From: Mark Silva [mailto:[EMAIL PROTECTED]] Sent: Thursday, October 03, 2002 8:40 PM To: Struts Users Mailing List Subject: Design Problem: Multiple Object Update How would you strut gurus approach this in a Struts oriented way ( I am currently using Struts 1.0.2) I have a list of objects on the screen, and i want to be able to make mass updates to. For example, i have a list of users, with Various Attributes (name, isActive checkbox, etc). I want the user to be able to make edits on the whole screen, and then submit it. What is the best way to keep the data together in terms of naming of the fields. currently I precede each value with the userId and an underscore. User = Mark Silva userId = 101 name field -- 101_name isActiveField -- 101_isActive then to get all the data, i have to parse through the parameter list in the request, and piece this all together. Notice I am bypassing the Form object. Is there a Struts way to do this? thanks, Mark -- 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] -- 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] -- 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] -- To unsubscribe, e-mail: mailto:[EMAIL PROTECTED] For additional commands, e-mail: mailto:[EMAIL PROTECTED] -- To unsubscribe, e-mail
RE: Design Problem: Multiple Object Update
Have you considered using HashMaps or ArrayLists in your forms. BeanUtils supports this kind of thing and therefor so does struts. some thing like... // Load object from the database in init action. HashMap users = new HashMap(); //for each user load key into map. users.put(dbUser.getId, dbUser); //Place users into Form form.setUsers(users); !--In jsp-- html:form action=someAction / logic:iterate id=user name=someForm property=users bean:write name=someForm property=user.userId / !-- This is where it gets harry html:text name=someForm property=%=user(\+ user.getUserId +\ ).active% / /logic:itereate In the post-accepting action the form.getUsers will be populated appropriately. We have used this approach with struts 1.0.2 to good effect. There are some drawbacks though. JavaScript doesn't like . in form element names. This can be overcome, though I forgot how we did it. And this does kinda rely on session. If I thought about it a little longer I could probably fix that too. Will Etson Galbreath, Mark [EMAIL PROTECTED] 10/04/02 11:01AM Yes, you can be sure, because form elements are actually an array, and one element will follow another. Mark -Original Message- From: Mark Silva [ mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 1:59 PM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update Pavel, Can we assume that the parameters will be sent in the right order? I have always assumed that this was something that could not be guarenteed with a form submission? i could be wrong about this point. thanks, mark -Original Message- From: Pavel Kolesnikov [ mailto:[EMAIL PROTECTED]] Sent: Friday, October 04, 2002 10:57 AM To: Struts Users Mailing List Subject: RE: Design Problem: Multiple Object Update On Fri, 4 Oct 2002, Mark Silva wrote: so if you had a bunch of parameters like so category=XYZkey=123category=ABCkey=256category=AAA how does struts correspond the category to the key? They don't. You have to go manually through all the arrays (getCategory, getKey etc) and suppose all the values are set in the appropriate order. So you can do somthing like: for (i = 0; i key.size i category.size; i++) { System.out.println (key: + key[i] + , category: + category[i]); } I think it's nicer than parsing stuff like 123_category=XYZ124_category=ABC129_category=AAA123_color ... ;) Pavel -- 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]