You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by piero de salvia <pi...@yahoo.com> on 2001/09/11 21:46:33 UTC

pull model design pattern question

Hi everybody,

I am transitioning from page-based systems (Cold
Fusion) to Velocity, and cannot figure out how to
insert the correct context data for a given page. In
page-based systems, (JSP, Cold Fusion etc) it is the
page itself that gets its own data, stuff like this:

<jsp:sqlquery>
select....
</jsp:sqlquery>

so each page gets its own data. 

But with Velocity, how do I the programmer, know what
data to put in context for a given page? the page
designer puts it in a property file that I read at
init time and put in a hash? kind of very clumsy...

piero de salvia


__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

Re: pull model design pattern question

Posted by Simon Christian <si...@cpd.co.uk>.

Jon Stevens wrote:
> 
> on 9/11/01 1:48 PM, "Simon Christian" <si...@stoutstick.com> wrote:
> 
> > Alternatively, you could have a context tool which simply runs SQL
> > queries for you, returning the ResultSet directly.
> >
> > #set( $myResultSet = $mySQLTool.runQuery( $aQuery ) )
> 
> I don't suggest working with RS directly. Work with lists of business
> objects instead. Please see my previous posting for examples. :-)
> 
> -jon

Ugh I had no intention of doing this in my own code just recognize it as
a way it *could be done*, but thanks for the warning anyways!

- simon

Re: pull model design pattern question

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/11/01 1:48 PM, "Simon Christian" <si...@stoutstick.com> wrote:

> Alternatively, you could have a context tool which simply runs SQL
> queries for you, returning the ResultSet directly.
> 
> #set( $myResultSet = $mySQLTool.runQuery( $aQuery ) )

I don't suggest working with RS directly. Work with lists of business
objects instead. Please see my previous posting for examples. :-)

-jon


Re: pull model design pattern question

Posted by Simon Christian <si...@stoutstick.com>.
I see two options in this kind of case (though I don't know if Velocity
is really the tool to use...heresy?) - if you're making fairly simply
queries, such as retrieving one record or a set of records (read Objects
if you need joins) then use one or more 'broker' objects to do the
interaction for you:

  #set( $myObj = $myObjBroker.getRecord( $aRecordId ) )

  #set( $myRecords = $myObjBroker.getRecordList( $aParameter ) )

Alternatively, you could have a context tool which simply runs SQL
queries for you, returning the ResultSet directly. 

  #set( $myResultSet = $mySQLTool.runQuery( $aQuery ) )

Can't say I'd be too keen on doing that mind you - I imagine designers
could come to terms with the previous method though.

Is this kind of thing the 'pull model'?

- simon

piero de salvia wrote:
> 
> Hi everybody,
> 
> I am transitioning from page-based systems (Cold
> Fusion) to Velocity, and cannot figure out how to
> insert the correct context data for a given page. In
> page-based systems, (JSP, Cold Fusion etc) it is the
> page itself that gets its own data, stuff like this:
> 
> <jsp:sqlquery>
> select....
> </jsp:sqlquery>
> 
> so each page gets its own data.
> 
> But with Velocity, how do I the programmer, know what
> data to put in context for a given page? the page
> designer puts it in a property file that I read at
> init time and put in a hash? kind of very clumsy...
> 
> piero de salvia
>

Re: pull model design pattern question

Posted by Bojan Smojver <bo...@binarix.com>.
piero de salvia wrote:
> 
> Hi everybody,
> 
> I am transitioning from page-based systems (Cold
> Fusion) to Velocity, and cannot figure out how to
> insert the correct context data for a given page. In
> page-based systems, (JSP, Cold Fusion etc) it is the
> page itself that gets its own data, stuff like this:
> 
> <jsp:sqlquery>
> select....
> </jsp:sqlquery>
> 
> so each page gets its own data.
> 
> But with Velocity, how do I the programmer, know what
> data to put in context for a given page? the page
> designer puts it in a property file that I read at
> init time and put in a hash? kind of very clumsy...

My understanding of the pull model is that the designer needs to be
informed about the things to pull. It is almost like an API for him/her,
and the API is mutually agreed between the programmer and the designer.
>From http://jakarta.apache.org/turbine/turbine-2/pullmodel.html:

--------------------------------------------------
Thus, it becomes the job of the template designer to understand the API
of objects available to him/her to take advantage of.
--------------------------------------------------

So, from the designer's point of view, it would be:

--------------------------------------------------
#foreach($piece in $ref.getFirstSetOfData())
  Do something with $piece
#end
--------------------------------------------------

and then on the other page:

--------------------------------------------------
#foreach($piece in $ref.getSecondSetOfData())
  Do something with $piece
#end
--------------------------------------------------

It enables the designer to switch those things around, embed them into
new pages if needed, use them for another project in exactly the same
way and so on.

This seems rather elegant to me :-)

Bojan

Re: pull model design pattern question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/11/01 8:04 PM, "Rickard Öberg" <ri...@xpedio.com> wrote:

> "Geir Magnusson Jr." wrote:
>> upcoming-if-it-ever-gets-out-of-CVS WebWork - come on Rickard, we want to
>> add #5 to the list :)
> 
> I was supposed to have released 1.0 yesterday, but then you-know-what
> happened which caught the attention of everyone here and not much was
> done at all.

It was a terrible day, and we have many more terrible days before us.

I was just tugging your chain - we would really like to see this :)

geir

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


Re: pull model design pattern question

Posted by Rickard Öberg <ri...@xpedio.com>.
"Geir Magnusson Jr." wrote:
> upcoming-if-it-ever-gets-out-of-CVS WebWork - come on Rickard, we want to
> add #5 to the list :) 

I was supposed to have released 1.0 yesterday, but then you-know-what
happened which caught the attention of everyone here and not much was
done at all.

/Rickard

-- 
Rickard Öberg
Software Development Specialist
xlurc - Xpedio Linköping Ubiquitous Research Center
Author of "Mastering RMI"
Email: rickard@xpedio.com

Re: pull model design pattern question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/12/01 5:22 AM, "Anthony Eden" <ae...@signaturedomains.com> wrote:

> In the case of JPublish you define an action which can be written in Java or
> any BSF supported scripting language (such as Python) and in the action you
> can place values into the context.
> 
> Naturally each framework is going to differ in the way that data is placed
> into the context, but they all have some sort of controller which actually
> places data into the context.  You definitely want to avoid placing business
> logic into your Velocity template (or any part of the view layer.)
> 
> (P.S. Gier, I noticed you put a question mark next to JPublish in your
> message.  Why?)

I wasn't sure how the project was going - I haven't looked in for a while to
see - and I don't want to give references to dead or abandoned things.

The bonus is that you piped in :)

geir

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


RE: pull model design pattern question

Posted by Anthony Eden <ae...@signaturedomains.com>.
In the case of JPublish you define an action which can be written in Java or
any BSF supported scripting language (such as Python) and in the action you
can place values into the context.

Naturally each framework is going to differ in the way that data is placed
into the context, but they all have some sort of controller which actually
places data into the context.  You definitely want to avoid placing business
logic into your Velocity template (or any part of the view layer.)

(P.S. Gier, I noticed you put a question mark next to JPublish in your
message.  Why?)

Sincerely,
Anthony Eden

-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Tuesday, September 11, 2001 5:37 PM
To: velocity-user@jakarta.apache.org
Subject: Re: pull model design pattern question


On 9/11/01 11:16 AM, "piero de salvia" <pi...@yahoo.com> wrote:

> OK Geir,
>
> and after I pull the Selects out of the templates,
> how do I associate the right data (be it a select or
> anything else) to be put in context for a given
> template?

Good - glad to see the notion of getting the stuff out of the templates was
acceptable to you :)

It's really can be a big shift in how you go about designing your web
application.  It takes a little more time up-front, but there are huge
benefits on the backside as your business and logic tends to no longer be
scattered among all of your pages.

Note that the following is just one way to do it.  There are many ways to do
it, and you should take a look at some of the frameworks that support
Velocity (such as Turbine, Melati, Jpublish (?) and he
upcoming-if-it-ever-gets-out-of-CVS WebWork - come on Rickard, we want to
add #5 to the list :) as they will show you how the MVC and other approaches
are done in practice.  You might even use one :)

One way many  people work with Velocity and other tools like it (WebMacro),
is that they change the application structure to have a servlet 'in front'
of the rendering (this is called the Controller) that manages the 'flow' of
the application, things like user authentication if needed, data management,
and view selection and rendering.

To answer the question, I tend to think of my apps in sections, and have a
set of data objects for each section.  I then stuff the context with
whatever data objects I need for that section (say, adding a new license in
a software license manager...), and then use what I need in the template.  I
think of this as a bit of lazyness on my one part, but it means it's very
easy to add additional pages.  Of course, I still modify the controller
servlet to choose that page when appropriate and render it, but that's
straightforward, and can actually be scripted externally if you wish.

Again, there are other ways to do this,  better than the cheap and dirty way
I described above, and I am sure the endless talent hanging around this list
will provide other and better examples.

The key to remember is that Velocity never intends to be more than a
templating tool - we make specific decisions to keep Velocity simple, to
keep the framework-ish features relegated to the frameworks (like Turbine.)
That said, it's simplicity makes it very flexible for your own application
framework if you choose to roll your own or integrate with existing apps.

geir


