Project

General

Profile

Actions

Bug #2527

closed

Setting internalPath from internalPathChanged() slot

Added by Saif Rehman almost 11 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
12/30/2013
Due date:
% Done:

0%

Estimated time:

Description

Hi,

When a user manually enters a new internal path from the browser and when a slot of internalPathChanged() sets the internalPath, Wt::WApplication is updated with the new internalPath however the browser still shows the URL entered manually.

I tried with these settings

<tracking>Auto</tracking>
<reload-is-new-session>false</reload-is-new-session>

Files

SetPath.cpp (892 Bytes) SetPath.cpp Koen Deforche, 02/07/2014 09:39 PM
Actions #1

Updated by Koen Deforche almost 11 years ago

  • Status changed from New to InProgress
  • Assignee set to Koen Deforche
Actions #2

Updated by Koen Deforche almost 11 years ago

Hey,

I fail to reproduce this, possibly because I do not really understand your description. See attached a test case; how would you modify it or exercise it to reproduce the problem?

Regards,

koen

Actions #3

Updated by Saif Rehman over 10 years ago

Sorry, I forgot about this report. Here's the changed file.

To reproduce the problem.

  1. Make sure reloading/changing URL manually from browser won't start a new session
  2. Open the page from browser
  3. Manually change the internal path from the browser to /hatter/

The internal path will stay the same on the browser, yet the handlePathChanged slot function will remove '/hatter' from 'internalPath_'.

If you use the button 'click to find hatter', the '/hatter' would be properly removed from both, server and client.

#include <Wt/WApplication>
#include <Wt/WContainerWidget>
#include <Wt/WPushButton>
#include <Wt/WText>

using namespace Wt;

class MyApp : public WApplication
{
public:
    MyApp(const WEnvironment& env)
        : WApplication(env)
    {
        WPushButton* button = new WPushButton( "click to see alice", root() );
        button->clicked().connect( this, &MyApp::changePath );

        WPushButton* button2 = new WPushButton( "click to find hatter", root() );
        button2->clicked().connect( this, &MyApp::changeToWrongPage );

        internalPathChanged().connect( this, &MyApp::handlePathChange );

        std::cout << "init: ";
        handlePathChange(internalPath());
    }

    void changePath() { setInternalPath( "/alice/", true ); }
    void changeToWrongPage() { setInternalPath( "/hatter/", true ); }

    void handlePathChange( std::string path )
    {
        std::cout << "handlePathChange " << path << std::endl;

        //Remove /hatter from the internal path IF the internal path has /hatter in it
        if(path.find("/hatter") != std::string::npos)
        {
            setInternalPath(std::string(path).replace(path.find("/hatter"), 7, ""), false);
        }

        new WText( path, root() );
        new WBreak( root() );
    }
};

WApplication *createMyApplication(const WEnvironment& env)
{
    return new MyApp(env);
}

int main(int argc, char **argv)
{
    return WRun(argc, argv, &createMyApplication);
}
Actions #4

Updated by Koen Deforche over 10 years ago

  • Status changed from Feedback to Resolved
  • Target version set to 3.3.4

Hey,

A fix is in git.

Koen

Actions #5

Updated by Koen Deforche about 10 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF