You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bo Gao <el...@gmail.com> on 2011/10/27 09:11:54 UTC

Problem with pass parameter Using @Environmental

I have a 2 nested component.
I pass Parameters Using @Environmental service.

Code in Outer Component:

	void beginRender() {
		environment.push(MyData.class, data);
	}
	void afterRender() {
		environment.pop(MyData.class);
	}

Code in inner Component

	@Environmental
	private MyData data;


It works well.

Then I want to put my first component in an ProgressiveDisplay, 
When should I call environment.push() ?

I try like this:

In my outer Component:

	@OnEvent(EventConstants.PROGRESSIVE_DISPLAY)
	void onLoad() {
		environment.push(MyData.class, getData());
	}


I think this would work, but if it works, where should I call environment.pop()?

I got an Error:

org.apache.tapestry5.ioc.util.UnknownValueException
No object of type org.test.MyData is available from the Environment.
availableValues
Environmentals:

org.apache.tapestry5.RenderSupport
org.apache.tapestry5.ValidationDecorator
org.apache.tapestry5.internal.services.DocumentLinker
org.apache.tapestry5.services.ClientBehaviorSupport
org.apache.tapestry5.services.FormSupport
org.apache.tapestry5.services.Heartbeat
org.apache.tapestry5.services.javascript.JavaScriptSupport
org.test.MyData

It's strange that It says MyData not found, but there are MyData in availableValues.

Many Thanks.

--
Bo Gao
elivoa@gmail.com







Re: Problem with pass parameter Using @Environmental

Posted by Bo Gao <el...@gmail.com>.
Thanks

On Oct 27, 2011, at 3:52 PM, Steve Eynon wrote:

> The Enviroment is tied to a ThreadLocal in the Request, so if you
> don't pop MyData manually, it should be cleared out automatically when
> the Request ends.
> 
> I'm not sure why MyData is not found on the Environment Stack - does
> getData() return an actual object or a null?

It's the object, not null.

It's strange that on the error page there is org.test.MyData, but I can't get it.

Now I use Tapestry 5.3-beta-21, It works when I use Tapestry 5.2.6.


> 
> Steve.
> 
> 
> On 27 October 2011 15:11, Bo Gao <el...@gmail.com> wrote:
>> I have a 2 nested component.
>> I pass Parameters Using @Environmental service.
>> 
>> Code in Outer Component:
>> 
>>        void beginRender() {
>>                environment.push(MyData.class, data);
>>        }
>>        void afterRender() {
>>                environment.pop(MyData.class);
>>        }
>> 
>> Code in inner Component
>> 
>>        @Environmental
>>        private MyData data;
>> 
>> 
>> It works well.
>> 
>> Then I want to put my first component in an ProgressiveDisplay,
>> When should I call environment.push() ?
>> 
>> I try like this:
>> 
>> In my outer Component:
>> 
>>        @OnEvent(EventConstants.PROGRESSIVE_DISPLAY)
>>        void onLoad() {
>>                environment.push(MyData.class, getData());
>>        }
>> 
>> 
>> I think this would work, but if it works, where should I call environment.pop()?
>> 
>> I got an Error:
>> 
>> org.apache.tapestry5.ioc.util.UnknownValueException
>> No object of type org.test.MyData is available from the Environment.
>> availableValues
>> Environmentals:
>> 
>> org.apache.tapestry5.RenderSupport
>> org.apache.tapestry5.ValidationDecorator
>> org.apache.tapestry5.internal.services.DocumentLinker
>> org.apache.tapestry5.services.ClientBehaviorSupport
>> org.apache.tapestry5.services.FormSupport
>> org.apache.tapestry5.services.Heartbeat
>> org.apache.tapestry5.services.javascript.JavaScriptSupport
>> org.test.MyData
>> 
>> It's strange that It says MyData not found, but there are MyData in availableValues.
>> 
>> Many Thanks.
>> 
>> --
>> Bo Gao
>> elivoa@gmail.com
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 

--
Bo Gao
elivoa@gmail.com







Re: Problem with pass parameter Using @Environmental

Posted by Barry Books <tr...@gmail.com>.
I've never tried this but I think this my help you

http://tapestry.1045711.n5.nabble.com/T5-2-Looking-For-A-RenderNotification-Mixin-Example-td4917771.html#a4920626

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


Re: Problem with pass parameter Using @Environmental

Posted by Steve Eynon <st...@alienfactory.co.uk>.
The Enviroment is tied to a ThreadLocal in the Request, so if you
don't pop MyData manually, it should be cleared out automatically when
the Request ends.

I'm not sure why MyData is not found on the Environment Stack - does
getData() return an actual object or a null?

Steve.


On 27 October 2011 15:11, Bo Gao <el...@gmail.com> wrote:
> I have a 2 nested component.
> I pass Parameters Using @Environmental service.
>
> Code in Outer Component:
>
>        void beginRender() {
>                environment.push(MyData.class, data);
>        }
>        void afterRender() {
>                environment.pop(MyData.class);
>        }
>
> Code in inner Component
>
>        @Environmental
>        private MyData data;
>
>
> It works well.
>
> Then I want to put my first component in an ProgressiveDisplay,
> When should I call environment.push() ?
>
> I try like this:
>
> In my outer Component:
>
>        @OnEvent(EventConstants.PROGRESSIVE_DISPLAY)
>        void onLoad() {
>                environment.push(MyData.class, getData());
>        }
>
>
> I think this would work, but if it works, where should I call environment.pop()?
>
> I got an Error:
>
> org.apache.tapestry5.ioc.util.UnknownValueException
> No object of type org.test.MyData is available from the Environment.
> availableValues
> Environmentals:
>
> org.apache.tapestry5.RenderSupport
> org.apache.tapestry5.ValidationDecorator
> org.apache.tapestry5.internal.services.DocumentLinker
> org.apache.tapestry5.services.ClientBehaviorSupport
> org.apache.tapestry5.services.FormSupport
> org.apache.tapestry5.services.Heartbeat
> org.apache.tapestry5.services.javascript.JavaScriptSupport
> org.test.MyData
>
> It's strange that It says MyData not found, but there are MyData in availableValues.
>
> Many Thanks.
>
> --
> Bo Gao
> elivoa@gmail.com
>
>
>
>
>
>
>

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