> piero
>
> --- "Geir Magnusson Jr." <ge...@optonline.net> wrote:
>> On 9/11/01 9:46 AM, "piero de salvia"
>> <pi...@yahoo.com> wrote:
>>
>>> Hi everybody,
>>>
>>> I am transitioning from page-based systems (Cold
>>> Fusion) to Velocity, and cannot figure out how to
>>> insert the correct context data for a given page.
>> In
>>> page-based systems, (JSP, Cold Fusion etc) it is
>> the
>>> page itself that gets its own data, stuff like
>> this:
>>>
>>> <jsp:sqlquery>
>>> select....
>>> </jsp:sqlquery>
>>>
>>> so each page gets its own data.
>>
>>>
>>> But with Velocity, how do I the programmer, know
>> what
>>> data to put in context for a given page? the page
>>> designer puts it in a property file that I read at
>>> init time and put in a hash? kind of very
>> clumsy...
>>
>>
>> One way, if you really want to continue with this,
>> embedding SQL in your
>> templates, you could easily create a toolset that
>> takes a string and returns
>> an object that contains the data from the resultset,
>> something like
>>
>> #set($data = $datatool.execute("SELECT name,
>> shoe_size, phone FROM thedata
>> WHERE....")
>>
>> #foreach( $row in $data )
>>   Hello $row.name
>> #end
>>
>> The general use-case with templates is to move away
>> from code right in the
>> templates (or even SQL code), and move to a set of
>> business objects provided
>> for the template designer.
>>
>> In your case, to make a smooth transition, you could
>> start with a tool do
>> make a direct transition from the current JSPs to
>> templates, and then begin
>> pulling pieces out of the templates...
>>
>> Hope that helps.
>>
>> geir
>>
>>
>> --
>> Geir Magnusson Jr.     geirm@optonline.net
>> System and Software Consulting
>> Developing for the web?  See
>> http://jakarta.apache.org/velocity/
>> If you look up, there are no limits - Japanese
>> Proverb
>>
>
>
> __________________________________________________
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with Yahoo!
Messenger
> http://im.yahoo.com

--
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


Re: pull model design pattern question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/11/01 11:16 AM, "piero de salvia" <pi...@yahoo.com> wrote:

> OK Geir,
> 
> and after I pull the Selects out of the templates,
> how do I associate the right data (be it a select or
> anything else) to be put in context for a given
> template?

Good - glad to see the notion of getting the stuff out of the templates was
acceptable to you :)

It's really can be a big shift in how you go about designing your web
application.  It takes a little more time up-front, but there are huge
benefits on the backside as your business and logic tends to no longer be
scattered among all of your pages.

Note that the following is just one way to do it.  There are many ways to do
it, and you should take a look at some of the frameworks that support
Velocity (such as Turbine, Melati, Jpublish (?) and he
upcoming-if-it-ever-gets-out-of-CVS WebWork - come on Rickard, we want to
add #5 to the list :) as they will show you how the MVC and other approaches
are done in practice.  You might even use one :)

One way many  people work with Velocity and other tools like it (WebMacro),
is that they change the application structure to have a servlet 'in front'
of the rendering (this is called the Controller) that manages the 'flow' of
the application, things like user authentication if needed, data management,
and view selection and rendering.

To answer the question, I tend to think of my apps in sections, and have a
set of data objects for each section.  I then stuff the context with
whatever data objects I need for that section (say, adding a new license in
a software license manager...), and then use what I need in the template.  I
think of this as a bit of lazyness on my one part, but it means it's very
easy to add additional pages.  Of course, I still modify the controller
servlet to choose that page when appropriate and render it, but that's
straightforward, and can actually be scripted externally if you wish.

Again, there are other ways to do this,  better than the cheap and dirty way
I described above, and I am sure the endless talent hanging around this list
will provide other and better examples.

The key to remember is that Velocity never intends to be more than a
templating tool - we make specific decisions to keep Velocity simple, to
keep the framework-ish features relegated to the frameworks (like Turbine.)
That said, it's simplicity makes it very flexible for your own application
framework if you choose to roll your own or integrate with existing apps.

geir


> piero
> 
> --- "Geir Magnusson Jr." <ge...@optonline.net> wrote:
>> On 9/11/01 9:46 AM, "piero de salvia"
>> <pi...@yahoo.com> wrote:
>> 
>>> Hi everybody,
>>> 
>>> I am transitioning from page-based systems (Cold
>>> Fusion) to Velocity, and cannot figure out how to
>>> insert the correct context data for a given page.
>> In
>>> page-based systems, (JSP, Cold Fusion etc) it is
>> the
>>> page itself that gets its own data, stuff like
>> this:
>>> 
>>> <jsp:sqlquery>
>>> select....
>>> </jsp:sqlquery>
>>> 
>>> so each page gets its own data.
>> 
>>> 
>>> But with Velocity, how do I the programmer, know
>> what
>>> data to put in context for a given page? the page
>>> designer puts it in a property file that I read at
>>> init time and put in a hash? kind of very
>> clumsy...
>> 
>> 
>> One way, if you really want to continue with this,
>> embedding SQL in your
>> templates, you could easily create a toolset that
>> takes a string and returns
>> an object that contains the data from the resultset,
>> something like
>> 
>> #set($data = $datatool.execute("SELECT name,
>> shoe_size, phone FROM thedata
>> WHERE....")
>> 
>> #foreach( $row in $data )
>>   Hello $row.name
>> #end
>> 
>> The general use-case with templates is to move away
>> from code right in the
>> templates (or even SQL code), and move to a set of
>> business objects provided
>> for the template designer.
>> 
>> In your case, to make a smooth transition, you could
>> start with a tool do
>> make a direct transition from the current JSPs to
>> templates, and then begin
>> pulling pieces out of the templates...
>> 
>> Hope that helps.
>> 
>> geir
>> 
>> 
>> -- 
>> Geir Magnusson Jr.     geirm@optonline.net
>> System and Software Consulting
>> Developing for the web?  See
>> http://jakarta.apache.org/velocity/
>> If you look up, there are no limits - Japanese
>> Proverb
>> 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
> http://im.yahoo.com

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


Re: pull model design pattern question

Posted by piero de salvia <pi...@yahoo.com>.
OK Geir,

and after I pull the Selects out of the templates, 
how do I associate the right data (be it a select or
anything else) to be put in context for a given
template?

piero

--- "Geir Magnusson Jr." <ge...@optonline.net> wrote:
> On 9/11/01 9:46 AM, "piero de salvia"
> <pi...@yahoo.com> wrote:
> 
> > Hi everybody,
> > 
> > I am transitioning from page-based systems (Cold
> > Fusion) to Velocity, and cannot figure out how to
> > insert the correct context data for a given page.
> In
> > page-based systems, (JSP, Cold Fusion etc) it is
> the
> > page itself that gets its own data, stuff like
> this:
> > 
> > <jsp:sqlquery>
> > select....
> > </jsp:sqlquery>
> > 
> > so each page gets its own data.
> 
> > 
> > But with Velocity, how do I the programmer, know
> what
> > data to put in context for a given page? the page
> > designer puts it in a property file that I read at
> > init time and put in a hash? kind of very
> clumsy...
> 
> 
> One way, if you really want to continue with this,
> embedding SQL in your
> templates, you could easily create a toolset that
> takes a string and returns
> an object that contains the data from the resultset,
> something like
> 
> #set($data = $datatool.execute("SELECT name,
> shoe_size, phone FROM thedata
> WHERE....")
> 
> #foreach( $row in $data )
>   Hello $row.name
> #end
> 
> The general use-case with templates is to move away
> from code right in the
> templates (or even SQL code), and move to a set of
> business objects provided
> for the template designer.
> 
> In your case, to make a smooth transition, you could
> start with a tool do
> make a direct transition from the current JSPs to
> templates, and then begin
> pulling pieces out of the templates...
> 
> Hope that helps.
> 
> geir
> 
> 
> -- 
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See
> http://jakarta.apache.org/velocity/
> If you look up, there are no limits - Japanese
> Proverb
> 


__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

Re: pull model design pattern question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/11/01 9:46 AM, "piero de salvia" <pi...@yahoo.com> wrote:

> Hi everybody,
> 
> I am transitioning from page-based systems (Cold
> Fusion) to Velocity, and cannot figure out how to
> insert the correct context data for a given page. In
> page-based systems, (JSP, Cold Fusion etc) it is the
> page itself that gets its own data, stuff like this:
> 
> <jsp:sqlquery>
> select....
> </jsp:sqlquery>
> 
> so each page gets its own data.

> 
> But with Velocity, how do I the programmer, know what
> data to put in context for a given page? the page
> designer puts it in a property file that I read at
> init time and put in a hash? kind of very clumsy...


One way, if you really want to continue with this, embedding SQL in your
templates, you could easily create a toolset that takes a string and returns
an object that contains the data from the resultset, something like

#set($data = $datatool.execute("SELECT name, shoe_size, phone FROM thedata
WHERE....")

#foreach( $row in $data )
  Hello $row.name
#end

The general use-case with templates is to move away from code right in the
templates (or even SQL code), and move to a set of business objects provided
for the template designer.

In your case, to make a smooth transition, you could start with a tool do
make a direct transition from the current JSPs to templates, and then begin
pulling pieces out of the templates...

Hope that helps.

geir


-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


Re: pull model design pattern question

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/12/01 4:50 PM, "Barbara Baughman" <ba...@utdallas.edu> wrote:

> How about returning an object that has:
> An array of column names
> A Vector of Vector-arrays representing the rows/values
> ?
> 
> Send this object to the template designers and let them play with
> #foreach to lay it all out.

That makes sense if you don't use Torque, however, when you are using
Torque, it is far simpler to just return an array of BO's because Torque
will generate and populate them for you based on your query.

P.s. We haven't even started to cover the submission of the form data back
to the server. :-)

p.p.s. I think I'm going to try to write an article for the JDC about all of
this. People are clearly doing things the hard way and that sucks when there
are much easier ways to accomplish the same thing. :-)

-jon


Re: pull model design pattern question

Posted by Barbara Baughman <ba...@utdallas.edu>.
How about returning an object that has:
An array of column names
A Vector of Vector-arrays representing the rows/values
?

Send this object to the template designers and let them play with
#foreach to lay it all out.

Something like that.  There are lots of creative ways to do this.  
Velocity itself doesn't care at all what kinds of objects you put in the
context, so don't feel limited to static views.

Barbara Baughman
X2157

