Boost logo

Boost Users :

From: Ray Burkholder (ray_at_[hidden])
Date: 2008-05-26 06:44:41


>
> I also want to change web development frameworks and will
> definitely be looking at C++ Web Tool Kit. I want something
> cross platform but it must support html templates. Please read on...

I used Mason with Perl a while ago for web development. It follows a
template philosophy. However, with Wt, and the new 'dynamic' style web
pages, you may need to change your thinking on how to implement your
desires.

>
> I've looked at quite a bunch of C++ web development kits and
> one thing that I definitely don't like is mixing html with C++ code.

I think this is the 'old' way of thinking. Rather than thinking of pages as
HTML coded constructs, think of them of collection of objects. When you
think of them in that perspective, suddenly the applicability of the object
oriented capabilities of C++ become apparent and very applicable.

For example, if you consider a web page loosely defined as header, left,
right, footer, and mid-content, with each described as an object, C++ with
its object composition and inheritance capabilities, a web page can be mixed
and matched from a series of more static objects along with some dynamic
objects.

>
> The only systems that I've worked with and found are:
> Microsoft ATL Server and VBMcgi. They both have their good
> and bad points. One thing that they both allow you to do is
> to create 'templates' or 'stencils' which are your html web
> page or web form, etc.

If you do want something as a template structure, I did come across
http://www.tntnet.org/index.html once upon a time. That may be more along
the lines for what you search.

However, I think the better way of thinking of things is with the MVC
(Model-View-Controller). ASP.NET supposedly offers a form of MVC Framework.
How it is implemented, I’m not sure. The second picture down on
http://java.sun.com/blueprints/patterns/MVC-detailed.html has a nice detail
relationship of how the three components of MVC interact. If you allow
yourself the idea that you can encapsulate the View as C++ code rather than
as a stencil, and defining your business logic in the Model, and providing
user interface control through the Controller, you may find yourself with a
powerful concept for developing Web 2.0 type of dynamic applications,
something I don't think you could pull off with the Web 1.0 concept of
stencils and templates.

>
> In both of these frameworks, your C++ code NEVER mixes with
> html code. Of course, you can if you want, but that is very
> messy. I like keeping my interface totally separate from my
> business logic. Being able to completely modify the
> interface at any time without touching the app is an additional bonus.

In the MVC/Wt case, there is no HTML code, or very little if any. It is all
emitted through C++ objects. But, as stated before, MVC segregates your
code into the business logic side and the visual side. Which logically
leads into the ability to have multiple Views into one set of business
logic.

>
> I wrote this app here:
>
> http://app.directcorrespondentlender.com
>
> Please note that all business logic is in C++ and all
> interface files consists of a single html file (plus a css
> file for styling, and a javascript file for ensuring that
> basic field formatting, i.e. $250,000). All logic is in C++,

In addition to encapsulating HTML, it encapsulates a bunch of Javascript as
well. In addition, it has built in objects for field validation for server
as well as client side.

> the drawback is that it is in MS ATL Server, thus not cross
> platform, plus its design is not the best, MS took a
> backward, complicated approach in my opinion.

You'll find Wt to be cross platform. Rather than separate html source
files, you would be considering separate C++ class files for each web page.
Also in Web 2.0, as they call things now-a-days, HTML is passé'. CSS is the
way to 'visually' present a web page. You therefore have the following:
Model: contains the business logic which emits events to the View when it
needs to be changed
View: HTML/DOM (Document Object Model) queries the Model in response to
change events to update the objects in the interface
CSS: Visually organize and format the objects on the page

So in essence, or in a sense, HTML stencils have gone by the way side to be
replaced by program generated web pages (which are HTML under the hood
anyway) visually defined by CSS.

>
> While VBMcgi was designed well, I love its design but I don't
> like the way it was coded. They use their own string class
> for instance :( and cookie handling does not seem to work
> right for multiple valued cookies. That made me decide to
> stick with ATL Server even though I don't like the design at all.

Wt has a Wstring class by it is readily interchangeable with the STL string
capability. Session status is handled for you so cookies may not be so
important, but are there none-the-less.

>
> Does C++ Web Took Kit allow you to work with templates aka
> stencils? I am looking for alternatives.
>

See above for why templates/stencils may not be the 'modern' way of
thinking.

Ray.

-- 
Scanned for viruses and dangerous content at 
http://www.oneunified.net and is believed to be clean.

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net