Thanks to everyone for the helpful comments.

As a new user, I definitely recommend this and similar info be added as a
HOWTO in the docs.

WILL

-----Original Message-----
From: Jeff Linwood [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 21, 2002 9:29 PM
To: Turbine Users List
Subject: Re: Implementing Pull MVC model


Thanks for pointing that out - I just spent a lot of time creating a HOWTO
for Using pull models in Turbine 2, based on that recent email. I didn't
know about the pull service HTML.

Well, here's what I wrote - I can put it into XDOC format if anyone is still
interested.


Using the pull model with Turbine 2



Turbine 2 can be used with two different programming models - the push model
and the pull model.  The difference is in how the Context is built up.  The
Context is used by the Velocity or WebMacro template files to "fill in the
blanks" and introduce dynamic data into a static HTML-based template.  This
programming concept is incredibly powerful - because it allows the web
designer, who may be experienced with HTML, CSS, and Javascript but not
Java, to put data fields wherever they want on a page without having to ask
the Java programmers to change a Java class and recompile.  For more
information on which to choose for your Turbine application, read Jon Steven
's informative commentary Push vs Pull.
http://jakarta.apache.org/turbine/turbine-2/pullmodel.html



The push model is found in the Flux/NewApp application that is distributed
with the TDK 2.1.  It is based on a one-to-one mapping of Java Screen
classes and Velocity template files.  The Screen class puts key/value pairs
into the Context.  The Context HowTo
http://jakarta.apache.org/turbine/turbine-2/howto/context-howto.html
explains this approach.



The pull model allows the web designer even more freedom than the push
model. Java programmers can create globally accessible Java classes known as
Tools.   These Tools are going to be useful for getting data out of a
service and bringing it to the presentation layer, authenticating users, or
creating links (see the TemplateLink tool that is built into Turbine).



Your SimpleSecurityTool should implement ApplicationTool, which is a simple
interface with two methods, init(Object data) and refresh.  It could be a
facade class that calls other classes, or it could have its own business
logic.



To make the Tool available to Turbine, you need to define your Tools in the
TurbineResources.properties file.  The "Pull Service" section of the
properties file is where the tools are listed.  You can use the following
syntax (all explained in the TurbineResources.properties):



tool.<Scope>.<Id> = <Classname>



tool.request.formsTool = com.yourcompany.turbine.tools.SimpleFormsTool



Classname is your java classname -
com.yourcompany.turbine.tools.SimpleFormsTool



Id is a unique identifier that you will use in your Velocity templates -
formsTool, for instance.



Scope defines the life cycle of the Tool.  There are four, global, request,
session, and persistent.



Global: The tool is instantiated once and is available to all templates for
all requests. Must be threadsafe.



Request: The tool is instantiated once for every request to Turbine.
Doesn't need to be threadsafe.  The link, page, and flux tools are all
defined as request scope.

Session: The tool is instantiated once for each user session. Should be
threadsafe.  Useful for tools that might hold user profiles, or items in a
shopping cart.



Persistent: Tool is instantiated once for each user session, and is stored
along with the user information.  Must be threadsafe and implement
Serializable.  An example of how this scope would be used would be great!



Additional tool-defined properties can be configured in the
TurbineResources.properties. The syntax is defined under the "Pull Service"
section.



----- Original Message -----
From: "Rodney Schneider" <[EMAIL PROTECTED]>
To: "Turbine Users List" <[EMAIL PROTECTED]>
Sent: Monday, January 21, 2002 10:24 PM
Subject: Re: Implementing Pull MVC model


> Hi,
>
> Also see:
>
> <http://jakarta.apache.org/turbine/turbine-2/services/pull-service.html>
>
> Regards,
>
> -- Rodney
>
> --
> To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
>


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


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

Reply via email to