RE: Backtracking woes
RE: Backtracking woes
- Subject: RE: Backtracking woes
- From: <email@hidden>
- Date: Thu, 16 Sep 2004 13:01:21 +0200
- Thread-topic: Backtracking woes
Title: Re: Backtracking woes
Actually, WebObjects already does this for you. Each request, except for
the very first in a session, includes a sender ID which is the context ID used
when the page from which the request originates was
generated.
What
my code does is to store for each page the list of context IDs it was used in.
Optionally I store the state of the component for each of those IDs. When a request reaches the page I check the sender ID against the list of known context
IDs and restore the state if saved. If the context cannot be restored (e.g. one
backtracked past an operation commited to the database) I throw an exception
informing the user of the backtracking issue. I may also forbid backtracking by
allowing only requests whose sender IDs match the latest context ID from the
list.
More
drastic implementations do this at the session level. Thus no backtracking is
allowed at all. Also the use of multiple windows on one session is not possible as only linear browsing is possible. I find this excessive and try to
allow and handle backtracking whereever reasonable.
Pierre
What I do to keep the users honest is have a
hidden field that stores a different id for each response and look for that id
in the response:
public void
takeValuesFromRequest(WORequest request, WOContext context)
{
if (rrid.equals((String)request.formValueForKey("rrid")))
{
super.takeValuesFromRequest(request,
context);
}
}
public WOActionResults invokeAction(WORequest request,
WOContext context) {
if (rrid.equals((String)request.formValueForKey("rrid")))
{
return super.invokeAction(request,
context);
} else {
setErrorString("Your last action could not be processed.
While editing, wait
for the page to fully load before clicking any buttons,
and do not use your
browser's 'Back'
button.");
return this;
}
}
public void
appendToResponse(WOResponse response, WOContext context)
{
rrid =
String.valueOf(System.currentTimeMillis());
super.appendToResponse(response,
context);
}
On 9/16/04 3:41 AM,
"email@hidden" <email@hidden>
wrote:
Hi!
Have a look at the 'Client-side backtracking'
sample code on my web page (http://homepage.mac.com/I_love_my/webobjects.html).
This allows for detection of client-side backtracking. It also allows for
saving and restoring state upon backtracking. I.e. your resultSetCurrentPage
ivar can be returned to its previous value when the user
backtracks.
Pierre.
http://homepage.mac.com/I_love_my
<http://homepage.mac.com/I_love_my/webobjects.html>
-----Original
Message-----
From:
webobjects-dev-bounces+pierre.bernard=email@hidden [mailto:webobjects-dev-bounces+pierre.bernard=email@hidden]On
Behalf Of Benjamin Adair
Sent: Wednesday, September
15, 2004 10:33 PM
To: Apple WO-Dev
Subject: Backtracking woes
Hello all,
I'm getting bit by the whole backtracking thing. I've
created a simple web application to allow our webmaster to maintain
the users and groups for our web site which authenticates against a
MySQL database.
I'm finding pretty much that whenever
the user moves forward within the application logic and then
backtracks within the browser and attempts to do something else, the
application's state doesn't match and I'm having a difficult time
thinking of a way (short of setting the backtrack cache to 0 - which
doesn't really help so much when the browser doesn't refresh the page in
the first place and is so user-unfriendly) to work around things.
A specific example. I have a ivar, resultSetCurrentPage.
If the user proceeds to the 2nd page, which increments the
ivar, backtracks, and then attempts to edit a user listed on what
was the first page.. They'll end up editing the corresponding user
from the second page.
I have read through the following
chapter on backtracking:
http://developer.apple.com/documentation/WebObjects/Web_Applications/BacktrackingAndCache/chapter_6_section_1.html#//apple_ref/doc/uid/TP30000111
And have played with settings for
'pageRefreshOnBacktrackEnabled' and read through messages from the
list that I have saved over the past year and really am not finding
much luck.
It is interesting to me that Apple's Webmail
application seems to handle this properly.. You can read a message,
back track, select a different message to read and it loads
properly.
Do I need to reorganize my logic? Is there
something more I can do? Any suggestions and help would be greatly
appreciated.
TIA
Ben
**********************************************************************
This email and any files transmitted with it are intended solely for
the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the sender
of this message. (email@hidden)
This email message has been checked for the presence of computer
viruses; however this protection does not ensure this message is
virus free.
Banque centrale du Luxembourg; Tel ++352-4774-1; http://www.bcl.lu
**********************************************************************
_______________________________________________
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