Hi Jorge,

> But maybe I'm wrong, who among you guys feel that really understand
> Tapestry? How much time and effort did it take?

I guess that differs from person to person. After you figure out the main
concepts, it is not difficult, I think. It _does_ take a while to understand
the full implications, however. Your email is a good example of that.


Since I wrote the Table component, I'll try to answer your questions related
to it.

Before I continue, however, I'd like to point out there is a fundamental
difference in the way Tapestry and JSP-derived frameworks operate that needs
to be understood by people using Tapestry.

In JSP you don't have 'components' and it is very rare that different parts
of your page are written by completely different people. The URLs are built
manually and the developer determines what parameter refers to what.

In Tapestry, the various components that you can build a page from can be
responsible not only for rendering their part of page, but also for
_handling events_ (URLs, in other words) that originate from their part of
the page. Tapestry automatically routes the event (URL) down to the right
component _without disturbing the other components on the page_. This makes
components to be extremely independent and allows many different components
or many different instances of the same component to peacefully coexist on a
single page.

A relevant example of that is the Workbench's Table tab, where you have two
different tables on the same page. Changes in the sorting or the active page
of one of the tables has no effect at all on the condition of the other --
it basically does not notice what is happenning in the other parts of the
page -- it simply does not care (of course, it is easy to make it care, if
necessary).

When I made that page, I did absolutely nothing to achieve this. It is
essentially built in. Had I made this via JSP, I would have had to manually
make sure what parameters are passed, define which table should understand
which parameters to avoid conflicts, and so on. The more components there
are, the more messy this gets.

I am saying all this because it would greatly help with explaining some of
the issues further down.

> 1 - The table component creates non bookmarkable URL's. There is no
> way to access directly a page somewhere in the list. In the Vlib
> application there is a way to create bookmarkable URL's but I wasn't
> able to incorporate this functionality in the Table component.

Suppose that we want to produce a bookmarkable URL. This automatically
implies two things, of which the more important one is the following:

All the 'state' information of the table must be encoded in the URL. That
includes the sorting column, the sorting order, the current page, and the
number of entries per page (or alternatively the first and last rows to be
displayed).

Now, suppose that you want to place two tables on the same page, as you can
do easily at the moment (as demonstrated in the workbench). Or, you want to
place a tree and a table together (a very frequent combination; we use it
all the time in our products together with a tab pane and a few other
things).

Needless to say, for any of these combinations you have to encode all of the
state of all the components in the URL in order to be able to render the
page correctly outside the context of a session (essentially to make it
bookmarkable), and do it in such a way that there are no conflicts. In other
words, the encoding of URLs MUST NOT be done by the component without regard
for the page it is located in, (as you indirectly suggest) since that may
cause conflicts. Essentially it can only be done if you have global
knowledge of what components the particular page contains.

There are two possible solutions: (1) doing it manually by the page that
holds the component(s) or (2) it can be done automatically by the framework.

The first solution can be implemented by using the External Service provided
by Tapestry (please see the docs). It will allow you to make bookmarkable UR
Ls with parameters that will be passed to your page.

The page can take the parameters, and set the table state accordingly. If
you have more than one component, it is your responsibility to decide how to
do that. You then have to create your own implementation of the components
in the Table family that render links, and make them render External links,
instead.

Needless to say, this approach is page- and application-specific, and it is
logical to expect that Table does not support it by default.


The second solution is to have Tapestry automatically place all the
component and page state in the URLs automatically, which would make them
bookmarkable no matter what. This is not currently available as a feature,
but is one of the extensions that Tapestry allows due to its design. (as a
side note: normally that state is stored in the session; Howard intends to
provide the ability to store that info in cookies, which would be done in a
similar manner, in order to minimize the need for creation of sessions;
adding this will be transparent to the existing applications).

This solution has not been implemented for two reasons, I believe -- there
has not been demand for it (External does the job well where necessary), and
it is quite likely that it would be impractical. It would likely result into
very, very long URLs for the average application, which is neither good, nor
workable, since it has a number of side-effects (e.g. according to our
testing IE stops working properly if a page contains a number of 'long'
links; go figure). I think it can certainly be considered, if there is
demand for it and if it makes sense after a careful review by the
contributors.


> 2 - The table component creates a Session on use, this is probably
> related to point 1 somehow, but I find this weird. One rule that I
> always try to follow when developing web apps is to try to delay the
> creation of sessions as much as possible. A paging component doesn't
> seem enough of a reason to create a Session, maybe in the Tapestry
> world things work differently.

