[Opensource] Re: Controller and FormCache Legacy failure
Peter A. Pilgrim
peterp at xenonsoft.demon.co.uk
Thu Dec 26 21:48:29 PST 2002
Michael Rimov wrote:
> 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?
This is the eforum SearchForm which I used to store data about query
context. The solution is to check request scope first and if not found
then check session scope, as I did.
Or add a brand new `String Persistent.findAttribute( String key)' then
will actual do the above with one method call.
--
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