Re: Filling-in a Bean inside a Servlet
Zerbe John W <[email protected]> Fri, 2 Sep 2005 17:17:52 -0400
| Newsgroups | gmane.comp.java.sun.servlet |
|---|---|
| Message-ID | <12A98F54FE7D1D4198E9B8D1D678BD2204CFCCB2@E2KMAIL1507.mellonbank.com> |
Hi, An alternative would be to do what the jsp processor does. Write your = own piece of code that uses reflection to determine what "setters" exist = for the bean and match those up with the request parameter names.=20 If you do some searching, you may find some free open source that does = this already. John Zerbe=20 -----Original Message----- From: A mailing list for discussion about Sun Microsystem's Java Servlet API Technology. [mailto:[email protected]]On Behalf Of Dani Pardo Sent: Friday, September 02, 2005 12:53 PM To: [email protected] Subject: Re: Filling-in a Bean inside a Servlet > Can I fill all the properties of the Bean magically on a line, = The > same way that the jsp does it via <jsp:setProperty property=3D"*"> ??? > There must be a trick or a workaround, because this method = doesn't > scale. There must be some trick to achieve to get a Customer object as = a > parameter: Hi, I respond to myself. I've done intensing search and I've finally get on the = conclusion that it can't be done: When using Servlets and JSPs, you play with FORM parameters on = the jsp side, and play with attaching attributes on the Servlet side. Acutally, it's almost the same I've been doing with Perl CGIs and Template = Toolkit. To do the magic-bean-populating trick, you have to use some = esoteric framwork like Struts: From http://www.coreservlets.com/Apache-Struts-Tutorial/ "With Struts, the normal processing flow is that a form submits data to a URL of the form blah.do. That address is mapped by struts-config.xml to an Action object, whose execute method handles the request. One of the arguments to execute is a form bean that is automatically created and whose properties are automatically populated with the incoming form data. The Action object then invokes business logic and data-access logic, placing the results in normal beans stored in request, session, or application scope." -- Dani Pardo, [email protected] Enplater S.A _________________________________________________________________________= __ To unsubscribe, send email to [email protected] and include in the = body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html =20 The information contained in this e-mail may be confidential and is = intended solely for the use of the named addressee. Access, copying or re-use of the e-mail or any information contained = therein by any other person is not authorized. If you are not the intended recipient please notify us immediately by = returning the e-mail to the originator.(16b) ___________________________________________________________________________ To unsubscribe, send email to [email protected] and include in the body of the message "signoff SERVLET-INTEREST". Archives: http://archives.java.sun.com/archives/servlet-interest.html Resources: http://java.sun.com/products/servlet/external-resources.html LISTSERV Help: http://www.lsoft.com/manuals/user/user.html