Re: Why Environmental Objects is only available during rendering, not during action requests.
On Tue, 08 Nov 2011 02:05:28 -0200, Steve Eynon steve.ey...@alienfactory.co.uk wrote: Remember that if you use t:trigger event=setupRender / then your event handler is called void onSetupRender() whereas the render phase method is called void setupRender() the two are different. Nice catch, Steve! Tapestry has two different types of events (component events and render lifecycle). The former can be triggered by user (i.e. not Tapestry itself) code, while the latter just by Tapestry itself. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Why Environmental Objects is only available during rendering, not during action requests.
I saw a line in tapestry documents (http://tapestry.formos.com/nightly/tapestry5/guide/ajax.html) Inside a component, you should use Environmental, to highlight the fact that RenderSupport (like most environmental objects) is only available during rendering, not during action requests. In fact, I just want to use Environmental Service during a action requests. (i.e. a zone update) Why this is not allowed, What other methods I can do the same thing? Thanks -- Elivoa
Re: Why Environmental Objects is only available during rendering, not during action requests.
I have a zone, and many nested components in it. I pass objects to these components by Environmental Service. The first time page render is ok. But when I click an Action link which will refresh the zone, I can't get Environmental Object. And I get an Error like this: 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 says No object of type MyData is available, but in availableValues, there is my MyData. strange. I use tapestry-rc-3 now. But it works when I use tapestry 2.6. On Nov 7, 2011, at 6:44 PM, Thiago H. de Paula Figueiredo wrote: On Mon, 07 Nov 2011 07:40:21 -0200, Bo Gao eli...@gmail.com wrote: I saw a line in tapestry documents (http://tapestry.formos.com/nightly/tapestry5/guide/ajax.html) Inside a component, you should use Environmental, to highlight the fact that RenderSupport (like most environmental objects) is only available during rendering, not during action requests. Each Environmental object put or removed by different classes in Tapestry, so there isn't a single answer for them. In fact, I just want to use Environmental Service during a action requests. (i.e. a zone update) What service do you need and what methods? What you're trying to do? -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br -- Bo Gao eli...@gmail.com
Re: Why Environmental Objects is only available during rendering, not during action requests.
On Mon, 07 Nov 2011 14:01:19 -0200, Bo Gao eli...@gmail.com wrote: I have a zone, and many nested components in it. I pass objects to these components by Environmental Service. The first time page render is ok. But when I click an Action link which will refresh the zone, I can't get Environmental Object. How you're adding these objects in the Environment? Please post the code that does that. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Why Environmental Objects is only available during rendering, not during action requests.
How you're adding these objects in the Environment? Please post the code that does that. My page, Test.tml: t:zone elementName=div t:id=textzone count:[ ${count} ] t:embedComponent / /t:zone t:eventlink t:id=plusOne zone=textzone+1/t:eventlink Test.java: ... void setupRender() { env.push(String.class, ++ + this.count); } void afterRender() { env.pop(String.class); } Object onPlusOne() { if (count == null) { count = 0; } this.count++; env.push(String.class, ++ + this.count); // I set environmental object here. return textzone; } ... EmbedComponent.java: ... @Environmental @Property private String env; EmbedComponent.tml: ... ${env} ... The first time page render, setupRender and afterRender will be called, it works. I click +1 button, the environmental object 'env' can not be found in component EmbedComponent. On Nov 8, 2011, at 12:15 AM, Thiago H. de Paula Figueiredo wrote: On Mon, 07 Nov 2011 14:01:19 -0200, Bo Gao eli...@gmail.com wrote: I have a zone, and many nested components in it. I pass objects to these components by Environmental Service. The first time page render is ok. But when I click an Action link which will refresh the zone, I can't get Environmental Object. How you're adding these objects in the Environment? Please post the code that does that. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br -- Bo Gao eli...@gmail.com
Re: Why Environmental Objects is only available during rendering, not during action requests.
On Mon, 07 Nov 2011 14:51:37 -0200, Bo Gao eli...@gmail.com wrote: void setupRender() { env.push(String.class, ++ + this.count); } void afterRender() { env.pop(String.class); } Component event lifecycle events are only triggered when the whole page or component is rendered. In this case, you're rendering a Zone, so your page isn't rendered (just a part of it) and setupRender() and afterRender() aren't invoked. Use the RenderNotification mixin or the Trigger component inside your zone to push and pop objects in the Environment. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Why Environmental Objects is only available during rendering, not during action requests.
Component event lifecycle events are only triggered when the whole page or component is rendered. In this case, you're rendering a Zone, so your page isn't rendered (just a part of it) and setupRender() and afterRender() aren't invoked. Use the RenderNotification mixin or the Trigger component inside your zone to push and pop objects in the Environment. In this version I have push the object in event method 'onPlusOne', env.push(String.class, ++ + this.count); This works in previous version of tapestry. I also tried Trigger component. t:zone elementName=div t:id=textzoneS t:trigger event=setupRender / [${cont}] t:trigger event=afterRender / /t:zone It doesn't works. On Nov 8, 2011, at 12:59 AM, Thiago H. de Paula Figueiredo wrote: On Mon, 07 Nov 2011 14:51:37 -0200, Bo Gao eli...@gmail.com wrote: void setupRender() { env.push(String.class, ++ + this.count); } void afterRender() { env.pop(String.class); } Component event lifecycle events are only triggered when the whole page or component is rendered. In this case, you're rendering a Zone, so your page isn't rendered (just a part of it) and setupRender() and afterRender() aren't invoked. Use the RenderNotification mixin or the Trigger component inside your zone to push and pop objects in the Environment. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br -- Bo Gao eli...@gmail.com
Re: Why Environmental Objects is only available during rendering, not during action requests.
Remember that if you use t:trigger event=setupRender / then your event handler is called void onSetupRender() whereas the render phase method is called void setupRender() the two are different. Steve. On 8 November 2011 10:56, Bo Gao eli...@gmail.com wrote: Component event lifecycle events are only triggered when the whole page or component is rendered. In this case, you're rendering a Zone, so your page isn't rendered (just a part of it) and setupRender() and afterRender() aren't invoked. Use the RenderNotification mixin or the Trigger component inside your zone to push and pop objects in the Environment. In this version I have push the object in event method 'onPlusOne', env.push(String.class, ++ + this.count); This works in previous version of tapestry. I also tried Trigger component. t:zone elementName=div t:id=textzoneS t:trigger event=setupRender / [${cont}] t:trigger event=afterRender / /t:zone It doesn't works. On Nov 8, 2011, at 12:59 AM, Thiago H. de Paula Figueiredo wrote: On Mon, 07 Nov 2011 14:51:37 -0200, Bo Gao eli...@gmail.com wrote: void setupRender() { env.push(String.class, ++ + this.count); } void afterRender() { env.pop(String.class); } Component event lifecycle events are only triggered when the whole page or component is rendered. In this case, you're rendering a Zone, so your page isn't rendered (just a part of it) and setupRender() and afterRender() aren't invoked. Use the RenderNotification mixin or the Trigger component inside your zone to push and pop objects in the Environment. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br -- Bo Gao eli...@gmail.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org
Re: Why Environmental Objects is only available during rendering, not during action requests.
Oh it works now, Thanks. On Nov 8, 2011, at 12:05 PM, Steve Eynon wrote: Remember that if you use t:trigger event=setupRender / then your event handler is called void onSetupRender() whereas the render phase method is called void setupRender() the two are different. Steve. On 8 November 2011 10:56, Bo Gao eli...@gmail.com wrote: Component event lifecycle events are only triggered when the whole page or component is rendered. In this case, you're rendering a Zone, so your page isn't rendered (just a part of it) and setupRender() and afterRender() aren't invoked. Use the RenderNotification mixin or the Trigger component inside your zone to push and pop objects in the Environment. In this version I have push the object in event method 'onPlusOne', env.push(String.class, ++ + this.count); This works in previous version of tapestry. I also tried Trigger component. t:zone elementName=div t:id=textzoneS t:trigger event=setupRender / [${cont}] t:trigger event=afterRender / /t:zone It doesn't works. On Nov 8, 2011, at 12:59 AM, Thiago H. de Paula Figueiredo wrote: On Mon, 07 Nov 2011 14:51:37 -0200, Bo Gao eli...@gmail.com wrote: void setupRender() { env.push(String.class, ++ + this.count); } void afterRender() { env.pop(String.class); } Component event lifecycle events are only triggered when the whole page or component is rendered. In this case, you're rendering a Zone, so your page isn't rendered (just a part of it) and setupRender() and afterRender() aren't invoked. Use the RenderNotification mixin or the Trigger component inside your zone to push and pop objects in the Environment. -- Thiago H. de Paula Figueiredo Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and instructor Owner, Ars Machina Tecnologia da Informação Ltda. http://www.arsmachina.com.br -- Bo Gao eli...@gmail.com - To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org -- Bo Gao eli...@gmail.com