[Opensource] Re: Controller and FormCache Legacy failure

Peter A. Pilgrim peterp at xenonsoft.demon.co.uk
Tue Dec 24 18:48:26 PST 2002


Peter A. Pilgrim wrote:

--////--

> Is any body actually using the form cache. I think this is legacy from
> Expresso 2 before the Struts Integration. Any one who using the form cache
> should be using action forms stored in the session scope instead.
> 
> When I look in the ControllerResponse.java:932 at the error code.
> 
>         DefaultForm myForm = (DefaultForm) 
> getRequest().getSession().getAttribute(
>                 formKey);
> 
>         if (myForm == null) {
>             throw new ControllerException("No ActionForm found for key '" +
>                     formKey + "' in session.");
>         }
> 
> getRequest() returns a ControllerRequest object
> getSession() returns a PersistentSession object
> 

I found the bugfix. It is in the ControllerResponse.java: 932

	DefaultForm myForm = (DefaultForm)getRequest().getSession().getAttribute(formKey);
	if (myForm == null)
	    myForm = (DefaultForm) getRequest().getSession().getPersistentAttribute(formKey);
	if (myForm == null) {
		throw new ControllerException("No ActionForm found for key '" +
				formKey + "' in session.");
	}

The default form should be retrieved using `getPersistentAttribute(formKey)' instead.

In fact I was thinking should `PersistentSession' be extended.

public String findAttribute( String name )
{
    String value = getAttribute( name );
    if ( value == null ) value = getPersistentAttribute( name );
    return value;
}

-- 
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