RE: Dynamic Form Beans?
Hi John, Are you able to slove this problem?if so, Can you help me out? Stephen. > -Original Message- > From: John Townsend [SMTP:[EMAIL PROTECTED]] > Sent: Wednesday, August 29, 2001 8:19 PM > To: [EMAIL PROTECTED]; 'Luis Olivares' > Subject: RE: Dynamic Form Beans? > > The one idea that I had was to create a new subclass of ActionForm > called ActionDataForm. This form would have get and put methods that use > keys instead of the usual pattern of numerous getters/setters. > > > For the process of saving form data, we could add a new override to > RequestUtils.processPopulate(..) which would take an ActionDataForm > instead of an ActionForm as its form instance. Then we would implement > this method to use get and put with keys instead of getters/setters. > > One problem: I don't know how the populate works from the other side > (meaning when you want to prepopulate a form based on the contents of a > JavaBean in the session, etc.). I imagine that logic is contained in the > HTML tag libraries or some other tag library. > > I guess what I am wondering is that since a number of people have run > into this and needed a solution I assumed that there might already be a > solution to this problem. If not, maybe we can find a solution and then > submit a patch to Struts for 1.1 or something. > > Anyone else have any thoughts on this? > > -- John Townsend > > PS. One thing I just thought of: I wonder if there is a JavaBeans > solution to this problem? If there is, that might be a better way to go. > > > -Original Message- > From: Luis Olivares [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 29, 2001 11:28 AM > To: [EMAIL PROTECTED] > Subject: Re: Dynamic Form Beans? > > I have the same 'problem'. > > I would like to be able to create a form dynamically depending on the > structure of a table (I used to do this with 'plain' JSP). > Any ideas? > > Regards. >Luis Olivares. >[EMAIL PROTECTED] >-- > "Intelligence is the ability to avoid doing >work, yet getting the work done" > --Linus Torvalds-- > > - Original Message - > From: "John Townsend" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, August 29, 2001 12:54 PM > Subject: Dynamic Form Beans? > > > > I am working on a project where is would be nice to have the ability > to > > define a dynamic form bean (i.e. a form bean where the fields are > > defined at runtime). The most obvious (but perhaps not the best) > > solution to this problem would be if the ActionServlet could handle > > saving data in a form bean that was a hashtable. > > > > Has someone else run into this problem and come up with a solution? > > > > Thanks, > > -- John Townsend > >
RE: Dynamic Form Beans?
One part of the solution is to use the MappedProperty feature recently added to the jakarta-commons bean-utils. The original submission is in this message: http://www.mail-archive.com/jakarta-commons@jakarta.apache.org/msg03005.html It has been integrated into the commons source, as indicated by this message: http://www.mail-archive.com/jakarta-commons@jakarta.apache.org/msg03596.html Also look at this message for a bug that needs to be fixed (hopefully the patch will be committed soon): http://www.mail-archive.com/jakarta-commons@jakarta.apache.org/msg03897.html Other relevant messages are referenced in this one: http://www.mail-archive.com/jakarta-commons@jakarta.apache.org/msg03429.html Hope this helps, Fr. -Original Message- From: John Townsend [mailto:[EMAIL PROTECTED]] Sent: 29 August 2001 19:54 To: [EMAIL PROTECTED] Subject: Dynamic Form Beans? I am working on a project where is would be nice to have the ability to define a dynamic form bean (i.e. a form bean where the fields are defined at runtime). The most obvious (but perhaps not the best) solution to this problem would be if the ActionServlet could handle saving data in a form bean that was a hashtable. Has someone else run into this problem and come up with a solution? Thanks, -- John Townsend The information in this email is confidential and is intended solely for the addressee(s). Access to this email by anyone else is unauthorised. If you are not an intended recipient, you must not read, use or disseminate the information contained in the email. Any views expressed in this message are those of the individual sender, except where the sender specifically states them to be the views of Capco. http://www.capco.com ***
Re: Dynamic Form Beans?
On the input side, it sounds like what you want is a map that is basically a copy of the map usually used internally by the servlet container to represent parameters. If you don't mind having copies in the map of what's also in any explicit form bean fields, you could just use this at the top of the reset() method in your form bean (or a base class). HashMap map = new HashMap(); // Actually, this would be an instance variable for (Enumeration e = request.getParameterNames(); e.hasMoreElements();) { String name = (String)e.nextElement(); map.put(name, request.getParameterValues(name)); } The output side is a little different because the Struts tags are set up to look only for explicit fields. There's been at least one proposal for changing that, though. However, this is what I refer to as an "uncontrolled" dynamic form bean. More interesting would be a "controlled" dynamic form bean, where the valid fields are actually controlled externally, rather than being at the whim of the request (or other code). But then, that's a bunch more work. :-) -- Martin Cooper - Original Message - From: "John Townsend" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]>; "'Luis Olivares'" <[EMAIL PROTECTED]> Sent: Wednesday, August 29, 2001 12:19 PM Subject: RE: Dynamic Form Beans? > The one idea that I had was to create a new subclass of ActionForm > called ActionDataForm. This form would have get and put methods that use > keys instead of the usual pattern of numerous getters/setters. > > > For the process of saving form data, we could add a new override to > RequestUtils.processPopulate(..) which would take an ActionDataForm > instead of an ActionForm as its form instance. Then we would implement > this method to use get and put with keys instead of getters/setters. > > One problem: I don't know how the populate works from the other side > (meaning when you want to prepopulate a form based on the contents of a > JavaBean in the session, etc.). I imagine that logic is contained in the > HTML tag libraries or some other tag library. > > I guess what I am wondering is that since a number of people have run > into this and needed a solution I assumed that there might already be a > solution to this problem. If not, maybe we can find a solution and then > submit a patch to Struts for 1.1 or something. > > Anyone else have any thoughts on this? > > -- John Townsend > > PS. One thing I just thought of: I wonder if there is a JavaBeans > solution to this problem? If there is, that might be a better way to go. > > > -Original Message- > From: Luis Olivares [mailto:[EMAIL PROTECTED]] > Sent: Wednesday, August 29, 2001 11:28 AM > To: [EMAIL PROTECTED] > Subject: Re: Dynamic Form Beans? > > I have the same 'problem'. > > I would like to be able to create a form dynamically depending on the > structure of a table (I used to do this with 'plain' JSP). > Any ideas? > > Regards. >Luis Olivares. >[EMAIL PROTECTED] >-- > "Intelligence is the ability to avoid doing >work, yet getting the work done" > --Linus Torvalds-- > > - Original Message - > From: "John Townsend" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Wednesday, August 29, 2001 12:54 PM > Subject: Dynamic Form Beans? > > > > I am working on a project where is would be nice to have the ability > to > > define a dynamic form bean (i.e. a form bean where the fields are > > defined at runtime). The most obvious (but perhaps not the best) > > solution to this problem would be if the ActionServlet could handle > > saving data in a form bean that was a hashtable. > > > > Has someone else run into this problem and come up with a solution? > > > > Thanks, > > -- John Townsend > > >
Re: Dynamic Form Beans?
I have the same problem too, and I'm sure there are many more like us. I believe this is a problem struts has not addressed yet. Fortunately, they are working on Dynamic form generation feature for struts1.1. I don't know when it is going to be ready!! Here is a work-around: Make your JSPs without using FormBeans (you should have your won Java classes to dynamically generate the form), and extract input parameters from request in your action and stuff them into a Hashtable for further processing. However, someone should clarify if this approach violates struts recommended architecture. I would definitely like to see a better solution. I have posted similar questions earlier on this topic, but I have got no response. Sastry. At 01:27 PM 8/29/2001 -0500, you wrote: >I have the same 'problem'. > >I would like to be able to create a form dynamically depending on the >structure of a table (I used to do this with 'plain' JSP). >Any ideas? > >Regards. >Luis Olivares. >[EMAIL PROTECTED] >-- > "Intelligence is the ability to avoid doing >work, yet getting the work done" > --Linus Torvalds-- > >- Original Message - >From: "John Townsend" <[EMAIL PROTECTED]> >To: <[EMAIL PROTECTED]> >Sent: Wednesday, August 29, 2001 12:54 PM >Subject: Dynamic Form Beans? > > > > I am working on a project where is would be nice to have the ability to > > define a dynamic form bean (i.e. a form bean where the fields are > > defined at runtime). The most obvious (but perhaps not the best) > > solution to this problem would be if the ActionServlet could handle > > saving data in a form bean that was a hashtable. > > > > Has someone else run into this problem and come up with a solution? > > > > Thanks, > > -- John Townsend > > Sastry Varanasi Tel : 408-526-6278 INSMBU, Cisco Systems
RE: Dynamic Form Beans?
The one idea that I had was to create a new subclass of ActionForm called ActionDataForm. This form would have get and put methods that use keys instead of the usual pattern of numerous getters/setters. For the process of saving form data, we could add a new override to RequestUtils.processPopulate(..) which would take an ActionDataForm instead of an ActionForm as its form instance. Then we would implement this method to use get and put with keys instead of getters/setters. One problem: I don't know how the populate works from the other side (meaning when you want to prepopulate a form based on the contents of a JavaBean in the session, etc.). I imagine that logic is contained in the HTML tag libraries or some other tag library. I guess what I am wondering is that since a number of people have run into this and needed a solution I assumed that there might already be a solution to this problem. If not, maybe we can find a solution and then submit a patch to Struts for 1.1 or something. Anyone else have any thoughts on this? -- John Townsend PS. One thing I just thought of: I wonder if there is a JavaBeans solution to this problem? If there is, that might be a better way to go. -Original Message- From: Luis Olivares [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 29, 2001 11:28 AM To: [EMAIL PROTECTED] Subject: Re: Dynamic Form Beans? I have the same 'problem'. I would like to be able to create a form dynamically depending on the structure of a table (I used to do this with 'plain' JSP). Any ideas? Regards. Luis Olivares. [EMAIL PROTECTED] -- "Intelligence is the ability to avoid doing work, yet getting the work done" --Linus Torvalds-- - Original Message - From: "John Townsend" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, August 29, 2001 12:54 PM Subject: Dynamic Form Beans? > I am working on a project where is would be nice to have the ability to > define a dynamic form bean (i.e. a form bean where the fields are > defined at runtime). The most obvious (but perhaps not the best) > solution to this problem would be if the ActionServlet could handle > saving data in a form bean that was a hashtable. > > Has someone else run into this problem and come up with a solution? > > Thanks, > -- John Townsend >
RE: Dynamic Form Beans?
I heard Struts 1.1 will address this issue. In the mean time, I too am interested to a working solution. Thanks, Thinh -Original Message- From: Luis Olivares [mailto:[EMAIL PROTECTED]] Sent: Wednesday, August 29, 2001 1:28 PM To: [EMAIL PROTECTED] Subject: Re: Dynamic Form Beans? I have the same 'problem'. I would like to be able to create a form dynamically depending on the structure of a table (I used to do this with 'plain' JSP). Any ideas? Regards. Luis Olivares. [EMAIL PROTECTED] -- "Intelligence is the ability to avoid doing work, yet getting the work done" --Linus Torvalds-- - Original Message - From: "John Townsend" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, August 29, 2001 12:54 PM Subject: Dynamic Form Beans? > I am working on a project where is would be nice to have the ability to > define a dynamic form bean (i.e. a form bean where the fields are > defined at runtime). The most obvious (but perhaps not the best) > solution to this problem would be if the ActionServlet could handle > saving data in a form bean that was a hashtable. > > Has someone else run into this problem and come up with a solution? > > Thanks, > -- John Townsend >
Re: Dynamic Form Beans?
I have the same 'problem'. I would like to be able to create a form dynamically depending on the structure of a table (I used to do this with 'plain' JSP). Any ideas? Regards. Luis Olivares. [EMAIL PROTECTED] -- "Intelligence is the ability to avoid doing work, yet getting the work done" --Linus Torvalds-- - Original Message - From: "John Townsend" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, August 29, 2001 12:54 PM Subject: Dynamic Form Beans? > I am working on a project where is would be nice to have the ability to > define a dynamic form bean (i.e. a form bean where the fields are > defined at runtime). The most obvious (but perhaps not the best) > solution to this problem would be if the ActionServlet could handle > saving data in a form bean that was a hashtable. > > Has someone else run into this problem and come up with a solution? > > Thanks, > -- John Townsend >