Web Oriented Object Framework

User Guide (Version 0.5b4)

Woof!
User Guide (Version 0.5b4)

Implementing the stubs

Let us start by implementing the simpler fibonacci/help URL. This is intended to simply display some informational text so the method itself does not need to do any processing. We therefore edit the method definition to be a no-op.

method help {} {
    # Nothing to be done other than rendering the template.
}

The help text itself will go into the view template for the URL. As seen in the console output earlier, this file is app/controllers/views/fibonacci-help-main.wtf. Open it in an editor and replace its content with the following text:

<p>
  A Fibonacci sequence is a sequence of integers that
  begins with the numbers 0 and 1 with subsequent numbers
  being the sum of the two prior numbers.
</p>

We would also like the title for our site to be set to reflect its purpose. So we add a line to our controller class to set the page title.

oo::class create FibonacciController {
    superclass ApplicationController
    constructor args {
        # Very important to pass arguments to parent
        next {*}$args
        pagevar set title "Fibonacci Generator"
    }
}

Now browsing to the URL http://localhost:8015/fibonacci/help brings up the following page in the browser.

Quick Start Example Page

No big deal, that's not much different from a static HTML page except that it is a HTML fragment as opposed to a full HTML page. We will implement something a little more dynamic - the generate page - in just a bit.

Before we do that however, let us imagine our application was a little larger and we had generated more than two stubs. The verify command helps us locate stubs that are still to be implemented.

C:\fibo> bowwow verify fibonacci 
FibonacciController: 
    Action method stubs: 
        generate

    View stubs:
        app/controllers/views/fibonacci-generate-main.wtf

or

~/fibo> tclsh scripts/wag.tcl verify fibonacci 
FibonacciController: 
    Action method stubs: 
        generate

    View stubs:
        app/controllers/views/fibonacci-generate-main.wtf

As we can see, the method generate and the corresponding view have still to be implemented. We will now go ahead and do just that.