On Wed, 12 Sep 2001, Lane Sharman wrote:

> Greetings,
> 
> Dynamic data objects get created when the user makes a request that results in
> dynamic sql assembly of a select statement. For example, suppose there are tables
> customer, invoice, line item, and inventory.
> 
> A web user (or swing user) could be provided an interface that resulted in a
> dynamic join:
> 
> a java code example:
> 
> String sqlStatement =  "select " +
>     + fieldList
>     + " from "
>     + tableList
>     + " where "
>     + joinClause
>     + " and "
>     + otherWhereCriteria
>     + " order by "
>     + orderBy;
> 
> 
> Now sqlStatement is syntactically correct.
> 
> The sql statement does not generate  a list of business objects, like an Invoice.
> Every element in fieldList is dynamic. The content in the ResultSet is unknowable
> until the actual time of the query so the resultant business object could not be
> compiled until the time of the query. Alternatively, a generic business object
> could have some generic methods and behavior but none that manipulated the field
> values directly except through dynamic meta query or introspection. That it is not
> how I think of an object like People below.
> 
> In short, I want to be able to give my users the ability to dynamically drill the
> db model without precompiling every possible "view".
> 
> thanks,
> 
> lane
> 
> Jon Stevens wrote:
> 
> > on 9/12/01 12:28 PM, "Lane Sharman" <la...@san.rr.com> wrote:
> >
> > > Greetings,
> > >
> > > This is an excellent contribution from Jon below and it helped me to
> > > understand the turbine pull model.
> >
> > Weird, I thought you already understood it.
> >
> > > However, I have an observation/question having been using sql and relational
> > > models for a long time and now merging this data in templates.
> >
> > Same here. :-)
> >
> > > Should a data query be attempted to be transformed to a business object if its
> > > entire existence, definition and scope is dynamically created for a single
> > > page?
> >
> > Yes.
> >
> > Why not?
> >
> > > For example, I have request arguments which produce a dynamic list of
> > > fields in which the scope of the fields might be a view of:
> > >
> > > 3 tables
> > > 15 fields
> > > a compound where and order by clause
> > >
> > > In other words, the data needed and requested, was produced through a dynamic
> > > query process and there is no way to predict in advance what the nature of the
> > > object would be.
> >
> > Once again: Huh?
> >
> > > Should dynamic data, query data formatted for a report be transformed into an
> > > object as well for template formatting?
> >
> > Once again: Huh?
> >
> > > In the above case, I use a result set transformation object containing a
> > > private Value[][] and MetaValue[] which maps the values from the ResultSet for
> > > presentment.
> >
> > What is the difference between your wrapper objects and a List of business
> > objects? (Other than your suggestion adds more complexity IMHO).
> >
> > -jon
> 
> --
> Lane Sharman
> http://corporate.acctiva.com/lane
> 
> 
> 


Re: pull model design pattern question

Posted by Lane Sharman <la...@san.rr.com>.
"Geir Magnusson Jr." wrote:

> On 9/13/01 7:23 PM, "Brian Goetz" <br...@quiotix.com> wrote:
>
> > On Thu, Sep 13, 2001 at 11:55:56AM -1000, Geir Magnusson Jr. wrote:
> >
> >> Meet him some time, and you will have a different mental voice in
> >> your head when you read what he writes.
> >
> > So what you're saying, Geir, is that you hear voices in your head, and
> > you think we would all benefit from hearing those same voices?  I
> > think there's a name for that...
> >
>
> Sometimes it's your voice, Brian...

and, thanks brian, geir for helping me to hear jons' voice ... as a result,
i have zero hard feelings and plan to move on with character ... as I hope
all people are attempting to do in these times.

-lane


Re: pull model design pattern question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/13/01 7:23 PM, "Brian Goetz" <br...@quiotix.com> wrote:

> On Thu, Sep 13, 2001 at 11:55:56AM -1000, Geir Magnusson Jr. wrote:
> 
>> Meet him some time, and you will have a different mental voice in
>> your head when you read what he writes.
> 
> So what you're saying, Geir, is that you hear voices in your head, and
> you think we would all benefit from hearing those same voices?  I
> think there's a name for that...
> 

Sometimes it's your voice, Brian...

geir

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


Re: pull model design pattern question

Posted by Brian Goetz <br...@quiotix.com>.
On Thu, Sep 13, 2001 at 11:55:56AM -1000, Geir Magnusson Jr. wrote:

> Meet him some time, and you will have a different mental voice in
> your head when you read what he writes.

So what you're saying, Geir, is that you hear voices in your head, and
you think we would all benefit from hearing those same voices?  I
think there's a name for that...

<disclaimer audience="humor-impaired">

  :)

</disclaimer>



RE: Velocity not finding the template... Urgent...

Posted by Paulo Gaspar <pa...@krankikom.de>.
LOL
You are inspired today Geir!

Paulo

> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Saturday, September 15, 2001 7:09 AM
>
> On 9/14/01 3:31 PM, "Paulo Gaspar" <pa...@krankikom.de> wrote:
>
> > Aren't you afraid Jon?
> > Apache is loosing another "paying customer"!!!
> > =;o)
> >
>
> NEW YORK (Bloomberg) : Today, the Jakarta Velocity project of the Apache
> Software Foundation announced that it was losing another paying customer.
> In accordance with Regulation FD (Fair Disclosure), the directors
> of Jakarta
> Velocity are required to make this information available to all investors.
>
> "While we feel that the long term outlook remains strong", said committer
> Geir Magnusson, "this will have a substantial impact in the near
> term due to
> general softness in the sector."
>
> Documents filed with the SEC indicate that losing that paying
> customer will
> affect gross revenue for the current quarter, reducing projected gross
> revenue to US$0, down from US$0.  No information was given with respect to
> net revenue or EBDITA.
>
> "Coupled with this reduction in revenue, we foresee a marginal increase in
> support costs", Magnusson said. "However, we still expect earnings in the
> US$0.00 to US$0.00 range for the 3rd quarter given the strong interest in
> the 1.2 release."
>
>
> > On 2nd thoughts, I guess he wants us to feel sorry for him because
> > he is going to go back to (argh) JSP.
> >
> > Thinking about it, I already feel sorry. That is why I feel this
> > urge to give some advise to Saurabh (and others posting the same
> > kind of questions) about the sophisticated methodology one must
> > follow in order to use Velocity. (It also works for another Open
> > Source projects, but most of them do not have such good
> > documentation as Velocity.)
> >
> > So, here goes the methodology - one just has to follow these steps
> > in order to solve any problem with the use of Velocity:
> > 1. Read the excellent Velocity documentation;
> > 2. For further doubts on "why are things this way" check the mail
> >   archives;
> > 3. For further doubts on "exactly how does this work", check the
> >   source code;
> > 4. When confused about one of the above steps, ask the list BUT
> >   please take the previous steps. You must take at least the
> >   step 1 and come up with smarter questions if you want us to
> >   sympathize and help you - meaning that you must be willing to
> >   help yourself first.
> >
> > Want some extra feature?
> > - You can always do it yourself and (hopefully, if it is a nice
> >  one) contribute it back to the project.
> >
> > Want someone to baby-sit you effortlessly trough the whole process
> > of using Velocity?
> > - Hire (means PAY) some consultant that knows Velocity. I think
> >  that Geir does consulting work.
> >  =;o)
> >
> > Remember: this is Open Source. Free as in free beer and free as in
> > free speech (although GNU sees it a bit different).
>
> Saurabh : welcome to our dysfunctional family...
>
> geir
>
> --
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> Developing for the web?  See http://jakarta.apache.org/velocity/
> If you look up, there are no limits - Japanese Proverb
>


Re: Velocity not finding the template... Urgent...

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/14/01 3:31 PM, "Paulo Gaspar" <pa...@krankikom.de> wrote:

> Aren't you afraid Jon?
> Apache is loosing another "paying customer"!!!
> =;o)
> 

NEW YORK (Bloomberg) : Today, the Jakarta Velocity project of the Apache
Software Foundation announced that it was losing another paying customer.
In accordance with Regulation FD (Fair Disclosure), the directors of Jakarta
Velocity are required to make this information available to all investors.

"While we feel that the long term outlook remains strong", said committer
Geir Magnusson, "this will have a substantial impact in the near term due to
general softness in the sector."

Documents filed with the SEC indicate that losing that paying customer will
affect gross revenue for the current quarter, reducing projected gross
revenue to US$0, down from US$0.  No information was given with respect to
net revenue or EBDITA.

"Coupled with this reduction in revenue, we foresee a marginal increase in
support costs", Magnusson said. "However, we still expect earnings in the
US$0.00 to US$0.00 range for the 3rd quarter given the strong interest in
the 1.2 release."


> On 2nd thoughts, I guess he wants us to feel sorry for him because
> he is going to go back to (argh) JSP.
> 
> Thinking about it, I already feel sorry. That is why I feel this
> urge to give some advise to Saurabh (and others posting the same
> kind of questions) about the sophisticated methodology one must
> follow in order to use Velocity. (It also works for another Open
> Source projects, but most of them do not have such good
> documentation as Velocity.)
> 
> So, here goes the methodology - one just has to follow these steps
> in order to solve any problem with the use of Velocity:
> 1. Read the excellent Velocity documentation;
> 2. For further doubts on "why are things this way" check the mail
>   archives;
> 3. For further doubts on "exactly how does this work", check the
>   source code;
> 4. When confused about one of the above steps, ask the list BUT
>   please take the previous steps. You must take at least the
>   step 1 and come up with smarter questions if you want us to
>   sympathize and help you - meaning that you must be willing to
>   help yourself first.
> 
> Want some extra feature?
> - You can always do it yourself and (hopefully, if it is a nice
>  one) contribute it back to the project.
> 
> Want someone to baby-sit you effortlessly trough the whole process
> of using Velocity?
> - Hire (means PAY) some consultant that knows Velocity. I think
>  that Geir does consulting work.
>  =;o)
> 
> Remember: this is Open Source. Free as in free beer and free as in
> free speech (although GNU sees it a bit different).

