Project

General

Profile

handler not get back events

Added by Thomas Lynch about 11 years ago

perhaps this is a bug, seems so, but you can tell me.

General description:

I have a internal path change handler set up to catch path change events. This appears to function well when all setInternalPath calls are set to generate events. Then browser 'back' buttons generate path change events, and setInternalPath calls generate events - both invoking my handler.

However, if I purposely call setInternalPath to not generate an event once, second operand false, then I never get events from the browser again.

More Detail

When the application changes the path there is no need to throw an event, as my application just changes the page directly. The wise Wt developers have given me a way to do this, setInternalPath has a second argument which if it is false, then no event is generated.

I'm very happy with this behavior, because now if a path change event comes to the handler I know it is from the browser, as my application doesn't make these. I can then compare the application path to the new path proposed and decide how to reply.

Here is the problem, if I call setInternalPath with a second argument of false once within my application, then after this Wt doesn't tell the path changed handler about path changes from the browser, except when the user backs up all the way to the authentication widget. However, if I always trigger events from the application on path changes (then I don't know where they come from) thus invoking the handler for everything - then Wt send events from the browser reliably from the browser too.

Specifics

I have code derived from the hangman example. This is in first application and I'm trying to understand the browser 'back' interaction. Here in the constructor for my application as per hangmanGame:

Wt::WApplication::instance()->internalPathChanged().connect(this, &myApplication::handlePathChange);

authWidget->processEnvironment();

...

And then in the handler I have put a message:

void myApplication::handlePathChange(const std::string &new_browser_path){

std::cout << "request to change path to (arg): " << new_browser_path << std::endl;

}

In google-chrome and in firefox:

in my application after the user logs in I get a login event (good) where in the login event handler I change the internal path to 'page1' without generating another event (false last argument on internalPathChange), then show a a simple page, page1, that has a button for going to a second page. Page1 displays correctly with the new internal path showing in the browser as /?_=page1 and the correct page contents shows with the button for getting to page2. All is good.

That button invokes a method that puts a message on the page and changes the internal path without generating an event (false last argument on internalPathChange) and the browswer. The browswer correctly shows the new path as /?_=page2 with the correct contents in the window. Life is grand.

Now while on page2 I hit the back button. The browswer then shows the link as /?_=page1 which is correct, however the contents is still that of page2. This is because the handler did not get invoked. In the stub showing above the message does not print, and in gdb if I set a break point on the handler, the debugger never hits the break point.

Now back in the browser if I hit page refresh, or refresh for a non-cashing refresh, the handler is still not invoked (no message and no break point trip), the browser still shows /?_=page1 --- however Wt shows the authentication widget again asking for a login and password (??). .. If I log in I am starting all over from the beginning of the application - the internal path change handler is never called.

Well now doing the experiment again, I go to page1, good, push the botton then go to page2, good, hit the back button and the browser says page1 but is showing page2 and no handler event as before --- then I go ahead and hit the back button a second time. Now the browser just shows 127.0.0.1:9090 as the path (correct) and finally the path change handler is invoked. YES! However, I never got to update the page on the first click of the back button.

Now as a last example, I go to page1, then to page2, all it good. Then back to page1 (same behavior as before still showing page2 contents with a page1 link) then forward to page2 .. then the browser link window shows /?_=page2 as it should, and as the contents never changed it is correct for page2. However, there is never a internal path change event handler invocation. I can go back and forth as many times as I like and the link shows correctly in the browser, but I never get an internalPathChanged event - or at least the handler is never invoked.

What the heck am I doing wrong here?


Replies (1)

RE: handler not get back events - Added by Koen Deforche about 11 years ago

Hey,

This is the same problem mentioned in #2418 ?

Regards,

koen

    (1-1/1)