You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Apache <ap...@ss78.shared.server-system.net> on 2006/04/12 16:50:10 UTC

How to use global services?

Hi, I have a DAO to access configurations, this DAO must be accessible by all pages but I don't want to declare an inject for it in each page especification.
I think I could place it in the Global class, but I don't know how neither where to "inject" this dao in the global class.
What is the best solution for this?
Thank you.


-------------------- m2f --------------------

Sent from www.TapestryForums.com

Read this topic online here: <<topic_link>>

http://www.tapestryforums.com/viewtopic.php?p=14702#14702

-------------------- m2f --------------------



Re: How to use global services?

Posted by Mark Arnold <ma...@markarnold.de>.
Is there a way to access the Hivemind service/bean provider, so that 
instead of using annotations, I can do something like this in my Page class:

public abstract class MyPage extends BasePage {
    /* define setters and getters for service1 and service2 ... */
    public MyPage() {
        init();
    }

    public void init() {
        setService1(SomeHivemindHook.getService("service1"));
        setService2(SomeHivemindHook.getService("service2"));
    }
}

Something like this?

Thanks,

MARK

Apache wrote:
> I think it is the easiest way ... in fact all my page classes already extends a custom class. I just need to inject the dao in the class.
>
> Another aproach that can be used is described in 
>
>
> Thank you.
>
>
> -------------------- m2f --------------------
>
> Sent from www.TapestryForums.com
>
> Read this topic online here: <<topic_link>>
>
> http://www.tapestryforums.com/viewtopic.php?p=14706#14706
>
> -------------------- m2f --------------------
>
>
>
>   


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


RE: How to use global services?

Posted by Apache <ap...@ss78.shared.server-system.net>.
Why you don't makin' a class for it, which includes this inject and then inherit all over Pages from this class and not from BasePage.
This should be the simplest Solution i think, but i'm a noob, too.


public abstract class upperclass extends BasePage
&#123;
@Inject&#40;"Property"&#41;
public abstract String getProperty&#40;&#41;;

..
&#125;

public class underclass extends upperclass
&#123;
&nbsp; public void ..&#40;&#41;
&nbsp; &#123;
&nbsp; &nbsp; String prop = getProperty&#40;&#41;;
&nbsp; &#125;
&#125;


-------------------- m2f --------------------

Sent from www.TapestryForums.com

Read this topic online here: <<topic_link>>

http://www.tapestryforums.com/viewtopic.php?p=14704#14704

-------------------- m2f --------------------



RE: How to use global services?

Posted by Apache <ap...@ss78.shared.server-system.net>.
I think it is the easiest way ... in fact all my page classes already extends a custom class. I just need to inject the dao in the class.

Another aproach that can be used is described in 


Thank you.


-------------------- m2f --------------------

Sent from www.TapestryForums.com

Read this topic online here: <<topic_link>>

http://www.tapestryforums.com/viewtopic.php?p=14706#14706

-------------------- m2f --------------------