Saurabh : welcome to our dysfunctional family...

geir

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


RE: Velocity not finding the template... Urgent...

Posted by Paulo Gaspar <pa...@krankikom.de>.
Aren't you afraid Jon?
Apache is loosing another "paying customer"!!!
=;o)


On 2nd thoughts, I guess he wants us to feel sorry for him because
he is going to go back to (argh) JSP.

Thinking about it, I already feel sorry. That is why I feel this
urge to give some advise to Saurabh (and others posting the same
kind of questions) about the sophisticated methodology one must
follow in order to use Velocity. (It also works for another Open
Source projects, but most of them do not have such good
documentation as Velocity.)

So, here goes the methodology - one just has to follow these steps
in order to solve any problem with the use of Velocity:
 1. Read the excellent Velocity documentation;
 2. For further doubts on "why are things this way" check the mail
    archives;
 3. For further doubts on "exactly how does this work", check the
    source code;
 4. When confused about one of the above steps, ask the list BUT
    please take the previous steps. You must take at least the
    step 1 and come up with smarter questions if you want us to
    sympathize and help you - meaning that you must be willing to
    help yourself first.

Want some extra feature?
 - You can always do it yourself and (hopefully, if it is a nice
   one) contribute it back to the project.

Want someone to baby-sit you effortlessly trough the whole process
of using Velocity?
 - Hire (means PAY) some consultant that knows Velocity. I think
   that Geir does consulting work.
   =;o)

Remember: this is Open Source. Free as in free beer and free as in
free speech (although GNU sees it a bit different).

Have fun,
Paulo

> -----Original Message-----
> From: Jon Stevens [mailto:jon@latchkey.com]
> Sent: Saturday, September 15, 2001 12:23 AM
> To: velocity-user
> Subject: Re: Velocity not finding the template... Urgent...
>
>
> on 9/13/01 10:39 PM, "Saurabh Shukla" <sa...@cysphere.com> wrote:
>
> > hii,
> >
> > I am using Velocity-1.1 on RedHat 6.2.(rather trying to use), I
>  so far were
> > working on jsp's and this is the first time i am trying velocity.
> >
> >
> > My web-app is in /home/saurabh/htdocs. I have got a template index.vm in
> > htdocs. ie /home/saurabh/htdocs/index.vm
> >
> > getTemplate("index.vm") throws Resource not Found Exception.
> >
> > getTemplate("/home/saurabh/htdocs/index.vm") also throws
> Resource not Found
> > Exception.(This ideally should not happen)!!!!!!!!!
> >
> > How ever if i put index.vm in /home/saurabh/ Velocity finds my template.
>
> <http://jakarta.apache.org/velocity/developer-guide.html#Configuri
ng%20Resou
rce%20Loaders>

> Can any one please please please explain why is this happening ? Coz' if
> this is the way velocity works then i'll have to shift to jsp asap.

Try reading the documentation first and then make 'threats' later.

-jon


Re: Velocity not finding the template... Urgent...

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/13/01 10:39 PM, "Saurabh Shukla" <sa...@cysphere.com> wrote:

> hii,
> 
> I am using Velocity-1.1 on RedHat 6.2.(rather trying to use), I  so far were
> working on jsp's and this is the first time i am trying velocity.
> 
> 
> My web-app is in /home/saurabh/htdocs. I have got a template index.vm in
> htdocs. ie /home/saurabh/htdocs/index.vm
> 
> getTemplate("index.vm") throws Resource not Found Exception.
> 
> getTemplate("/home/saurabh/htdocs/index.vm") also throws Resource not Found
> Exception.(This ideally should not happen)!!!!!!!!!
> 
> How ever if i put index.vm in /home/saurabh/ Velocity finds my template.

<http://jakarta.apache.org/velocity/developer-guide.html#Configuring%20Resou
rce%20Loaders>

> Can any one please please please explain why is this happening ? Coz' if
> this is the way velocity works then i'll have to shift to jsp asap.

Try reading the documentation first and then make 'threats' later.

-jon


Velocity not finding the template... Urgent...

Posted by Saurabh Shukla <sa...@cysphere.com>.

hii,

I am using Velocity-1.1 on RedHat 6.2.(rather trying to use), I  so far were
working on jsp's and this is the first time i am trying velocity.


My web-app is in /home/saurabh/htdocs. I have got a template index.vm in
htdocs. ie /home/saurabh/htdocs/index.vm

getTemplate("index.vm") throws Resource not Found Exception.

getTemplate("/home/saurabh/htdocs/index.vm") also throws Resource not Found
Exception.(This ideally should not happen)!!!!!!!!!

How ever if i put index.vm in /home/saurabh/ Velocity finds my template.

Can any one please please please explain why is this happening ? Coz' if
this is the way velocity works then i'll have to shift to jsp asap.

Regards,
saurabh.


Re: pull model design pattern question

Posted by David Rees <dr...@runt.ebetinc.com>.
On Thu, Sep 13, 2001 at 11:55:56AM -1000, Geir Magnusson Jr. wrote:
> On 9/13/01 10:49 AM, "David Rees" <dr...@runt.ebetinc.com> wrote:
> 
> But lets not debate it here?

Sorry, one more message to clarify my position.  :-)
 
> I like Jon, I consider him a friend, I greatly respect the work has has put
> into innumerable open source projects.  I don't always agree with his style,
> and I know he doesn't always agree with mine, but it doesn't seem to be a
> problem.  And I have been on the receiving end.
> 
> Meet him some time, and you will have a different mental voice in your head
> when you read what he writes.

I don't hold any grudges against Jon hope to meet him someday.  Besides, the
work he does speaks for itself (it's top notch.) My previous post was meant
to say "Jon sometimes comes across as harsh, but take a deep breath and look
at what the message beneath and you'll understand.  Don't take it
personally!"

-Dave

RE: pull model design pattern question

Posted by Huy Do <hu...@tramada.com>.
> But lets not debate it here?
>
> I like Jon, I consider him a friend, I greatly respect the work
> has has put
> into innumerable open source projects.  I don't always agree with
> his style,
> and I know he doesn't always agree with mine, but it doesn't seem to be a
> problem.  And I have been on the receiving end.
>
> Meet him some time, and you will have a different mental voice in
> your head
> when you read what he writes.

I've never met him, but i still think he's alright (sucking up for future
needs :-P). Just don't try too hard making your questions sound more complex
then they are when you ask questions :-)

My thanks and appreciation extends to all who are involved with
Turbine/Velocity. I have learn't heaps on this list.

just my 2cents.

Huy


Re: pull model design pattern question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/13/01 10:49 AM, "David Rees" <dr...@runt.ebetinc.com> wrote:

> On Thu, Sep 13, 2001 at 09:24:39AM -0700, Lane Sharman wrote:
>> 
>> I don't quite understand why Jon on this list terrorizes people who are
>> trying to
>> learn. I hear he is a nice guy in person but he sure likes to alienate people
>> with his words and personal commentary over the net. Maybe one day he will
>> get
>> that the meaning of his words, when mean, mean something too.
> 
> I think that Jon means the best, but this is not the first time I've seen
> someone offended by Jon's "style" of writing.  In fact, it seems to happen
> quite frequently.  Whether the people reading his messages are too sensitive
> or Jon should be more tolerant of others is up to debate.  ;-)

But lets not debate it here?

I like Jon, I consider him a friend, I greatly respect the work has has put
into innumerable open source projects.  I don't always agree with his style,
and I know he doesn't always agree with mine, but it doesn't seem to be a
problem.  And I have been on the receiving end.

Meet him some time, and you will have a different mental voice in your head
when you read what he writes.

geir

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


Re: pull model design pattern question

Posted by David Rees <dr...@runt.ebetinc.com>.
On Thu, Sep 13, 2001 at 09:24:39AM -0700, Lane Sharman wrote:
> 
> I don't quite understand why Jon on this list terrorizes people who are trying to
> learn. I hear he is a nice guy in person but he sure likes to alienate people
> with his words and personal commentary over the net. Maybe one day he will get
> that the meaning of his words, when mean, mean something too.

I think that Jon means the best, but this is not the first time I've seen
someone offended by Jon's "style" of writing.  In fact, it seems to happen
quite frequently.  Whether the people reading his messages are too sensitive
or Jon should be more tolerant of others is up to debate.  ;-)

-Dave

Re: pull model design pattern question

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 9/13/01 6:24 AM, "Lane Sharman" <la...@san.rr.com> wrote:

> Thanks, Dennis. I was just trying to learn about whether there was a tool that
> would work with velocity that would support dynamic schemas which underly an
> analytic query (a join against multiple tables where the sql tables are joined
> at
> runtime).

If it works with Velocity, it works with WebMacro and works with lots of
other things - it wouldn't be a 'Velocity-specific' tool.
 
geir

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
Developing for the web?  See http://jakarta.apache.org/velocity/
If you look up, there are no limits - Japanese Proverb


Re: pull model design pattern question

Posted by Lane Sharman <la...@san.rr.com>.
Dennis Doubleday wrote:

> At 02:38 AM 9/13/01, you wrote:
>
> >"Hey Lane, how about making some sense and explain yourself clearly instead
> >of wasting all of our time with weird ramblings about weird off topic
> >stuff."
>
> Why do you feel the need to humiliate people who are trying to learn from you?

Thanks, Dennis. I was just trying to learn about whether there was a tool that
would work with velocity that would support dynamic schemas which underly an
analytic query (a join against multiple tables where the sql tables are joined at
runtime).

I don't quite understand why Jon on this list terrorizes people who are trying to
learn. I hear he is a nice guy in person but he sure likes to alienate people
with his words and personal commentary over the net. Maybe one day he will get
that the meaning of his words, when mean, mean something too.

thanks again.

-lane


Re: pull model design pattern question

