On Thu, 27 Jan 2011 19:04:26 -0200, Nicolas Bouillon
<nico...@bouillon.net> wrote:
Hi,
Hi!
And the other hand, many times in this mailing list, beginner asks how to
choose dynamically a component to display on the page. The classic
response is that it's not possible because the page tree (page and
components
contained in the page) must be known before page execution, Tapestry has
dynamic behavior but a static structure
http://tapestry.apache.org/principles.html
The component tree is static, but you can choose what to render using the
Delegate component or returning component instances in render lifecycle
events.
But, searching how the BeanDisplay works, I discovered that this
component cheats and is not so static.
This is not technically correct. It uses perfectly correct, recommended
ways of doing it. It asks for a page instance and, gets a Block from its
template and renders it.
. To explain rapidly, the BeanDisplay loops on
each java bean property, and use the PropertyDisplay to display it. The
PropertyDisplay then use the BeanBlockSource service to lookup how to
display this property, which finally use the PageCache (an *internal*
Tapestry service :
You could do the same using ComponentSource, which is not internal. It
delegates some methods to RequestPageCache, which delegates some methods
to PageCache.
My point is :
1. The Core Component BeanDisplay, which is sometime presented as a
sample of what can be done, cannot be realized without using an internal
service
(PagePool), and that is discouraged for upgrade compatibility.
You can use ComponentSource instead.
2. Dynamic structure is finally possible in Tapestry.
The structure is still 100% static at all times, and Tapestry 5 had static
structure from its very beginning. What you're seeing here is the dynamic
behavior (rendering) of static structures. The structure of pages and
components are not changed, just what is rendered.
The BeanModel family (BeanEditor, BeanEditForm, BeanDisplay and Grid) uses
blocks (<t:block>) that are placed in pages written specifically for
holding them. These blocks are statically defined in some page template.
More details in the "Adding New Property Editors" in
http://tapestry.apache.org/beaneditform-guide.html.
I'm using Tapestry 5 on a daily basis at work. For a dynamic navigation,
for example, PageRenderLinkSource helped us to check if a specific
configuration page exists for a product (RuntimeException is thrown on
createPageRenderLink),
You can use ComponentSource to do that.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
Coordenador e professor da Especialização em Engenharia de Software com
Ênfase em Java da Faculdade Pitágoras
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org