On Wed, 02 May 2012 18:46:59 -0300, netdawg <net.d...@yahoo.com> wrote:

BTW, I just posted a citation which describes the componentResources...which is already able to pull up the pageName...this is very useful in authoring solid code at the page level. Why would componentResources have the
pagename attribute if the INTENT was otherwise (that is, as you are
suggesting, the component to be oblivious to the page)?

I haven't understood what you're trying to do with it, so I didn't answer.

And if it does already have pageName, why not access to pageName.property?

Because they're very, very, very different stuff. Each component instance belongs to a page, so ComponentResources.getPageName() is actually an easy thing to implement. On the other hand, getting properties from the page itself is a whole different matter. In addition, tying a component to a given page is a very bad thing to do (you couldn't use the component in another page).

A component accessing a page property, believe me, is a Very Bad Thing. It's bad architecture. It's going against the philosophy on which Tapestry was build. I really don't know what good would come from doing what a framework doesn't want you to do.

To me, it seems counter-intuitive to place a property of a page into a
component and to then have it trickle  back down to the page...when the
component could simply access the property directly (just like it does the pageName).

That's the point: getting the page name is one thing, getting page properties would need a whole different code for it. And it would still be a very bad idea.

On the other hand, you can get the page instance by invoking ComponentResources.getPage() and casting the returned object to the page class.

the message (best practice according to you guys) is to use the getters and setters of the component class from the page class...

Nope. It's passing parameters to the components or using the Environment.

--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to