Another approach is to dynamically add components to a page when it's first 
loaded and before it is put into the cache.
This is done by overriding the finishLoad() method and adding components to the 
page based on, say, the schema of a given database table. Have a look at 
IPageLoader.createImplicitComponent().

Two problems remain however:

1. Once the page has been loaded, it is put into the cache and cannot be 
modified dynamically anymore. If the schema of the database table changes, the 
page won't be updated unless it is flushed from the page cache and reloaded. 
Even if you flush the page out when needed, it still requires that your schema 
(or whatever model you use to compose your page) does not change too often. 
Otherwise it defeats the purpose of the page cache.

2. You may want to use the same page template for several database tables or 
models, each of which requiring different components to be added. Furthermore, 
you might not know in advance which and how many models you need. The solution 
I've used for this problem is to use a different page name (and thus a 
different page instance) for each of them but use the same base page 
class/template/spec.

Let me try to explain this:
You create a "template page" that will be the basis for all customized pages. 
Suppose it's named EditObject.

You have a database table, say MYTABLE, and you want to dynamically create a 
page based on EditObject that can be used to edit rows of the MYTABLE table.

The dynamically generated page will be called EditObject$MYTABLE but is not 
defined in your application, only the EditObject page is. This involves using a 
specific SpecificationResolverDelegate. This resolver will return the 
EditObject page template for all requests to pages whose name begins with 
EditObject$.

Then, in the finishLoad() method of the EditObject page, you extract the name 
of the database table from the name of the page (EditObject$MYTABLE) and 
dynamically add components to the page based on the schema of said table.

Sorry in advance if it's not crystal clear. I'm usually better at writing code 
than English. ;)

Raphael Jean
EntropySoft

> -----Original Message-----
> From: James Carman [mailto:[EMAIL PROTECTED]
> Sent: jeudi 2 mars 2006 13:44
> To: 'Tapestry users'
> Subject: RE: Dynamic pages
> 
> The block approach would allow you to do what you want.  Yes, the blocks
> are
> defined statically in some page, but they're dynamically added to another.
> 
> -----Original Message-----
> From: news [mailto:[EMAIL PROTECTED] On Behalf Of Raul Raja Martinez
> Sent: Thursday, March 02, 2006 7:33 AM
> To: [email protected]
> Subject: Re: Dynamic pages
> 
> You should also know that it is not possible to add components
> dynamically at runtime. There have been many discussions about this in
> this list. I'm trying to build a CMS in Tapestry and I having a hard
> time with this too.
> I would like to provide the functionality for people to write their own
> modules that can be dropped in the CMS and dinamically position on
> different places and different pages, but because of the static
> structure of Tapestry Components, I'm still not sure how to approach that.
> 
> Any help is appreciated.
> 
> James Carman wrote:
> > Typically, if you want to add a dynamic number of components or the type
> of
> > component is based on some data and you're not talking about the @If and
> > @For situations, you use @Blocks for that.  In Trails, we have "editor
> > blocks" defined on another page.  Then, based on the property type, we
> > choose which block to display (show the checkboxEditor for boolean
> > properties).
> >
> > -----Original Message-----
> > From: Rudolf Baloun [mailto:[EMAIL PROTECTED]
> > Sent: Thursday, March 02, 2006 5:22 AM
> > To: Tapestry users
> > Subject: Re: Dynamic pages
> >
> > Hi Peter,
> >
> > here is the easiest solution:
> > http://jakarta.apache.org/tapestry/tapestry/ComponentReference/If.html
> >
> > put in your page something like this:
> >
> > <span jwcid="@If"  condition="ognl:theCondition">
> >     ....
> > </span>
> > Now you got to implement the "isTheConditon()" in your java-code (in the
> > Page).
> >
> >
> >
> > Dynamic number of components:
> > http://jakarta.apache.org/tapestry/tapestry/ComponentReference/For.html
> >
> >
> >
> > I dont know if it is what you want to know.
> > Look in the componentreference.....
> >
> >
> > Rudolf B.
> >
> >
> >
> > Peter Verhoye wrote:
> >> Hi all,
> >>
> >> It happens sometimes that I'm starting to think of new interesting
> >> projects to create myself. Since I've recently discovered Tapestry, I
> >> wanted to do something with it. However, I have a problem for which I
> >> haven't found a solution yet.
> >>
> >> Let's say you have a page on which you want to display a non-predefined
> >> number of components and that the location for them on that page is not
> >> defined also.
> >>
> >> I guess the later you could do by somehow changing the css style of the
> >> page at runtime.
> >>
> >> But how would you do the former? Is it possible to dynamically add
> >> components to a page?
> >>
> >> Any help or discussion would be greatly appreciated :-)
> >>
> >> BB
> >> Peter
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]


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

Reply via email to