Hi !

As Howard suggested, you may have a look into TapestryModule, you will see
how RenderSupportImpl is built and pushed into the environment (cf.
contributeMarkupRenderer)

Also as Thiago mentioned it, ComponentResources is not a service, it can be
injected into pages because Tapestry 'shadows' @Inject to the
environment.peek() method

HTH

2010/8/7 Paul Stanton <p...@mapshed.com.au>

> That doesn't seem to work Thiago, or maybe I'm missing something:
>
> public class TapestryExtensionImpl implements TapestryExtension
> {
>   @Inject
>   private Environment environment;
>
>   @SuppressWarnings("unchecked")
>   public <T> T getPage(Class<T> pageClass)
>   {
>       ComponentSource componentSource =
> environment.peekRequired(ComponentSource.class);
>       return (T) componentSource.getPage(pageClass);
>   }
> }
>
> Caused by: java.lang.RuntimeException: No object of type
> org.apache.tapestry5.services.ComponentSource is available from the
> Environment.  Available types are
> org.apache.tapestry5.services.ComponentEventResultProcessor.
>   at
> org.apache.tapestry5.internal.services.EnvironmentImpl.peekRequired(EnvironmentImpl.java:79)
>   at $Environment_12a4a4a9c82.peekRequired($Environment_12a4a4a9c82.java)
>   at $Environment_12a4a4a9bbb.peekRequired($Environment_12a4a4a9bbb.java)
>   at
> com.mapshed.vha.services.TapestryExtensionImpl.getPage(TapestryExtensionImpl.java:21)
>
>
> Thiago H. de Paula Figueiredo wrote:
>
>> On Fri, 06 Aug 2010 17:38:53 -0300, Paul Stanton <p...@mapshed.com.au>
>> wrote:
>>
>>  Thiago,
>>>
>>
>> Hi!
>>
>>  By "declare your class as a service" do you mean bind it? ie:
>>>
>>>    public static void bind(ServiceBinder binder) {
>>>        binder.bind(TapestryExtension.class, TapestryExtensionImpl.class);
>>>    }
>>>
>>
>> Yes.
>>
>>  or do i need to 'contribute' it somewhere? Because it isn't working.:
>>>
>>
>> ComponentResources ins't a service. There's class transformation applied
>> to component and pages classes that inject it. You should get it from the
>> Environment service by using the peek() or peekRequired() methods.
>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>


-- 
Regards,
Christophe Cordenier.

Committer on Apache Tapestry 5
Co-creator of wooki @wookicentral.com

Reply via email to