[SOLVED]Antw: Re: Problem with pages saved in a variable
[SOLVED]Antw: Re: Problem with pages saved in a variable
- Subject: [SOLVED]Antw: Re: Problem with pages saved in a variable
- From: "Andri vonAllmen" <email@hidden>
- Date: Wed, 14 Oct 2009 10:03:01 +0200
Hi Stephane,
The reason for not using the WO caching mechanism was, that I'm maintaining a application which has "pageWithName" methods ad infinitum and this method does always create a new instance of a page (please do correct me, if this is not true), which is not the behaviour I want it to have (I want it to check the cache first).
Thank you for responding,
Andri
>>> Stephane Guyot <email@hidden> schrieb am Mittwoch, 14. Oktober
2009 um 09:16 in Nachricht <email@hidden>:
> Andri,
>
> I don't what exactly you want do, but have a look on API Session :
> restorePageForConextID, savePage, savePageInPermanentCache.
> You can start to override this API and just log, to understand how
> WebObjects works with pages and contextIDs.
>
> HTH,
> Stephane
>
>
> Le 13 oct. 09 à 10:29, Andri vonAllmen a écrit :
>
>>
>> Dear List,
>>
>> in an Applications Session, a NSMutableDictionary object is used for
>> "caching" pages. Everytime the "pageWithName" method is called, the
>> dictionary is queried in order to determine if the requested page does
>> already exist, if true the existing page is returned, else a new
>> one is
>> generated and stored in the dictionary. This is made in
>> Application.java
>> by overriding the "pageWithName" method:
>>
>> public WOComponent pageWithName(String aName, WOContext aContext) {
>> Object result = null;
>> if ( aContext.hasSession() ) result =
>> ((NSMutableDictionary)((Session)aContext.session()).cachedPages
>> ()).objectForKey(aName);
>> if ( result == null ) {
>> result = super.pageWithName(aName, aContext);
>> if ( aContext.hasSession() ) if ( aName != null )
>> ((NSMutableDictionary)((Session)aContext.session()).cachedPages
>> ()).setObjectForKey(result,
>> aName);
>> }
>> return (WOComponent)result;
>> }
>>
>> This works with one exception. Making changes on Enterprise Objects is
>> not possible in every case. Saving changes works, if always the same
>> object is changed but not if two different objects are changed
>> (changing
>> the first, saving the changes, then changing the second and saving the
>> changes). But if making changes on a object, saving it, and then
>> revert
>> the changes (to the same state as before changing it the first time),
>> making changes on other objects is possible.
>>
>> As mentioned in the WO API Reference, for pages being stored in a
>> variable the "ensureAwakeInContext" method has to be called, but this
>> has no effect. Same if refreshing the objects in the default editing
>> context ("refreshAllObjects", "refaultAllObjects") which is used on
>> all
>> pages.
>>
>> Any suggestions or other hints would be appreciated.
>>
>> Regards
>> Andri
>>
>>
>> --- Disclaimer:
>> --------------------------------------------------------- This
>> email and
>> contents is for use only by the intended recipient. If you are not the
>> individual or entity to whom it is addressed, you are hereby formally
>> notified that any use, copying or distribution of this email and
>> attachments, in whole or in part, is strictly prohibited. If you have
>> received this email in error, please notify the sender and delete the
>> message and attachment(s) from your system. Any views, opinions or
>> information, expressed or contained in this email, are those of the
>> sender and not necessarily reflect those of CEDES. To help protect our
>> environment, please avoid printing out this information unnecessarily.
>> _______________________________________________
>> Do not post admin requests to the list. They will be ignored.
>> Webobjects-dev mailing list (email@hidden)
>> Help/Unsubscribe/Update your Subscription:
>> email@hidden
>>
>> This email sent to email@hidden
>>
>
> IBCM : International Bank of Chatenay-Malabry http://www.kiva.org/
> lender/stephane4127 - Click on Map View
--- Disclaimer: --------------------------------------------------------- This email and contents is for use only by the intended recipient. If you are not the individual or entity to whom it is addressed, you are hereby formally notified that any use, copying or distribution of this email and attachments, in whole or in part, is strictly prohibited. If you have received this email in error, please notify the sender and delete the message and attachment(s) from your system. Any views, opinions or information, expressed or contained in this email, are those of the sender and not necessarily reflect those of CEDES. To help protect our environment, please avoid printing out this information unnecessarily.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden