[Opensource] Re: Controller and FormCache Legacy failure

Michael Rimov rimovm at centercomp.com
Thu Dec 26 01:47:34 PST 2002


At 02:48 AM 12/25/2002 +0000, you wrote:
>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.

Hi Peter,

I'm not sure that is the correct fix since most often DefaultForm is stored 
in the request context and not the session.  getSession().getAttribute() 
retrieves the object stored in the request context.......

I think the solution is in your struts-config.xml file by changing the 
default  form-bean to request scope, not session scopr.... OR we can check 
both the request scope AND if not found, the session scope.

Does this make sense?
                                                         -Mike







More information about the Opensource mailing list