Posted by Nick Bauman <ni...@cortexity.com>.
Another whitewash of the OS vs Free Software debate:

> 3) Open Source software is not, by definition, free software. I do try
> to make a living.

Depends on what you mean by "free". Making a living on what you do, versus 
what you've done is the difference between the free as in speech vs. free 
as in beer argument. You can make a living either way. 

I believe the former more condusive to better software, and, dare I say it, 
a better world. But that's just me.

-- 
Nick Bauman
3600 N. Dupont
Minneapolis, MN 55412
Mobile: (612) 232-7120
Home: (612) 522-0165


Re: pull model design pattern question

Posted by Lane Sharman <la...@san.rr.com>.
Jon Stevens wrote:

> on 9/13/01 7:00 AM, "Dennis Doubleday" <dd...@mail.yourfit.com> wrote:
>
> > At 02:38 AM 9/13/01, you wrote:
> >
> >> "Hey Lane, how about making some sense and explain yourself clearly instead
> >> of wasting all of our time with weird ramblings about weird off topic
> >> stuff."
> >
> > Why do you feel the need to humiliate people who are trying to learn from you?
>
> I'm not sure how my original response on this subject was offensive at all.

to set the record straight:

1) Someone other than me found jon's words humiliating.

2) My exact opening paragraph on a technical critique of velocity starts:

> Geir,
>
> First, as I hinted in my post, I really like the macro faciility in velocity.
> Velocity is a fine tool.
>
> The limitations as I see it in velocity (for me).

Characterizing my critique of bashing is just ridiculous and everyone who has read
my posts on webmacro or velocity knows I do not bash velocity.

3) Open Source software is not, by definition, free software. I do try to make a
living.

4) I am the author of a number of products. Things that are actually sold as well
as services so I do respect and understand the economics of the software market.

5) VeryLargeHashtable is open source and it is completely free to download. It now
powers the wiki engine to support the WebMacro community.

In closing, I wish, jon, that you would train your energies on more looming
challenges to the existence of java than continually attempting to put me down in
public. It reflects on you and it has a tendency to inhibit others from asking
questions for fear of being ridiculed in public by you.

-lane


Re: pull model design pattern question

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/13/01 7:00 AM, "Dennis Doubleday" <dd...@mail.yourfit.com> wrote:

> At 02:38 AM 9/13/01, you wrote:
> 
>> "Hey Lane, how about making some sense and explain yourself clearly instead
>> of wasting all of our time with weird ramblings about weird off topic
>> stuff."
> 
> Why do you feel the need to humiliate people who are trying to learn from you?

I'm not sure how my original response on this subject was offensive at all.
I spent about half an hour of my time documenting how to solve the problem
as well as YEARS of my time helping write code to solve problems so that you
can take advantage of the solutions (for free). So quickly you forget all of
that.

On the other hand, Lane has done an excellent job of trying to sell himself
on the lists (and in private email) by creating obscure documents on his
website that point to his commercial software (meaning that he tells you all
about his "cool thing" and then points you to his website where you can buy
it or read about it...not that reading about it makes any sense) as well as
attempting to bash our efforts here in Velocity land [1] and has flamed me
for creating Velocity in the first place.

[1] <http://lists.semiotek.com/archives/webmacro/2001-August/006572.html>

Needless to say, Lane is on my list as someone who takes and takes and never
gives anything worthwhile back.

> You know the tables and columns in the database and Torque has generated
> objects to map to them. If your business object is the product of a join
> which selects a subset of fields from among many tables, and the nature of
> the object is determined by input from the end user, then Torque hasn't
> (and could not have) generated any such object in advance.

Correct. However, handling that case is a fairly trivial thing to do and the
pull model (and Velocity) still supports getting a list of generic bean
objects that would allow you to easy implement this as needed.

-jon


Re: pull model design pattern question

Posted by Dennis Doubleday <dd...@mail.yourfit.com>.
At 02:38 AM 9/13/01, you wrote:

>"Hey Lane, how about making some sense and explain yourself clearly instead
>of wasting all of our time with weird ramblings about weird off topic
>stuff."

Why do you feel the need to humiliate people who are trying to learn from you?



>You know *exactly* the tables and columns in the database because you
>defined them in an XML file and used that to generate the code.

You know the tables and columns in the database and Torque has generated 
objects to map to them. If your business object is the product of a join 
which selects a subset of fields from among many tables, and the nature of 
the object is determined by input from the end user, then Torque hasn't 
(and could not have) generated any such object in advance.

-------------------------------------------------------------
Dennis Doubleday          email: dday@yourfit.com
yourfit.com, Inc.           web: http://www.yourfit.com/


Re: pull model design pattern question

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/12/01 8:47 PM, "Lane Sharman" <la...@san.rr.com> wrote:

> Jon,
> 
> You are not listening. Also, please stop using "duh" after asking me a
> question
> using your shorthand "huh". I am trying to be patient and explain to you what
> this important issue is all about .... quit adding a lot of noise to the
> thread
> signal.

How about me saying:

"Hey Lane, how about making some sense and explain yourself clearly instead
of wasting all of our time with weird ramblings about weird off topic
stuff."

> There are a suite of applications used in financials, statistical
> analysis, warehousing, and data analysis that state that the application
> programmer does not nor cannot know the field list to be subject to analysis.
> There is no possibility for saying
> 
>   public static synchronized List getFieldNames()
>   {
>     if (fieldNames_ == null)
>     {
>       fieldNames_ = new Vector();
>           fieldNames_.add("WordId");
>           fieldNames_.add("Word");
>           fieldNames_.add("Rating");
>           fieldNames_.add("Ignored");
>         }
>     return fieldNames_;
>   }
> 
> because the data object's field list under analysis is not known at compile
> time.

Torque maps objects to a database. That is why it is called an Object
Relational Tool. I believe I said this numerous times now.

You know *exactly* the tables and columns in the database because you
defined them in an XML file and used that to generate the code.

If the problem is something else that you are trying to solve, then once
again, you aren't making any sense and are posting about something totally
unrelated and off topic.

