I would address this using component parameters to tell the components
where they can obtain those resources from.  Perhaps there's a
ResourcesProvider interface that a page could implement.

The default for the parameter could be "componentResources.page",
which would provide the containing page, cast to ResourcesProvider.

For AppPropertyBlocks, you'll need to bind the parameter more
directly, to whatever works as a proper ResourcesProvider.

Does that help?

Could you move the resource provider to a service, instead of the page?

On Wed, Nov 5, 2008 at 5:53 AM, José Paumard <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I just came across a problem that really puts me into trouble.
>
> I have a page that holds some components. Those components need to access
> some resources bound to each page, initialized on the @PageAttached event.
> Those resources are closed on the @PageDetached event.
>
> To access those resources in each component,  I use the following pattern in
> the component class, and everything works fine :
>
> @Inject
> private ComponentResources componentResources ;
>
> public SomeResource getResource() {
>   componentResources.getPage().getTheRightResource() ;
> }
>
> (think of a connection to a DB, or an EntityManager as a resource).
>
> Now in some pages, I have home made property editors. Those are declared in
> a special "fake" page : AppPropertyBlocks. The componentResource.getPage()
> returns that page, which doesnt hold my resource, and this is my problem. I
> can understand why it does so, but when I call getPage(), I'm waiting for
> the page that in the end, will be sent to the client.
>
> I'm not sure I'm missing something, any help / hint / workaround will be
> much appreciated !
>
> José
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

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

Reply via email to