DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9001>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9001 enhancement for form beans Summary: enhancement for form beans Product: Struts Version: 1.0.2 Final Platform: All OS/Version: Other Status: NEW Severity: Enhancement Priority: Other Component: Controller AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] I have thought of an enhancement for creating/using form beans in Struts. It seems like their could be one form bean for all forms if the form bean used something like a hashtable to store the key-value pairs of any given form. This would eliminate the need to have or write several form beans. The Struts architecture would have to change just a little bit (at least from my point of view) so that instead of looking for a method that matches the name of the form field it would look for a method that sets the key (form field name) and value (value of the form element). When auto-filling in a form it would use an accessor method to access the value for the given form field element. As far as the action classes go, a developer would change from using specific getter/setter methods to using one getter, setter with various keys. Examples: FormBean.java public class FormBean { public class FormBean() { myAttributes = new Hashtable(); } public String getAttribute(String key) { return (String)myAttributes(key); } public void setAttribute(String key, String value) { myAttributes.put(key, value); } private Hashtable myAttributes; } Suppose an text input field exists named "someNumber" and the value of the field is "123". Instead of calling formBean.setSomeNumber("123") it would call formBean.setAttribute("someNumber","123"); The action class (after getting reference to the form bean) could do something like: String theNumber = formBean.getAttribute("someNumber") instead of String theNumber = formBean.getSomeNumber(); The advanatges are: 1. It reduces the number of form beans that have to be created. In fact, just one form bean could be used for all forms. 2. It doesn't add any additional steps to retrieving or setting data in the Action Class. 3. By reducing the number of form beans classes that are created, the developer's job is made easier. This is just an idea for enhancement. Perhaps I don't see the bigger picture for the current architecture. I assume there is a good reason it is done the way it is done currently but I thought I'd throw this out just in case it may be useful. -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>