Accessing services from a TreeContentProvider

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing services from a TreeContentProvider

ChrisAndCatharineMiller
I have implemented a ITreeContentProvider (based on the Tacos Tree implementation) but while it works fine if I setup the tree data using static information (ie data in the provider itself), I really want to be able to do this dynamically using data from the database.

Having overridden the base Engine class to add an entry named "appContext" to the Global class which contains the Application Context (as per the example in chapter 13 of the Spring  reference), I already have a Service implementation which I can access in my pages and components using
          Map global = (Map) getPage().getGlobal();
          ApplicationContext ac = (ApplicationContext) global.get("appContext");
          ac.getBean("staticDataService");  // StaticDataService is the Spring service which should load the Tree data

The problem is that in my Page and Component classes this works fine since the super classes have the appropriate getPage or getGlobal methods. However I can't see how to do the same in my ITreeContentProvider implementation

Is there some way getting the Global (or even Visit) objects from classes which don't extend the BasePage or BaseComponent classes ?

Thanks,

Chris
Reply | Threaded
Open this post in threaded view
|

AW: Accessing services from a TreeContentProvider

Saqib Rasul
Hi Chris,

You could define the ITreeContentProvider as a "bean" (as in a Tapestry Helper Beans) in the .page/.jwc file and then inject into it the properties you want from the page/component.

Regards,

Saqib

http://galaxy.sagadc.com/
- Web Services in 15 Minutes -

> -----Urspr√ľngliche Nachricht-----
> Von: ChrisAndCatharineMiller [mailto:[hidden email]]
> Gesendet: Wednesday, 11 May 2005 12:41 PM
> An: [hidden email]
> Betreff: Accessing services from a TreeContentProvider
>
> I have implemented a ITreeContentProvider (based on the Tacos Tree
> implementation) but while it works fine if I setup the tree data using
> static information (ie data in the provider itself), I really want to be
> able to do this dynamically using data from the database.
>
> Having overridden the base Engine class to add an entry named "appContext"
> to the Global class which contains the Application Context (as per the
> example in chapter 13 of the Spring  reference), I already have a Service
> implementation which I can access in my pages and components using
>           Map global = (Map) getPage().getGlobal();
>           ApplicationContext ac = (ApplicationContext)
> global.get("appContext");
>           ac.getBean("staticDataService");  // StaticDataService is the
> Spring service which should load the Tree data
>
> The problem is that in my Page and Component classes this works fine since
> the super classes have the appropriate getPage or getGlobal methods.
> However I can't see how to do the same in my ITreeContentProvider
> implementation
>
> Is there some way getting the Global (or even Visit) objects from classes
> which don't extend the BasePage or BaseComponent classes ?
>
> Thanks,
>
> Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]