void Extension::handleURLChange() { // Find the page IGui* gui = IGui::instance(); Wt::WApplication* app = Wt::WApplication::instance(); std::string pageName = "/"; std::string action = "view"; if (app->internalPathMatches("/page/")) { pageName = app->internalPathNextPart("/page/"); std::string pagePath = "/page/" + pageName + "/"; if (app->internalPathMatches(pagePath)) action = app->internalPathNextPart(pagePath); } dbo::Session& s = dbSession(); dbo::Transaction t(s); dbo::ptr<Model> page = s.find<Model>().where("name=?").bind(pageName); // Use it if (page) { ActionMap::const_iterator found = actionMap.find(action); if (found != actionMap.end()) { ((this)->*(found->second))(*page); // Call the action .. view/edit etc.. } else { Wt::WApplication::instance()->log("ERROR") << "No valid action for page " << page->getName() << " - " << "Action name " << action; // Default to view maybe ? gui->setBody("ERROR: No such action " + action ); } } else { gui->setBody("PAGE NOT FOUND: " + pageName); } t.commit(); }