[Opensource] what is the use of the DefaultForm form bean?

Peter A. Pilgrim peterp at xenonsoft.demon.co.uk
Wed Dec 11 16:47:51 PST 2002


Mike Traum wrote:
> After trying to figure out the workflow method of using 
> addStatePairing(), it became apparent to me that I do not understand how 
> the DefaultForm can be used within expresso. When I use the perform() 
> method (instead of run()), I can't seem to access any data in the 
> DefaultForm bean - the bean exists, but is empty. If I define my own 
> form bean with the standard getters and setters, that works. But, it's a 
> real pain and it seems that was the point of DefaultForm - a dynamic 
> form bean.
>  
> Any ideas?

I think `DefaultForm' is a dummy `ActionForm' because every controller
extends a Struts `Action'. It is possible in Pure Struts just define
an action that does not need an action form. Have tried making your
form bean extend the DefaultForm?

Looking at source code, Mike Nash, wrote it. The overall intention
is not clear. I looked at the `Controller.java' then and see it
only referenced in one place of code.

			try {
				BeanUtils.populate(form, req.getParameters());
			} catch (Exception e) {
				if (form instanceof DefaultForm) {
					try {
						((DefaultForm) form).setUsingHashtableParameters(req.getParameters());
					} catch (Exception ex) {


						ex.printStackTrace();
						throw new ServletException(ex);
					}
				} else {
					log.error("Error populating form", e);
					throw new ServletException(e);
				}
			}

My guess. (!!!) This form is almost a `DynaBean' before it was conceived,
because DefaultForm has an hash table. A hashtable is a fancy name for
a map. DynaBean' are infact mapped java beans. From the code above
the base Controller will populate the a Struts action form,
and only if there is an exception, will it attempt populate a
`DefaultForm' type.

However this is functional explanation. Why Mike N semantically used this class
is still mystery?

-- 
Peter Pilgrim
ServerSide Java Specialist

My on-line resume and for interview videos about myself, J2EE
Open Source, Struts and Expresso.
    ||
    \\===>  `` http://www.xenonsoft.demon.co.uk/no-it-striker.html ''




More information about the Opensource mailing list