You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Yohan Yudanara <yo...@gmail.com> on 2011/03/10 11:52:57 UTC

How to Get Service Without @Inject annotation

Hi..

Could anyone give me an example how to get service bean, without using
@Inject annotation, in page class?
Is it using ObjectLocator? What built-in service to inject, in order to use
ObjectLocator?

I can use this when using tapestry-spring and spring ioc:
@Inject
private ApplicationContext springContext;
and use this statement to get bean:
entityManager = springContext.getBean(beanNames[0]);

How to do the same thing using tapestry-ioc?

Thanks..

Best regards,
Yohan

Re: How to Get Service Without @Inject annotation

Posted by Yohan Yudanara <yo...@gmail.com>.
Thank you very much for your help.
I use the registry from ServletContext.

I'm using this code:
@Inject
private Context context;

and use this statement to get bean:
Registry registry = (Registry)
context.getAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME);
entityManager = registry.getService(clazz);


Thanks..



On Thu, Mar 10, 2011 at 6:11 PM, Igor Drobiazko <ig...@gmail.com>wrote:

> Injecting ObjectLocator into a page or component class is not supported.
> You
> need to provide a wrapper service, which uses ObjectLocator. Then inject it
> into your page and retrieve your services.
>
> Alternatively you can retrieve the Registry from ServletContext. Check this
> out.
>
>
> http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/TapestryFilter.html#REGISTRY_CONTEXT_NAME
>
> On Thu, Mar 10, 2011 at 11:52 AM, Yohan Yudanara
> <yo...@gmail.com>wrote:
>
> > Hi..
> >
> > Could anyone give me an example how to get service bean, without using
> > @Inject annotation, in page class?
> > Is it using ObjectLocator? What built-in service to inject, in order to
> use
> > ObjectLocator?
> >
> > I can use this when using tapestry-spring and spring ioc:
> > @Inject
> > private ApplicationContext springContext;
> > and use this statement to get bean:
> > entityManager = springContext.getBean(beanNames[0]);
> >
> > How to do the same thing using tapestry-ioc?
> >
> > Thanks..
> >
> > Best regards,
> > Yohan
> >
>
>
>
> --
> Best regards,
>
> Igor Drobiazko
> http://tapestry5.de
>

Re: How to Get Service Without @Inject annotation

Posted by Igor Drobiazko <ig...@gmail.com>.
Injecting ObjectLocator into a page or component class is not supported. You
need to provide a wrapper service, which uses ObjectLocator. Then inject it
into your page and retrieve your services.

Alternatively you can retrieve the Registry from ServletContext. Check this
out.

http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/TapestryFilter.html#REGISTRY_CONTEXT_NAME

On Thu, Mar 10, 2011 at 11:52 AM, Yohan Yudanara
<yo...@gmail.com>wrote:

> Hi..
>
> Could anyone give me an example how to get service bean, without using
> @Inject annotation, in page class?
> Is it using ObjectLocator? What built-in service to inject, in order to use
> ObjectLocator?
>
> I can use this when using tapestry-spring and spring ioc:
> @Inject
> private ApplicationContext springContext;
> and use this statement to get bean:
> entityManager = springContext.getBean(beanNames[0]);
>
> How to do the same thing using tapestry-ioc?
>
> Thanks..
>
> Best regards,
> Yohan
>



-- 
Best regards,

Igor Drobiazko
http://tapestry5.de