Re: setPageRefreshOnBacktrackEnabled problem?

Ondřej Čada <[email protected]> Fri, 27 Apr 2012 03:57:36 +0200
Newsgroups gmane.comp.web.webobjects.devel
Message-ID <[email protected]>
Chuck,

On Apr 26, 2012, at 9:18 PM, Chuck Hill wrote:

>> either setPageRefreshOnBacktrackEnabled does not work, or I am =
missing something fundamental.
> It works.  :-P

Well, so I am missing something of importance. Not a big surprise :)

>> In my session there is "SomeClass foo".
>> In one of my pages, there is (essentially) this:
>> =3D=3D=3D
>> <wo:if condition=3D$session.foo> OK <wo:str =
value=3D$session.foo.title/> </wo>
>> <wo:else>
>> <wo:hyperlink action=3D$selectFoo1>Foo1</wo>
>> <wo:hyperlink action=3D$selectFoo2>Foo2</wo>
>> </wo>
>> =3D=3D=3D
>>=20
>> with the actions trivial "WOComponent selectFoo1() { =
session().foo=3Dfoo1; return null; }" and similar with Foo2. (There is =
also a "select Foo" action in the OK part which does session().foo=3Dnull,=
 but that's not important here, it works perfectly.)
>>=20
>> It works perfectly -- till I use backtrack. With backtrack, it goes =
all wrong :(
>>=20
>> 1. page is opened, shows "Foo1 Foo2"
>> 2. "Foo1" is clicked, shows correctly the "OK Foo1.title" contents
>> 3. back button is used --> oops, shows again "Foo1 Foo2"!
>>=20
>> Here I probably am missing something -- given I have set =
pageRefreshOnBacktrackEnabled=3Dtrue, it should show still OK, since my =
session still contains non-null foo, should it not?
>=20
> Probably.  Is this the first access to your application?  If so, it =
could be making a new page instance each time.

Works consistently -- anytime I try the sequence, first or tenth time, =
the above's what happens.

>> Anyway, seems no part of my application gets activated at this =
moment; not even appendToResponse logs anything.
> Is anything getting to application.dispatchRequest()?

Nope, it is not. Nothing happens at 'back' at all, far as I can say. See =
also below.

>> 4. "Foo2" is clicked --> oops, shows again "OK Foo1.title"
>> whilst none of the selectFoo1/selectFoo2 actions is ever called. =
appendToResponse is called, though.
>=20
> That is consistent with setPageRefreshOnBacktrackEnabled(true).
>=20
>> What am I missing, and, more important, how to fix the problem? I =
don't care whether
>> (a) back keeps showing the "OK Foo1.title" contents (
>> (b) back goes to "Foo1 Foo2" AND selection works all right.
>>=20
>> I've googled out a trick based on contextID comparation, but that one =
fails with automatic refresh (which it considers to be same as "back") =
:(
>=20
> Check what is happening to the contextID when this is going on.

I've added logs above and below super.dispatchRequest. Also, I am =
logging from app and session appendToResponse, and from component's =
preAppendToResponse and postAppendToResponse. The logs look like this:

    public WOResponse dispatchRequest(WORequest rr) { // in Application
        println "-- WILL dispatch ${rr.context.contextID}"
        WOResponse re=3Dsuper.dispatchRequest(rr)
        println "-- DID dispatch ${rr.context.contextID}"
        re
    }
    public void appendToResponse(WOResponse response, WOContext context) =
{ // in both Application and Session
        def cid=3Dcontext.request.requestHandlerPathArray.lastObject // =
this is what...
        def n=3Dcid.indexOf('.')                                     // =
... I have found ...
        if (n>=3D0) cid=3Dcid.substring(0,n)                           =
// ... at the Web as a solution of the problem
        println "//// app-pre ${context.contextID}: $cid"          // =
session prefixes 'sess'
        super.appendToResponse(response,context)
        println "//// app-post ${context.contextID}: $cid"
    }
    protected void preAppendToResponse(WOResponse response, WOContext =
context) { // in Component
        def cid=3Dcontext.request.requestHandlerPathArray.lastObject
        def n=3Dcid.indexOf('.')
        if (n>=3D0) cid=3Dcid.substring(0,n)
        println "//// comp-pre ${context.contextID}: $cid LAST =
$_lastKnownCID known ${_knownCIDs.containsObject(cid)}, CM =
${sess.foo.title}"
    }
    protected void postAppendToResponse(WOResponse response, WOContext =
context) {
         _knownCIDs.addObject(_lastKnownCID=3Dcontext.contextID)
         println "//// comp-post ${context.contextID}: $_lastKnownCID, =
CM ${sess.footitle}"
    }


=3D=3D=3D first access of the page ... =3D=3D=3D
-- WILL dispatch null
//// app-pre 0: null
//// sess-pre 0: null
//// comp-pre 0: null LAST null known false, CM null
//// comp-post 0: 0, CM null
//// sess-post 1: null
//// app-post 1: null
-- DID dispatch null
-- WILL dispatch null
-- DID dispatch null
=3D=3D=3D ... shows foo selection | foo1 selection clicked ... =3D=3D=3D
-- WILL dispatch null
//// app-pre 2: 0
//// sess-pre 2: 0
//// comp-pre 2: 0 LAST 0 known true, CM aaa      // <=3D 'aaa' is the =
first foo.title
//// comp-post 2: 2, CM aaa
//// sess-post 2: 0
//// app-post 2: 0
-- DID dispatch null
-- WILL dispatch null
-- DID dispatch null
=3D=3D=3D ... shows correct OK:Foo1 | 'back' browser button tapped =
(nothing in log at all) ... =3D=3D=3D
=3D=3D=3D ... shows foo selection | foo2 selection clicked ... =3D=3D=3D
-- WILL dispatch null
//// app-pre 3: 0
//// sess-pre 3: 0
//// comp-pre 3: 0 LAST 2 known true, CM aaa
//// comp-post 3: 3, CM aaa
//// sess-post 3: 0
//// app-post 3: 0
-- DID dispatch null
-- WILL dispatch null
-- DID dispatch null
=3D=3D=3D ... shows still OK:Foo1 =3D=3D=3D

Thanks and all the best,
---
Ondra =C4=8Cada
OCSoftware:     [email protected]               http://www.ocs.cz
private         [email protected]             http://www.ocs.cz/oc