> It must be added in through an inspection of the accompanying meta schema, eg,
> direct access to java.sql.ResultSetMetaData or some wrapper or adapter of this
> object which accompanies every ResultSet:
> 
>   public static synchronized List getFieldNames()
>   {
>     if (fieldNames_ == null)
>     {
>       fieldNames_ = new Vector();
>       int fieldCount =  rsSchema.getColumnCount();
>       for (int i  == 0; i <fieldCount; i++) {
>           fieldNames_.add(new FieldDescriptor(rsSchema, i) );
>         }
>     return fieldNames_;
>   }
> 
> Do you have a class, FieldDescriptor, that takes a java.sql.ResultSetMetaData
> argument and int and builds a field descriptor on the fly that can be used
> subsequently in this manner ?

Yes. I originally wrote the class back in March 1999. It is actually quite
simple...take a look:

com.workingdogs.village.Schema

<http://share.whichever.com/viewcvs.cgi/village/com/workingdogs/village/Sche
ma.java?rev=1.10&content-type=text/vnd.viewcvs-markup>

> If not, then you need to make this extension to torque or whatever to allow
> for truly dynamic field and object construction in used in analytic
> applications.

Torque itself is used against known schema's. Village can be used to get you
the rest of the way. Torque uses Village under the covers to do quite a lot
of stuff. Adding methods to Torque's base objects to expose Village's Schema
in order to do what you need is trivial.

> Static O/R mapping is OK for static object models but does not
> cut it when you need when you get into data warehousing and analytics.

Of course you are the first person I have *ever* heard from that needed this
capability. 

In reality, most people design relational database using an attribute-like
system that allows you to dynamically represent any sort of data.

For example: Scarab's Attributes allows us to have any number of Attributes
and Attribute Options for an Issue. Here is some documentation for you to
read:

    <http://scarab.tigris.org/attributes.html>

-jon


Re: pull model design pattern question

Posted by Lane Sharman <la...@san.rr.com>.
Jon,

You are not listening. Also, please stop using "duh" after asking me a question
using your shorthand "huh". I am trying to be patient and explain to you what
this important issue is all about .... quit adding a lot of noise to the thread
signal. There are a suite of applications used in financials, statistical
analysis, warehousing, and data analysis that state that the application
programmer does not nor cannot know the field list to be subject to analysis.
There is no possibility for saying

    public static synchronized List getFieldNames()
    {
      if (fieldNames_ == null)
      {
        fieldNames_ = new Vector();
            fieldNames_.add("WordId");
            fieldNames_.add("Word");
            fieldNames_.add("Rating");
            fieldNames_.add("Ignored");
          }
      return fieldNames_;
    }

because the data object's field list under analysis is not known at compile
time.

It must be added in through an inspection of the accompanying meta schema, eg,
direct access to java.sql.ResultSetMetaData or some wrapper or adapter of this
object which accompanies every ResultSet:

    public static synchronized List getFieldNames()
    {
      if (fieldNames_ == null)
      {
        fieldNames_ = new Vector();
        int fieldCount =  rsSchema.getColumnCount();
        for (int i  == 0; i <fieldCount; i++) {
            fieldNames_.add(new FieldDescriptor(rsSchema, i) );
          }
      return fieldNames_;
    }

Do you have a class, FieldDescriptor, that takes a java.sql.ResultSetMetaData
argument and int and builds a field descriptor on the fly that can be used
subsequently in this manner ?

If not, then you need to make this extension to torque or whatever to allow for
truly dynamic field and object construction in used in analytic applications.
Static O/R mapping is OK for static object models but does not cut it when you
need when you get into data warehousing and analytics.

-lane


Jon Stevens wrote:

> on 9/12/01 5:25 PM, "Lane Sharman" <la...@san.rr.com> wrote:
>
> > what about a method to provide the field list as well? does that exist?
> >
> > -lane
>
> Duh. Of course.
>
> Here is an example of the generated code within Scarab's BaseWord.java class
> (which represents a table called "SCARAB_WORD").
>
>     /**
>      * Generate a list of field names.
>      */
>     public static synchronized List getFieldNames()
>     {
>       if (fieldNames_ == null)
>       {
>         fieldNames_ = new Vector();
>             fieldNames_.add("WordId");
>             fieldNames_.add("Word");
>             fieldNames_.add("Rating");
>             fieldNames_.add("Ignored");
>           }
>       return fieldNames_;
>     }
>
> There are actually several methods to deal with this, including methods to
> retrieve the data stored in the BO object based on field (ie: column) name.
>
> Before you ask more questions about what Torque methods get generated, go
> download Scarab, build it and take a look at the generated code. It gets
> generated into:
>
> scarab/target/webapps/scarab/WEB-INF/src/org/tigris/scarab/om
>
> Lastly, Torque's generated Java code is based on the execution of Velocity
> templates to output Java code. You can modify these yourself and add
> whatever helpful methods you need to the Base objects.
>
> thanks,
>
> -jon

--
Lane Sharman
http://corporate.acctiva.com/lane



Re: pull model design pattern question

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/12/01 5:25 PM, "Lane Sharman" <la...@san.rr.com> wrote:

> what about a method to provide the field list as well? does that exist?
> 
> -lane

Duh. Of course.

Here is an example of the generated code within Scarab's BaseWord.java class
(which represents a table called "SCARAB_WORD").

    /**
     * Generate a list of field names.
     */
    public static synchronized List getFieldNames()
    {
      if (fieldNames_ == null)
      {
        fieldNames_ = new Vector();
            fieldNames_.add("WordId");
            fieldNames_.add("Word");
            fieldNames_.add("Rating");
            fieldNames_.add("Ignored");
          }
      return fieldNames_;
    }

There are actually several methods to deal with this, including methods to
retrieve the data stored in the BO object based on field (ie: column) name.

Before you ask more questions about what Torque methods get generated, go
download Scarab, build it and take a look at the generated code. It gets
generated into:

scarab/target/webapps/scarab/WEB-INF/src/org/tigris/scarab/om

Lastly, Torque's generated Java code is based on the execution of Velocity
templates to output Java code. You can modify these yourself and add
whatever helpful methods you need to the Base objects.

thanks,

-jon


Re: pull model design pattern question

Posted by Lane Sharman <la...@san.rr.com>.
Jon Stevens wrote:

> on 9/12/01 1:59 PM, "Lane Sharman" <la...@san.rr.com> wrote:
>
> > Greetings,
> >
> > Dynamic data objects get created when the user makes a request that results in
>

<snip>

>
> > In short, I want to be able to give my users the ability to dynamically drill
> > the db model without precompiling every possible "view".
>
> Then you would have a method that would dynamically generate the Criteria
> based on the input for tables/columns from the user.

what about a method to provide the field list as well? does that exist?

-lane


Re: pull model design pattern question

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/12/01 1:59 PM, "Lane Sharman" <la...@san.rr.com> wrote:

> Greetings,
> 
> Dynamic data objects get created when the user makes a request that results in
> dynamic sql assembly of a select statement. For example, suppose there are
> tables
> customer, invoice, line item, and inventory.
> 
> A web user (or swing user) could be provided an interface that resulted in a
> dynamic join:
> 
> a java code example:
> 
> String sqlStatement =  "select " +
>   + fieldList
>   + " from "
>   + tableList
>   + " where "
>   + joinClause
>   + " and "
>   + otherWhereCriteria
>   + " order by "
>   + orderBy;

Thanks to Torque, I haven't written one of those in years now. :-)

> Now sqlStatement is syntactically correct.
> 
> The sql statement does not generate  a list of business objects, like an
> Invoice.

Why not? Torque would do that for you.

> Every element in fieldList is dynamic.

In Torque it isn't unless you write code specially to be that way.

> The content in the ResultSet is
> unknowable until the actual time of the query so the resultant business object
> could not be compiled until the time of the query. Alternatively, a generic
> business object could have some generic methods and behavior but none that
> manipulated the field values directly except through dynamic meta query or
> introspection. That it is not how I think of an object like People below.

Huh?

> In short, I want to be able to give my users the ability to dynamically drill
> the db model without precompiling every possible "view".

Then you would have a method that would dynamically generate the Criteria
based on the input for tables/columns from the user.

-jon


Re: pull model design pattern question

Posted by Lane Sharman <la...@san.rr.com>.
Greetings,

Dynamic data objects get created when the user makes a request that results in
dynamic sql assembly of a select statement. For example, suppose there are tables
customer, invoice, line item, and inventory.

A web user (or swing user) could be provided an interface that resulted in a
dynamic join:

a java code example:

String sqlStatement =  "select " +
    + fieldList
    + " from "
    + tableList
    + " where "
    + joinClause
    + " and "
    + otherWhereCriteria
    + " order by "
    + orderBy;


Now sqlStatement is syntactically correct.

The sql statement does not generate  a list of business objects, like an Invoice.
Every element in fieldList is dynamic. The content in the ResultSet is unknowable
until the actual time of the query so the resultant business object could not be
compiled until the time of the query. Alternatively, a generic business object
could have some generic methods and behavior but none that manipulated the field
values directly except through dynamic meta query or introspection. That it is not
how I think of an object like People below.

In short, I want to be able to give my users the ability to dynamically drill the
db model without precompiling every possible "view".

thanks,

lane

Jon Stevens wrote:

> on 9/12/01 12:28 PM, "Lane Sharman" <la...@san.rr.com> wrote:
>
> > Greetings,
> >
> > This is an excellent contribution from Jon below and it helped me to
> > understand the turbine pull model.
>
> Weird, I thought you already understood it.
>
> > However, I have an observation/question having been using sql and relational
> > models for a long time and now merging this data in templates.
>
> Same here. :-)
>
> > Should a data query be attempted to be transformed to a business object if its
> > entire existence, definition and scope is dynamically created for a single
> > page?
>
> Yes.
>
> Why not?
>
> > For example, I have request arguments which produce a dynamic list of
> > fields in which the scope of the fields might be a view of:
> >
> > 3 tables
> > 15 fields
> > a compound where and order by clause
> >
> > In other words, the data needed and requested, was produced through a dynamic
> > query process and there is no way to predict in advance what the nature of the
> > object would be.
>
> Once again: Huh?
>
> > Should dynamic data, query data formatted for a report be transformed into an
> > object as well for template formatting?
>
> Once again: Huh?
>
> > In the above case, I use a result set transformation object containing a
> > private Value[][] and MetaValue[] which maps the values from the ResultSet for
> > presentment.
>
> What is the difference between your wrapper objects and a List of business
> objects? (Other than your suggestion adds more complexity IMHO).
>
> -jon

--
Lane Sharman
http://corporate.acctiva.com/lane



Re: pull model design pattern question

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/12/01 12:28 PM, "Lane Sharman" <la...@san.rr.com> wrote:

> Greetings,
> 
> This is an excellent contribution from Jon below and it helped me to
> understand the turbine pull model.

Weird, I thought you already understood it.

> However, I have an observation/question having been using sql and relational
> models for a long time and now merging this data in templates.

Same here. :-)

> Should a data query be attempted to be transformed to a business object if its
> entire existence, definition and scope is dynamically created for a single
> page?

Yes.

Why not?

> For example, I have request arguments which produce a dynamic list of
> fields in which the scope of the fields might be a view of:
> 
> 3 tables
> 15 fields
> a compound where and order by clause
> 
> In other words, the data needed and requested, was produced through a dynamic
> query process and there is no way to predict in advance what the nature of the
> object would be.

Once again: Huh?

> Should dynamic data, query data formatted for a report be transformed into an
> object as well for template formatting?

Once again: Huh?

> In the above case, I use a result set transformation object containing a
> private Value[][] and MetaValue[] which maps the values from the ResultSet for
> presentment.

What is the difference between your wrapper objects and a List of business
objects? (Other than your suggestion adds more complexity IMHO).

-jon


Re: pull model design pattern question

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/12/01 1:24 PM, "Barbara Baughman" <ba...@utdallas.edu> wrote:

> I think the idea is to not allow template designers the ability to get
> free access to database information through template design.  Access to
> database information should be controlled by the application program.
> Let users give you a list of fields and tables and sorts, etc., build the
> SQL query in your program, execute it, and return the information.  The
> template designer should only be concerned with displaying the
> information.  It also means the template designer doesn't need to know
> SQL, which is programmer-type knowledge.
> 
> The politics of taking this ability away from the template folks may be
> difficult, and the programming logistics are certainly not trivial, but
> the philosophy above is very important the MVC model.
> 
> Barbara Baughman
> X2157

If you want to get to that level of control, that is very easy to do with
the tools/model that I documented earlier.

-jon


Re: pull model design pattern question

Posted by Barbara Baughman <ba...@utdallas.edu>.
I think the idea is to not allow template designers the ability to get
free access to database information through template design.  Access to
database information should be controlled by the application program.  
Let users give you a list of fields and tables and sorts, etc., build the
SQL query in your program, execute it, and return the information.  The
template designer should only be concerned with displaying the
information.  It also means the template designer doesn't need to know
SQL, which is programmer-type knowledge.

The politics of taking this ability away from the template folks may be
difficult, and the programming logistics are certainly not trivial, but
the philosophy above is very important the MVC model.

Barbara Baughman
X2157

On Wed, 12 Sep 2001, Lane Sharman wrote:

