At 17:44 30/06/02, someone wrote:
>I guess the underlying problem is I don't understand the relationship
>between actions, templates, screens and "page views" correctly.


See http://jakarta.apache.org/turbine/turbine-2/fsd.html for more info

or here is my idiots guide.....

When you fetch a web page in a browser you are making a request. What you 
get back is a page.

When an http request is made the thing that you want to happen is the 
action. This is what gets *done*. An action might typically do some change 
to the database, send some email, or whatever. Not all requests have an 
action though....You might just be displaying info in which case no action 
is required. I've been doing web apps for nearly seven years and the action 
here is the same as the action we used on those CGI scripts all that time 
ago even before Java 1.0 was released.

Typically a page that is requested is made up from a number of smaller 
sections such as a header, footer, and menu on the left.  The whole thing 
is a page (what you see in the browser). What goes where is controlled by a 
"Layout".  I have never changed the layout so know little about them. The 
layout will usually manipulate some navigation sections and the "screen". 
The screen is the important stuff on the page and is often different with 
each page. In contrast the header, footer, and menu are often the same no 
matter which page is displayed. (

We can look at a simple turbine app of mine (and my colleagues) as an example
http://www.owal.co.uk/oss_support/
It is not a lot more than the newapp which comes with the Turbine 
Development Kit tdk.
It is a simple database of companies that use, support, and develop Open 
Source Software.
(So if you want to shout out to the world that you are a Struts expert then 
submit your details :-)

There is a simple header with a pretty image and slogan. (This is defined 
in DefaultTop.vm  )
There is a simple footer with several pretty images and slogans. (This is 
defined in DefaultBottom.vm  )
There is a simple menu on the left defined in Menu.vm.

The rest of the page is a "screen".

So how do we say what goes in a screen?

Basically you say what template you want, and you usually do that by 
specifying it in the link.
Of course there is a default template (typically INdex.vm) but the 
principle is the same.

Select "search for a company" and you get a new page, with the same 
navigation tools, but a new screen.
The link is 
http://www.owal.co.uk/oss_support/servlet/newapp/template/CompanySearch.vm
which hopefully suggests to you that the template is "CompanySearch.vm"
CompanySearch.vm is a velocity file which like ASP or JSP is souped up html 
BUT it doesn't actually
figure out what goes there. There is no way to insert Java into a velocity 
page.

So how does the screen and the template get this information (the list of 
open source packages).
Well the "system" sees that CompanySearch.vm is needed here and 
automatically searches for
a java class called CompanySearch to "help" it. My class COmpanySearch goes 
to the database,
sees what it is supposed to offer the user, and inserts the necessary data 
into a thing called a context.
The context is basically the environment of the velocity template - it can 
"see" the context, and nothing else.

Click on one of the OSS packages listed such as "Apache Turbine" and you 
will reach this page

http://www.owal.co.uk/oss_support/servlet/newapp/template/CompanySearchResults.vm/pid/4

Here we have a new template, which results in a new page, but of course the 
navigation elements are the same.

CompanySearchResults displays the results of a search for a company (well 
duh!). It gets its info from a
java class "CompanySearchResults" which does the actual search. But what 
does it search on?
well it needs to have some parameter and in this case it is the package 
identifier (or "pid") which has the value 4.

The template doesn't care - it just knows that it is supposed to display a 
list of companies which some other code
will provide it through its context.




And that is all I am typing on the subject today. If people ask for it  I can

a) write more in the same way (but perhaps clearer)
b) discuss how to add new features to this app - eg a search by company 
location
c) Turn this application into a well documented super-newapp which could be 
used as an example of how to do things in Turbine.



Alex McLintock






Openweb Analysts Ltd, London: Software For Complex Websites 
http://www.OWAL.co.uk/
Free Consultancy for London Companies thinking of Open Source Software.


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to