void WMenuItem::setText(const WString& text) { if (!text_) { text_ = new WLabel(anchor()); text_->setTextFormat(Wt::PlainText); } text_->setText(text); if (!customPathComponent_) { std::string result; #ifdef WT_TARGET_JAVA WString t = text; #else const WString& t = text; #endif if (t.literal()) result = t.narrow(); else result = t.key(); for (unsigned i = 0; i < result.length(); ++i) { if (std::isspace((unsigned char)result[i])) result[i] = '-'; else if (std::isalnum((unsigned char)result[i])) result[i] = std::tolower((unsigned char)result[i]); else result[i] = '_'; } setPathComponent(result); customPathComponent_ = false; } }
ProductMenuItem::ProductMenuItem(const Product *product_) : WMenuItem::WMenuItem("", new ProductWidget(product_)) { _product = product_; // Create a good looking url. const boost::regex e("[^0-9a-zA-Z]"); std::string str = boost::regex_replace(_product->name(), e, "_"); setPathComponent(str); }