> Greetings,
> 
> This is an excellent contribution from Jon below and it helped me to understand
> the turbine pull model.
> 
> However, I have an observation/question having been using sql and relational
> models for a long time and now merging this data in templates.
> 
> Should a data query be attempted to be transformed to a business object if its
> entire existence, definition and scope is dynamically created for a single
> page? For example, I have request arguments which produce a dynamic list of
> fields in which the scope of the fields might be a view of:
> 
> 3 tables
> 15 fields
> a compound where and order by clause
> 
> In other words, the data needed and requested, was produced through a dynamic
> query process and there is no way to predict in advance what the nature of the
> object would be.
> 
> Should dynamic data, query data formatted for a report be transformed into an
> object as well for template formatting?
> 
> In the above case, I use a result set transformation object containing a
> private Value[][] and MetaValue[] which maps the values from the ResultSet for
> presentment.
> 
> -lane
> 
> Jon Stevens wrote:
> 
> > on 9/11/01 12:46 PM, "piero de salvia" <pi...@yahoo.com> wrote:
> >
> > > Hi everybody,
> > >
> > > I am transitioning from page-based systems (Cold
> > > Fusion) to Velocity, and cannot figure out how to
> > > insert the correct context data for a given page. In
> > > page-based systems, (JSP, Cold Fusion etc) it is the
> > > page itself that gets its own data, stuff like this:
> > >
> > > <jsp:sqlquery>
> > > select....
> > > </jsp:sqlquery>
> > >
> > > so each page gets its own data.
> > >
> > > But with Velocity, how do I the programmer, know what
> > > data to put in context for a given page? the page
> > > designer puts it in a property file that I read at
> > > init time and put in a hash? kind of very clumsy...
> > >
> > > piero de salvia
> >
> > You should never place SQL queries directly in a page. That is totally
> > against everything related to MVC because you are putting the business logic
> > of your application into the View portion of your page. What if you want to
> > run the same query on multiple pages? Do you copy/paste it? Use a #macro or
> > what? It is better to abstract that out into the Model/Controller.
> >
> > This is *exactly* why I hate JSP, ColdFusion, PHP, ASP, etc. They encourage
> > you to write applications which end up as a big spaghetti mess.
> >
> > In order to implement what you want, you need to use other tools to help you
> > get what you need and that is what we have been working on providing for the
> > last few years. Velocity is simply the View portion. A combination of tools
> > is what will get you the rest of the MC equation.
> >
> > That is why there are several web frameworks that have been developed to
> > help you get what you need. However, in this case above, what you need is
> > something like Torque to solve your problem. Torque gives you an Object
> > Relational view of your database as well as implements a persistence layer
> > so that it make it possible to save those objects back to the database.
> >
> > For example, say you have a database table that looks like this:
> >
> > People
> > ----------------
> > Id
> > Name
> > Address
> > Phone
> > ----------------
> >
> > You then have a Torque generated business object (based on the XML
> > description of the database) called "People" which has get/set methods for
> > each of the columns in the table.
> >
> > <table name="PEOPLE" idMethod="idbroker" javaName="People">
> >     <column name="ID" primaryKey="true" required="true"
> >         type="INTEGER"/>
> >     <column name="Name" primaryKey="false" required="true"
> >         type="VARCHAR"/>
> >     <column name="Address" primaryKey="false" required="false"
> >         type="VARCHAR"/>
> >     <column name="Phone" primaryKey="false" required="false"
> >         type="VARCHAR"/>
> > </table>
> >
> > Now, say you want to have all of the people within your database show up on
> > a page. In order to do that, you would add a method like this to your People
> > object:
> >
> > public List getAllPeople()
> > {
> >     return PeoplePeer.doSelect(new Criteria());
> > }
> >
> > This will return a List of populated People objects based on a default
> > 'blank' Criteria. The default is effectively this SQL query: "select * from
> > People". I believe that the BasePeople object (which People extends) might
> > already have this method in it so you may not even have to write it, but I'm
> > showing it here for completeness.
> >
> > Now, the problem is that you need to be able to get that People object into
> > the Context in a Pull fashion. In order to do that, you need a web framework
> > [1] which allows you to define a set of objects which get placed into the
> > Context within the various scopes (global/request/user). I generally like to
> > provide an API and encapsulate multiple objects into a single object. For
> > example, I would have an object that looks like the one below placed into
> > the Request context:
> >
> > public class RequestContextPullObject
> > {
> >     private People people = null;
> >
> >     public People getPeople()
> >     {
> >         if (people == null)
> >         {
> >             people = People.getInstance();
> >         }
> >         return people;
> >     }
> > }
> >
> > Now, this object would be made available in the Context for each request as
> > a $requestPull through the configuration of Turbine's Pull Service:
> >
> > services.PullService.tool.request.requestPull=org.foo.
> > RequestContextPullObject
> >
> > In the template, in order to get the list of all of the People, all you need
> > to do is:
> >
> > <table>
> > #foreach ($person in $requestPull.People.AllPeople)
> > <tr>
> >     <td>$person.Name</td>
> >     <td>$!person.Address</td>
> >     <td>$!persion.Phone</td>
> > </tr>
> > #end
> > </table>
> >
> > The beauty of this model is that your designers are given a simple API that
> > they can work from (the RequestContextPullObject) and there is zero logic
> > within your templates for doing SQL queries, etc. You can put that
> > #foreach() loop into a macro and display the list of all people in the
> > system on ANY template without having to modify any Java code to do so.
> >
> > Yes, this model is a bit more work than working with ColdFusion or PHP or
> > direct JSP. However, the end result is a cleaner application design which
> > can be re-used more easily and is more maintainable over the long term.
> >
> > This is exactly how Scarab is designed and we have found it to be an
> > exceptionally clean design.
> >
> > I hope that helps clear things up a bit.
> >
> > -jon
> >
> > [1] <http://jakarta.apache.org/turbine/>
> 
> --
> Lane Sharman
> http://corporate.acctiva.com/lane
> 
> 
> 


Re: pull model design pattern question

Posted by Lane Sharman <la...@san.rr.com>.
Greetings,

This is an excellent contribution from Jon below and it helped me to understand
the turbine pull model.

However, I have an observation/question having been using sql and relational
models for a long time and now merging this data in templates.

Should a data query be attempted to be transformed to a business object if its
entire existence, definition and scope is dynamically created for a single
page? For example, I have request arguments which produce a dynamic list of
fields in which the scope of the fields might be a view of:

3 tables
15 fields
a compound where and order by clause

In other words, the data needed and requested, was produced through a dynamic
query process and there is no way to predict in advance what the nature of the
object would be.

Should dynamic data, query data formatted for a report be transformed into an
object as well for template formatting?

In the above case, I use a result set transformation object containing a
private Value[][] and MetaValue[] which maps the values from the ResultSet for
presentment.

-lane

Jon Stevens wrote:

> on 9/11/01 12:46 PM, "piero de salvia" <pi...@yahoo.com> wrote:
>
> > Hi everybody,
> >
> > I am transitioning from page-based systems (Cold
> > Fusion) to Velocity, and cannot figure out how to
> > insert the correct context data for a given page. In
> > page-based systems, (JSP, Cold Fusion etc) it is the
> > page itself that gets its own data, stuff like this:
> >
> > <jsp:sqlquery>
> > select....
> > </jsp:sqlquery>
> >
> > so each page gets its own data.
> >
> > But with Velocity, how do I the programmer, know what
> > data to put in context for a given page? the page
> > designer puts it in a property file that I read at
> > init time and put in a hash? kind of very clumsy...
> >
> > piero de salvia
>
> You should never place SQL queries directly in a page. That is totally
> against everything related to MVC because you are putting the business logic
> of your application into the View portion of your page. What if you want to
> run the same query on multiple pages? Do you copy/paste it? Use a #macro or
> what? It is better to abstract that out into the Model/Controller.
>
> This is *exactly* why I hate JSP, ColdFusion, PHP, ASP, etc. They encourage
> you to write applications which end up as a big spaghetti mess.
>
> In order to implement what you want, you need to use other tools to help you
> get what you need and that is what we have been working on providing for the
> last few years. Velocity is simply the View portion. A combination of tools
> is what will get you the rest of the MC equation.
>
> That is why there are several web frameworks that have been developed to
> help you get what you need. However, in this case above, what you need is
> something like Torque to solve your problem. Torque gives you an Object
> Relational view of your database as well as implements a persistence layer
> so that it make it possible to save those objects back to the database.
>
> For example, say you have a database table that looks like this:
>
> People
> ----------------
> Id
> Name
> Address
> Phone
> ----------------
>
> You then have a Torque generated business object (based on the XML
> description of the database) called "People" which has get/set methods for
> each of the columns in the table.
>
> <table name="PEOPLE" idMethod="idbroker" javaName="People">
>     <column name="ID" primaryKey="true" required="true"
>         type="INTEGER"/>
>     <column name="Name" primaryKey="false" required="true"
>         type="VARCHAR"/>
>     <column name="Address" primaryKey="false" required="false"
>         type="VARCHAR"/>
>     <column name="Phone" primaryKey="false" required="false"
>         type="VARCHAR"/>
> </table>
>
> Now, say you want to have all of the people within your database show up on
> a page. In order to do that, you would add a method like this to your People
> object:
>
> public List getAllPeople()
> {
>     return PeoplePeer.doSelect(new Criteria());
> }
>
> This will return a List of populated People objects based on a default
> 'blank' Criteria. The default is effectively this SQL query: "select * from
> People". I believe that the BasePeople object (which People extends) might
> already have this method in it so you may not even have to write it, but I'm
> showing it here for completeness.
>
> Now, the problem is that you need to be able to get that People object into
> the Context in a Pull fashion. In order to do that, you need a web framework
> [1] which allows you to define a set of objects which get placed into the
> Context within the various scopes (global/request/user). I generally like to
> provide an API and encapsulate multiple objects into a single object. For
> example, I would have an object that looks like the one below placed into
> the Request context:
>
> public class RequestContextPullObject
> {
>     private People people = null;
>
>     public People getPeople()
>     {
>         if (people == null)
>         {
>             people = People.getInstance();
>         }
>         return people;
>     }
> }
>
> Now, this object would be made available in the Context for each request as
> a $requestPull through the configuration of Turbine's Pull Service:
>
> services.PullService.tool.request.requestPull=org.foo.
> RequestContextPullObject
>
> In the template, in order to get the list of all of the People, all you need
> to do is:
>
> <table>
> #foreach ($person in $requestPull.People.AllPeople)
> <tr>
>     <td>$person.Name</td>
>     <td>$!person.Address</td>
>     <td>$!persion.Phone</td>
> </tr>
> #end
> </table>
>
> The beauty of this model is that your designers are given a simple API that
> they can work from (the RequestContextPullObject) and there is zero logic
> within your templates for doing SQL queries, etc. You can put that
> #foreach() loop into a macro and display the list of all people in the
> system on ANY template without having to modify any Java code to do so.
>
> Yes, this model is a bit more work than working with ColdFusion or PHP or
> direct JSP. However, the end result is a cleaner application design which
> can be re-used more easily and is more maintainable over the long term.
>
> This is exactly how Scarab is designed and we have found it to be an
> exceptionally clean design.
>
> I hope that helps clear things up a bit.
>
> -jon
>
> [1] <http://jakarta.apache.org/turbine/>

