RE: This Tapestry stuff is hard.
Phil Surette <[email protected]>
| Newsgroups | gmane.comp.java.tapestry.devel |
|---|---|
| Message-ID | <[email protected]> |
I sympathize with you. Tapestry can seem odd. There
is a new tutorial in the works which I'm looking forward
to. I think you can grab what's there from CVS.
Here's my best cut at answering your questions. I may
be wrong on some of these and someone else will jump
on that and then we'll both be illuminated.
Visit = session
Engine = request context
I've been able to use tapestry without understanding services,
gestures, rewind, or page recorders. The rewind and page
recorders seem to be most important for understanding how
forms work, but forms do what I expect out of the box
anyway.
Page initialization: override beginResponse
Page cleanup: override detach
<aside>
for component cleanup, you need to implement PageDetachListener
and add this to your component:
public finishLoad() {
getPage().addPageDetachListener(this);
}
public void pageDetached(PageEvent pageEvent){
//do your cleanup
}
I forget what the right method is for initializing a component...
</aside>
You should pretty well always override detach to clean up
any page state that you've accumulated. Otherwise it hangs
around sucking up memory until someone else tries to use
that page. Basically, during the course of each request,
a page and a bunch of components are grabbed from a pool
and are used to process the request; at the end of the
request they are returned to the pool. In between requests
they should not be holding onto any state, since the state
will probably not be appropriate the next time they're
attached to a request.
Components can call getPage() to get at their containing page.
If you know the type of page the component is in you can just
cast it and make your call. I doubt this is the Tapestry Way
though. I've never needed to have components talk to each other,
usually the components are on different pages and communication
is mediated through a link.
I don't see beans as the model in a Tapestry app. I don't use
them much - the EvenOdd one is the only I've used.
As for MVC, I find the model and controller are a little mixed
up in Tapestry. Maybe it's just me, but most frameworks seem
this way to me.
Your .html page is your view. Your .page or .component has some
controller logic in it - it pushes data from the page/component
into the view. The way I do tapestry, my pages/components usually
_contain_ the model as an object property that can be accessed
from the .page or .component. And the pages have some controller
logic in them, since (the way I do tapestry) they control the
navigation, e.g. they get notified when someone clicks on a
link, set up a new page, and redirect to that page.
-----Original Message-----
From: Jorge [mailto:[email protected]]
Sent: Tuesday, December 03, 2002 12:51 PM
To: [email protected]
Subject: [Tapestry-developer] This Tapestry stuff is hard.
I've been playing on and off with Tapestry for the past days , and I
have mixed feelings about it, in one hand looking at the bundled
examples, Tapestry seems to be as good as you guys advertise, on the
other hand trying to do something with Tapestry it's proving to be a
torture.
First I'd like to say that English is not my native language, so my
confusion maybe partially related to my poor understanding of the
documentation (BTW congratulations, hardly never do I see a project
that makes such an obvious effort in documenting itself).
The first hurdle that I come across is the weird naming conventions
that you guys follow, terms like "Visit", "Engine", "Service",
"Gestures" "rewind" and "page recorders". I understand that the Visit
is the place to store the Session State (why not call it Session?), as
for the rest of the stuff I'm still fishing. For instance it's still
unclear to me where to store application level variables.
And how about page initialization. Apparently the method in which to
perform page initialization is called "detach()"?!?, isn't this
weird?, a "detach()" method to perform initialization!?! ... what's
wrong with "init()" or "pageInit()" or "initialize()"?, is it only me
that finds this stuff confusing? After digging in the docs the reason
for the "detach()" became more clear, apparently there is a pool of
pages and when there is a request, a page is retrieved (detached?)
from the pool and the persistent properties of the page must be
manually reseted (I'm talking from my ass I don't know for sure if
this is what happens). But I have a question, why do I need to know
that there is a pool? I have no interest at this time to know the
magic behind the curtain, I'm just trying to use Tapestry, is it
required to know the inner workings of Tapestry to be able to use it?
I understand how pages intercommunicate (wheee ... no more parsing of
parameters), but how do components "talk" to each other, case in point
I have a "Portrait" component (it shows a picture from a list of
available pictures) and a "PortraitExplorer" component, how can I make
the "PortraitExplorer" tell the "Portrait" to show the next picture on the
list? I also can't seem to find a way to make a component execute a
method of the containing page , for example lets say I put the
"PortraitExplorer" component and the "Portrait" component in a
"ShowPicassoPictures" page and when I press the "NextPicture" button of
the "PortraitExplorer" component I want to execute the
incrementPicassoHitCount() of the "ShowPicassoPictures" page. I think
that what I'm talking about is to have a method of the containing page
as parameter of a component, is this possible?
Another thing that I found weird is the "rewind". It seems to be one of
the focal points in Tapestry but I don't understand it. From what I
can gather it seems that Tapestry is doing the same work twice, and
only producing HTML once, isn't this weird?
Helper Beans... like the "EvenOdd" thingy , the whole "Helper Beans"
stuff remains as one of the most confusing aspects of Tapestry is the
Bean supposed to be the Model in a MVC design?
Oh... perhaps it would be beneficial to make more clearer in the docs
the dependency on CSS of the EvenOdd bean, I know its there but it
took me a while to understand from where the alternating row colours
where coming.
This post is long already, so I better stop here. If someone could
shed some light in some of my questions I would be forever grateful.
I'm having a hard time trying to justify the time spent with Tapestry
and the (almost)zero results so far.
Jorge Chandra
_______________________________________________
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com
-------------------------------------------------------
This SF.net email is sponsored by: Microsoft Visual Studio.NET
comprehensive development tool, built to increase your
productivity. Try a free online hosted session at:
http://ads.sourceforge.net/cgi-bin/redirect.pl?micr0003en
_______________________________________________
Tapestry-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer