World Library  
Flag as Inappropriate
Email this Article

Wt (web toolkit)

Article Id: WHEBN0024220883
Reproduction Date:

Title: Wt (web toolkit)  
Author: World Heritage Encyclopedia
Language: English
Subject: MooTools, Dojo Toolkit, Ext JS, DHTMLX, Pyjamas (software)
Collection: Ajax (Programming), Rich Internet Application Frameworks, Web Application Frameworks, Web Development Software, Web Server Software
Publisher: World Heritage Encyclopedia
Publication
Date:
 

Wt (web toolkit)

Wt
Original author(s) Emweb
Initial release 1.0.0 / Released December 2005
Stable release 3.3.4 / March 25, 2015 (2015-03-25)[1]
Written in C++
Operating system Any
Type Web application framework
License Dual License: GNU General Public License or Commercial License
Website /wt.eu.webtoolkitwww

Wt (pronounced "witty") is an open source widget-centric web application framework for the C++ programming language developed by Emweb. It has an API that resembles the C++ desktop application library Qt, also using a widget tree and event-driven signal/slot programming model.

The goal of the library is to benefit from the stateful component model used in desktop applications APIs, applied to web development, instead of the traditional model–view–controller (MVC) model. Rather than using MVC at the level of a page, MVC is pushed to the level of individual components.

While the library uses a desktop application development model, it does support web-specific features including semantic URLs and browser history navigation support.

A unique feature of the library is its abstraction layer of the browser rendering model. The library uses Ajax for communicating with Ajax-capable browsers, while using plain HTML form post-backs for other user agents. Using a progressive bootstrap method, the user interface is initially rendered as plain HTML, and for Ajax-capable browsers, it is automatically upgraded to use Ajax for increased interactivity. In this way, it is the only server-side framework that implements progressive enhancement automatically, and the only Ajax framework with search engine optimization (SEO) qualities.

Because of the popularity of C/C++ in embedded system environments, the library is often used in such devices, and has been highly optimized for performance as a consequence.

Contents

  • Major features 1
  • Code example 2
  • See also 3
  • References 4
  • External links 5

Major features

See the feature list on the project homepage for a more detailed overview.

Code example

The Hello World! example full source code

#include 
#include 
#include 
#include 
#include 
#include 

// c++0x only, for std::bind
// #include 

using namespace Wt;

/*
 * A simple hello world application class which demonstrates how to react
 * to events, read input, and give feed-back.
 */
class HelloApplication : public WApplication
{
public:
  HelloApplication(const WEnvironment& env);

private:
  WLineEdit *nameEdit_;
  WText *greeting_;

  void greet();
};

/*
 * The env argument contains information about the new session, and
 * the initial request. It must be passed to the WApplication
 * constructor so it is typically also an argument for your custom
 * application constructor.
*/
HelloApplication::HelloApplication(const WEnvironment& env)
  : WApplication(env)
{
  setTitle("Hello world");                               // application title

  root()->addWidget(new WText("Your name, please ? "));  // show some text
  nameEdit_ = new WLineEdit(root());                     // allow text input
  nameEdit_->setFocus();                                 // give focus

  WPushButton *button
    = new WPushButton("Greet me.", root());              // create a button
  button->setMargin(5, Left);                            // add 5 pixels margin

  root()->addWidget(new WBreak());                       // insert a line break

  greeting_ = new WText(root());                         // empty text

  /*
   * Connect signals with slots
   *
   * - simple Wt-way
   */
  button->clicked().connect(this, &HelloApplication::greet);

  /*
   * - using an arbitrary function object (binding values with boost::bind())
   */
  nameEdit_->enterPressed().connect
    (boost::bind(&HelloApplication::greet, this));

  /*
   * - using a c++0x lambda:
   */
  // b->clicked().connect(std::bind([=]() { 
  //       greeting_->setText("Hello there, " + nameEdit_->text());
  // }));
}

void HelloApplication::greet()
{
  /*
   * Update the text, using text input into the nameEdit_ field.
   */
  greeting_->setText("Hello there, " + nameEdit_->text());
}

WApplication *createApplication(const WEnvironment& env)
{
  /*
   * You could read information from the environment to decide whether
   * the user has permission to start a new application
   */
  return new HelloApplication(env);
}

int main(int argc, char **argv)
{
  /*
   * Your main method may set up some shared resources, but should then
   * start the server application (FastCGI or httpd) that starts listening
   * for requests, and handles all of the application life cycles.
   *
   * The last argument to WRun specifies the function that will instantiate
   * new application objects. That function is executed when a new user surfs
   * to the Wt application, and after the library has negotiated browser
   * support. The function should return a newly instantiated application
   * object.
   */
  return WRun(argc, argv, &createApplication);
}

See also

References

  1. ^ http://www.webtoolkit.eu/wt/doc/reference/html/Releasenotes.html
  • Article in Dr Dobb's Journal, Feb 2008
  • Introductory article at CodeGuru, Jun 2008

External links

  • Wt Project Homepage
  • Saetta Web Server for web sites in C/C++ with and without Wt
This article was sourced from Creative Commons Attribution-ShareAlike License; additional terms may apply. World Heritage Encyclopedia content is assembled from numerous content providers, Open Access Publishing, and in compliance with The Fair Access to Science and Technology Research Act (FASTR), Wikimedia Foundation, Inc., Public Library of Science, The Encyclopedia of Life, Open Book Publishers (OBP), PubMed, U.S. National Library of Medicine, National Center for Biotechnology Information, U.S. National Library of Medicine, National Institutes of Health (NIH), U.S. Department of Health & Human Services, and USA.gov, which sources content from all federal, state, local, tribal, and territorial government publication portals (.gov, .mil, .edu). Funding for USA.gov and content contributors is made possible from the U.S. Congress, E-Government Act of 2002.
 
Crowd sourced content that is contributed to World Heritage Encyclopedia is peer reviewed and edited by our editorial staff to ensure quality scholarly research articles.
 
By using this site, you agree to the Terms of Use and Privacy Policy. World Heritage Encyclopedia™ is a registered trademark of the World Public Library Association, a non-profit organization.
 


Copyright © World Library Foundation. All rights reserved. eBooks from Project Gutenberg are sponsored by the World Library Foundation,
a 501c(4) Member's Support Non-Profit Organization, and is NOT affiliated with any governmental agency or department.