--
Lane Sharman
http://corporate.acctiva.com/lane



Re: pull model design pattern question

Posted by Bojan Smojver <bo...@binarix.com>.
piero de salvia wrote:

> Do I put People and Beers in EVERY request? page2
> won't use People and page1 won't use Beers. This is no
> big deal for 2 business objects, but what about 2000?
> Maybe it's still acceptable, I don't know, this is
> totally new to me.

> 1.how do I do the partitioning without modifying the
> controller every time? Say the designer wants busin
> obj x on page/section y. I have to go into the servlet
> and add it (regression test, and evils like that)? or
> does the servlet look it up in a property file? or how
> ?

Place all objects in a Hashtable or something similar and only put that
into context. Then pick the correct ones from templates. Something like
($biz here is a Hashtable):

---------------------------------
#set($beers = $biz.beers)
#set($people = $biz.people)
---------------------------------

or if you don't want all those objects to initialise up front, this
approach could be useful ($biz here is your class that knows how to pick
other useful objects):

---------------------------------
#set($beers = $biz.getObject("beers"))
#set($people = $biz.getObject("people"))
---------------------------------

where getObject() would only really get make an instance of the ones
that are being used. Those objects could even be stored (serialized)
somewhere in a database.

Bojan

Re: pull model design pattern question

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/12/01 1:20 AM, "piero de salvia" <pi...@yahoo.com> wrote:

> Jon,
> 
> you actually gave me a very useful insight to
> Turbine's way of doing things. But do you put ALL you
> of your business objs in context?

Please read and study my previous email more closely. Print it out if you
have to. I explained this already.

That is what the RequestContextPullObject is all about. The Turbine Pull
system will put it into the Context for me for each request. You can scope
it so that it goes into the Context either on a global basis (ie: the object
is not re-created for each request), on a request basis (ie: the object IS
re-created for each request) or on a user basis (ie: the object is created
once for the session for the user).

> I mean, say I request:
> 
> www.xxx.com/aaa/bbb/page1.vm
> 
> which needs the People business obj, and
> 
> www.xxx.com/aaa/bbb/page2.vm
> 
> which needs the Beers business obj.
> 
> Do I put People and Beers in EVERY request? page2
> won't use People and page1 won't use Beers. This is no
> big deal for 2 business objects, but what about 2000?

No. The People object is not put into the context EVER! The only thing that
is put into the context is the RequestContextPullObject. If a template needs
access to the People object then it can PULL (key word there) the People
object out of the RequestContextPullObject.

> 1.how do I do the partitioning without modifying the
> controller every time? Say the designer wants busin
> obj x on page/section y. I have to go into the servlet
> and add it (regression test, and evils like that)? or
> does the servlet look it up in a property file? or how
> ?

That is why you need to use something like Turbine that implements the Pull
Model appropriately and allows you to do this without modifying the
controller (it is configuration file based).

> 2.the granularity of this partitioning is too large,
> and I still end up with tons of bus objs for a given
> section in context that I don't need. It seeems to me
> that the controller should know that page y needs
> exactly busin objs x, k, and z. Or maybe I still don't
> grasp the concept.

NO. You expose a single object which can PULL the information out as needed.

-jon


Re: pull model design pattern question

Posted by piero de salvia <pi...@yahoo.com>.
Jon,

you actually gave me a very useful insight to
Turbine's way of doing things. But do you put ALL you
of your business objs in context?

I mean, say I request:

www.xxx.com/aaa/bbb/page1.vm

which needs the People business obj, and

www.xxx.com/aaa/bbb/page2.vm

which needs the Beers business obj. 

Do I put People and Beers in EVERY request? page2
won't use People and page1 won't use Beers. This is no
big deal for 2 business objects, but what about 2000?
Maybe it's still acceptable, I don't know, this is
totally new to me.

This is also a question to Geir, because if I
logically partition an app into sections, it seems to
me that :

1.how do I do the partitioning without modifying the
controller every time? Say the designer wants busin
obj x on page/section y. I have to go into the servlet
and add it (regression test, and evils like that)? or
does the servlet look it up in a property file? or how
?

2.the granularity of this partitioning is too large,
and I still end up with tons of bus objs for a given
section in context that I don't need. It seeems to me
that the controller should know that page y needs
exactly busin objs x, k, and z. Or maybe I still don't
grasp the concept.

thanks for enlightening a layman like me. I will also
throw a party when I really learn Java programming.

piero

> example, I would have an object that looks like the
> one below placed into
> the Request context:
> 
> public class RequestContextPullObject
> {
>     private People people = null;
> 
....
> Now, this object would be made available in the
> Context for each request as
> a $requestPull through the configuration of
> Turbine's Pull Service:
> 
> 

__________________________________________________
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger
http://im.yahoo.com

Re: pull model design pattern question

Posted by Jon Stevens <jo...@latchkey.com>.
on 9/11/01 12:46 PM, "piero de salvia" <pi...@yahoo.com> wrote:

> Hi everybody,
> 
> I am transitioning from page-based systems (Cold
> Fusion) to Velocity, and cannot figure out how to
> insert the correct context data for a given page. In
> page-based systems, (JSP, Cold Fusion etc) it is the
> page itself that gets its own data, stuff like this:
> 
> <jsp:sqlquery>
> select....
> </jsp:sqlquery>
> 
> so each page gets its own data.
> 
> But with Velocity, how do I the programmer, know what
> data to put in context for a given page? the page
> designer puts it in a property file that I read at
> init time and put in a hash? kind of very clumsy...
> 
> piero de salvia

You should never place SQL queries directly in a page. That is totally
against everything related to MVC because you are putting the business logic
of your application into the View portion of your page. What if you want to
run the same query on multiple pages? Do you copy/paste it? Use a #macro or
what? It is better to abstract that out into the Model/Controller.

This is *exactly* why I hate JSP, ColdFusion, PHP, ASP, etc. They encourage
you to write applications which end up as a big spaghetti mess.

In order to implement what you want, you need to use other tools to help you
get what you need and that is what we have been working on providing for the
last few years. Velocity is simply the View portion. A combination of tools
is what will get you the rest of the MC equation.

That is why there are several web frameworks that have been developed to
help you get what you need. However, in this case above, what you need is
something like Torque to solve your problem. Torque gives you an Object
Relational view of your database as well as implements a persistence layer
so that it make it possible to save those objects back to the database.

For example, say you have a database table that looks like this:

People
----------------
Id
Name
Address
Phone
----------------

You then have a Torque generated business object (based on the XML
description of the database) called "People" which has get/set methods for
each of the columns in the table.

<table name="PEOPLE" idMethod="idbroker" javaName="People">
    <column name="ID" primaryKey="true" required="true"
        type="INTEGER"/>
    <column name="Name" primaryKey="false" required="true"
        type="VARCHAR"/>
    <column name="Address" primaryKey="false" required="false"
        type="VARCHAR"/>
    <column name="Phone" primaryKey="false" required="false"
        type="VARCHAR"/>
</table>

Now, say you want to have all of the people within your database show up on
a page. In order to do that, you would add a method like this to your People
object:

public List getAllPeople()
{
    return PeoplePeer.doSelect(new Criteria());
}

This will return a List of populated People objects based on a default
'blank' Criteria. The default is effectively this SQL query: "select * from
People". I believe that the BasePeople object (which People extends) might
already have this method in it so you may not even have to write it, but I'm
showing it here for completeness.

Now, the problem is that you need to be able to get that People object into
the Context in a Pull fashion. In order to do that, you need a web framework
[1] which allows you to define a set of objects which get placed into the
Context within the various scopes (global/request/user). I generally like to
provide an API and encapsulate multiple objects into a single object. For
example, I would have an object that looks like the one below placed into
the Request context:

public class RequestContextPullObject
{
    private People people = null;

    public People getPeople()
    {
        if (people == null)
        {
            people = People.getInstance();
        }
        return people;
    }
}

Now, this object would be made available in the Context for each request as
a $requestPull through the configuration of Turbine's Pull Service:

services.PullService.tool.request.requestPull=org.foo.
RequestContextPullObject

In the template, in order to get the list of all of the People, all you need
to do is:

<table>
#foreach ($person in $requestPull.People.AllPeople)
<tr>
    <td>$person.Name</td>
    <td>$!person.Address</td>
    <td>$!persion.Phone</td>
</tr>
#end
</table>

The beauty of this model is that your designers are given a simple API that
they can work from (the RequestContextPullObject) and there is zero logic
within your templates for doing SQL queries, etc. You can put that
#foreach() loop into a macro and display the list of all people in the
system on ANY template without having to modify any Java code to do so.

Yes, this model is a bit more work than working with ColdFusion or PHP or
direct JSP. However, the end result is a cleaner application design which
can be re-used more easily and is more maintainable over the long term.

This is exactly how Scarab is designed and we have found it to be an
exceptionally clean design.

I hope that helps clear things up a bit.

-jon

[1] <http://jakarta.apache.org/turbine/>