On Thu, 14 Nov 2002, Wendy Cameron wrote:
> Date: Thu, 14 Nov 2002 09:03:16 +1000 > From: Wendy Cameron <[EMAIL PROTECTED]> > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: Struts Users Mailing List <[EMAIL PROTECTED]> > Subject: RE: jsp:setProperty > > I have been looking into this a little more last night, I decideded > to look at the compiled jsp code when I user jsp:setProperty "*" > > And discovered that in the Code was JspRuntime.introspect(Object, > request) Which is servlet code for jsp:setProperty "*", it now strikes > me as odd there seems to three seperate implementations of populating a > bean through introspect. Each is independant (No package dependancy). > So this means the Jakarta apache project has 3 seperate implementations > of introspect, possibly inconsistant, it also strikes me that every > vendor has a different implementation of it. It seems to me this is > candidate area for standardisation and forming a part of JDK, at least > maybe as an interface, as it seems to be something you would want to do > in a stack of places, eg populating bean fields from the a record in a > record set. > Where do you see *three* implementations? I can count two (the one built in to the JSP environment and the one that Struts uses (commons-beanutils). Where is the third one? > This interested me, because I am trying to write a simple example > framework using MVC architecture as training materials. I want to be > able to avoid the complexities of struts and just demonstrate what MVC > is and how to build MVC architecture. > I'd stick with the commons-beanutils implementation (that Struts also happens to use). Not only is it already separate and reusable (and, in fact, used by quite a few other projects), it is deliberately *not* compatible with the (stupid, IMHO) way that <jsp:setProperty/> deals with zero-length Strings -- JSP implementations basically ignore them. You might want to look at how Struts actually uses BeanUtils.populate() to copy request parameters into a form bean. Specifically, look at the processPopulate method of RequestProcessor (1.1) or ActionServlet (1.0). If you are running in a Servlet 2.3 or later environment, it's basically as simple as: Object formBean = ...; Map parameters = request.getParameterMap(); BeanUtils.populate(formBean, parameters); In a Servlet 2.2 world, the only additional thing is to build the map of parameters by hand (since getParameterMap is not available). > Then the next phase in the course is to introduce Struts, by converting > the same problem or system over to struts. Reinforcing the MVC > concepts, while introducing struts concepts and tablibs. (Is it possible > to get an evaluation copy of Struts in Action) > > So I decided to use the JspRuntime.introspect(Object, request) despite > its platform specific nature, only work with Tomcat, because the > properties are fairly simple in nature. > Beyond locking you into Tomcat, you're also locked in to the JSP spec interpretation of property population, which operates in some unexpected manners. > Regards Wendy > Craig -- To unsubscribe, e-mail: <mailto:struts-user-unsubscribe@;jakarta.apache.org> For additional commands, e-mail: <mailto:struts-user-help@;jakarta.apache.org>