I think the above explains this to some extent. In addition, you can control
what to put in your session, how to put it in your session, and whether to
put it in your session at all. Please see the descriptions of the table
session managers in
http://www.geocities.com/mindbridgeweb/TapestryTable.html.
This will be a part of the documentation in the next release.

> 3 - So far I'm having no luck embedding existing components (Images
> and form components) inside a Table component, looking at the example
> in the workbench what I'm trying to do seems possible but I'm failing
> miserably.

Look at LocaleSelection.java in the workbench. You need a class identical to
VerbosityColumn to define your column. In the Block that the class refers
to, you can put whatever components you like -- images, form components,
etc. The components can be bound to the current value in the table simply --
see the binding the 'verbosity' component uses (it has a lot of OGNL, but
essentially calls getCurrentLocaleVerbosity() in the bean which ties to the
current value).

You can see use of form components as well in LocaleList, which also uses a
slightly different way to define columns that is less code, but cannot be
sorted. Essentially, you have two approaches to choose from.

> 4 - I can't seem to find a easy way to define the number of items in a
> page, shouldn't this be a parameter of the Table (or the TableRows)
> component?

This is a part of the state. You can change it using:
tableModel.getPagingState().setPageSize(..)
(or sth like that -- do not remember the exact method names).

This was originally done in the way you mentioned, but some use cases showed
that the current approach is more flexible.


I hope that I have managed to help with your questions and to give some
insight into what the implications of working with components are.


One last thing I should mention is that we are really trying to make
Tapestry easier, so the feedback that you are giving (your messages are a
good example) is analyzed carefully to see what we can change to make your
life and that of other new-comers hassle-free. Of course, the solutions are
not always obvious and are not always the immediately apparent ones.


With respect to the Table component, we have already included a lot of the
feedback that has been received into the CVS (should be available in the
next version). Malcolm has helped a lot with the documentation and some
additional things are on the table  (no pun intended) -- using delegation
rather than inheritance for extensions (columns, etc), providing more
standard functionality (a Block column that save you some of the work
mentioned above), and so on. So we do listen, and suggestions and
observations are very welcome -- thank you for them.


Best regards,

-mb



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of
Jorge
Sent: Thursday, December 05, 2002 3:46 PM
To: [EMAIL PROTECTED]
Subject: RE: [Tapestry-developer] This Tapestry stuff is hard.





I want to thank Phil and Nick for their responses to my last e-mail,
they cleared up some of my questions and it was nice to know that I'm
not the only one with problems in my Tapestry initiation, misery loves
company :-)

After talking with the guys that introduce me to Tapestry and reading
some posts in the mailing list it seems to me that only a handful of
people really grok Tapestry. The others just code by example, that is,
they can be productive fairly quickly with Tapestry by following the
examples provided, but if they have to do something for which there
isn't an example there are SOL.
But maybe I'm wrong, who among you guys feel that really understand
Tapestry? How much time and effort did it take?

My main problem is that every time I find an answer, another bunch of
questions pop up, dragging me into a endless spiral of confusion.

Example :

After trying unsuccessfully to combine two components to make a list
paging component I turned my attention to the existing Table component
in the contrib package. After a brief moment of euphoria (It seemed I
actually accomplished something) the reality kicked in.

1 - The table component creates non bookmarkable URL's. There is no
way to access directly a page somewhere in the list. In the Vlib
application there is a way to create bookmarkable URL's but I wasn't
able to incorporate this functionality in the Table component.

2 - The table component creates a Session on use, this is probably
related to point 1 somehow, but I find this weird. One rule that I
always try to follow when developing web apps is to try to delay the
creation of sessions as much as possible. A paging component doesn't
seem enough of a reason to create a Session, maybe in the Tapestry
world things work differently.

3 - So far I'm having no luck embedding existing components (Images
and form components) inside a Table component, looking at the example
in the workbench what I'm trying to do seems possible but I'm failing
miserably.

4 - I can't seem to find a easy way to define the number of items in a
page, shouldn't this be a parameter of the Table (or the TableRows)
component?

The above example pretty much summarizes my Tapestry experience so far,
it seems like I'm playing with Russian Matryoshka nesting dolls.

Fortunately not all my experience is bad, there are things that I
really like about Tapestry.

- The clear separation between Java code and HTML is great.
- The way pages communicate is awesome.
- Localization of pages is extremely easy (very important for my work).
- I just love the Border component and what can be done with it.
- The exception reporting is excellent.

I truly believe that there are more hidden pearls in the Framework
that are just waiting for me to find them, if only I had a map.

Jorge Chandra



_______________________________________________
No banners. No pop-ups. No kidding.
Introducing My Way - http://www.myway.com


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Tapestry-developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/tapestry-developer

Reply via email to