You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ilya Obshadko <il...@gmail.com> on 2014/07/03 03:59:18 UTC

[T5.4] context isn't passed to enclosing page during form submit

I'm not sure if this is a bug or not.

Here's a scenario:

Page.java

public class Page {
   @Property
   private Entity entity;

   void onActivate ( Long id ) {
       entity = retrieveFromDatabase ( id );
   }

}

Page.tml:

<t:mycomponent entity="entity"/>

MyComponent.tml:

<t:form p:context="entity.id">
...
</t:form>


AJAX is NOT used. If I get it right, form context must be passed to
enclosing page during form submission. However it doesn't work and
appropriate onActivate method is never called, although submission URL
looks just like expected:
http://localhost:8080/application/page.mycomponent.form/12345

Am I missing something here? I'm using 5.4-beta6


-- 
Ilya Obshadko

Re: [T5.4] context isn't passed to enclosing page during form submit

Posted by Lance Java <la...@googlemail.com>.
Correct, so the bulk of your tapestry code can deal with entities, not ids.
 On 3 Jul 2014 23:11, "Ilya Obshadko" <il...@gmail.com> wrote:

> That's Hibernate entity, so I don't think ValueEncoder is necessary with
> tapestry-hibernate.
>
>
> On Thu, Jul 3, 2014 at 11:28 PM, Lance Java <la...@googlemail.com>
> wrote:
>
> > If you contribute an appropriate ValueEncoder for Entity, you won't need
> > onActivate() / onPassivate(). You can use @PageActivationContext instead.
> >
> >
> > On 3 July 2014 06:11, Ilya Obshadko <il...@gmail.com> wrote:
> >
> > > Oops my bad. I always try to forget about onPassivate ()
> > > That should fix it, thanks!
> > >
> > >
> > > On Thu, Jul 3, 2014 at 1:46 PM, Geoff Callender <
> > > geoff.callender.jumpstart@gmail.com> wrote:
> > >
> > > > What's "t:ac"? In the POST's Form Data, "t:ac" is the key of the
> field
> > > > that carries the page's activation context.
> > > >
> > > >
> > > > On 3 Jul 2014, at 12:41 pm, Geoff Callender <
> > > > geoff.callender.jumpstart@gmail.com> wrote:
> > > >
> > > > > Not a bug. Form bubbles up its context in the PREPARE_FOR_SUBMIT
> > event.
> > > > Here's a typical way to deal with it:
> > > > >
> > > > >       void onPrepareForSubmit(Long id) {
> > > > >               this.id = id;
> > > > >               entity = retrieveFromDatabase(id);
> > > > >       }
> > > > >
> > > > > What should you pass in the context? At a minimum I'd recommend
> > passing
> > > > all the parameters of its enclosing component. Then, in
> > > > onPrepareForSubmit(...) you can restore the component's parameter
> > values
> > > > (like we restored this.id above) before proceeding. In this way a
> > > > component can behave independently rather than depending on its page.
> > > When
> > > > components get deeply nested then this is essential.
> > > > >
> > > > >
> > > > > If you want the page's onActivate(Long id) to be invoked, then
> you'll
> > > > need the *page's* context to include id, which you achieve by doing
> > this
> > > in
> > > > the page:
> > > > >
> > > > >       Long onPassivate() {
> > > > >               return id;
> > > > >       }
> > > > >
> > > > > I'm guessing your page doesn't do that. Before clicking submit, the
> > > page
> > > > URL would look like this...
> > > > >
> > > > >       http://localhost:8080/application/page/12345
> > > > >
> > > > > ...and, on submit, the Form Data would include:
> > > > >
> > > > > t:ac:12345
> > > > >
> > > > > Geoff
> > > > >
> > > > >
> > > > > On 3 Jul 2014, at 11:59 am, Ilya Obshadko <ilya.obshadko@gmail.com
> >
> > > > wrote:
> > > > >
> > > > >> I'm not sure if this is a bug or not.
> > > > >>
> > > > >> Here's a scenario:
> > > > >>
> > > > >> Page.java
> > > > >>
> > > > >> public class Page {
> > > > >>   @Property
> > > > >>   private Entity entity;
> > > > >>
> > > > >>   void onActivate ( Long id ) {
> > > > >>       entity = retrieveFromDatabase ( id );
> > > > >>   }
> > > > >>
> > > > >> }
> > > > >>
> > > > >> Page.tml:
> > > > >>
> > > > >> <t:mycomponent entity="entity"/>
> > > > >>
> > > > >> MyComponent.tml:
> > > > >>
> > > > >> <t:form p:context="entity.id">
> > > > >> ...
> > > > >> </t:form>
> > > > >>
> > > > >>
> > > > >> AJAX is NOT used. If I get it right, form context must be passed
> to
> > > > >> enclosing page during form submission. However it doesn't work and
> > > > >> appropriate onActivate method is never called, although submission
> > URL
> > > > >> looks just like expected:
> > > > >> http://localhost:8080/application/page.mycomponent.form/12345
> > > > >>
> > > > >> Am I missing something here? I'm using 5.4-beta6
> > > > >>
> > > > >>
> > > > >> --
> > > > >> Ilya Obshadko
> > > > >
> > > >
> > > >
> > >
> > >
> > > --
> > > Ilya Obshadko
> > >
> >
>
>
>
> --
> Ilya Obshadko
>

Re: [T5.4] context isn't passed to enclosing page during form submit

Posted by Ilya Obshadko <il...@gmail.com>.
That's Hibernate entity, so I don't think ValueEncoder is necessary with
tapestry-hibernate.


On Thu, Jul 3, 2014 at 11:28 PM, Lance Java <la...@googlemail.com>
wrote:

> If you contribute an appropriate ValueEncoder for Entity, you won't need
> onActivate() / onPassivate(). You can use @PageActivationContext instead.
>
>
> On 3 July 2014 06:11, Ilya Obshadko <il...@gmail.com> wrote:
>
> > Oops my bad. I always try to forget about onPassivate ()
> > That should fix it, thanks!
> >
> >
> > On Thu, Jul 3, 2014 at 1:46 PM, Geoff Callender <
> > geoff.callender.jumpstart@gmail.com> wrote:
> >
> > > What's "t:ac"? In the POST's Form Data, "t:ac" is the key of the field
> > > that carries the page's activation context.
> > >
> > >
> > > On 3 Jul 2014, at 12:41 pm, Geoff Callender <
> > > geoff.callender.jumpstart@gmail.com> wrote:
> > >
> > > > Not a bug. Form bubbles up its context in the PREPARE_FOR_SUBMIT
> event.
> > > Here's a typical way to deal with it:
> > > >
> > > >       void onPrepareForSubmit(Long id) {
> > > >               this.id = id;
> > > >               entity = retrieveFromDatabase(id);
> > > >       }
> > > >
> > > > What should you pass in the context? At a minimum I'd recommend
> passing
> > > all the parameters of its enclosing component. Then, in
> > > onPrepareForSubmit(...) you can restore the component's parameter
> values
> > > (like we restored this.id above) before proceeding. In this way a
> > > component can behave independently rather than depending on its page.
> > When
> > > components get deeply nested then this is essential.
> > > >
> > > >
> > > > If you want the page's onActivate(Long id) to be invoked, then you'll
> > > need the *page's* context to include id, which you achieve by doing
> this
> > in
> > > the page:
> > > >
> > > >       Long onPassivate() {
> > > >               return id;
> > > >       }
> > > >
> > > > I'm guessing your page doesn't do that. Before clicking submit, the
> > page
> > > URL would look like this...
> > > >
> > > >       http://localhost:8080/application/page/12345
> > > >
> > > > ...and, on submit, the Form Data would include:
> > > >
> > > > t:ac:12345
> > > >
> > > > Geoff
> > > >
> > > >
> > > > On 3 Jul 2014, at 11:59 am, Ilya Obshadko <il...@gmail.com>
> > > wrote:
> > > >
> > > >> I'm not sure if this is a bug or not.
> > > >>
> > > >> Here's a scenario:
> > > >>
> > > >> Page.java
> > > >>
> > > >> public class Page {
> > > >>   @Property
> > > >>   private Entity entity;
> > > >>
> > > >>   void onActivate ( Long id ) {
> > > >>       entity = retrieveFromDatabase ( id );
> > > >>   }
> > > >>
> > > >> }
> > > >>
> > > >> Page.tml:
> > > >>
> > > >> <t:mycomponent entity="entity"/>
> > > >>
> > > >> MyComponent.tml:
> > > >>
> > > >> <t:form p:context="entity.id">
> > > >> ...
> > > >> </t:form>
> > > >>
> > > >>
> > > >> AJAX is NOT used. If I get it right, form context must be passed to
> > > >> enclosing page during form submission. However it doesn't work and
> > > >> appropriate onActivate method is never called, although submission
> URL
> > > >> looks just like expected:
> > > >> http://localhost:8080/application/page.mycomponent.form/12345
> > > >>
> > > >> Am I missing something here? I'm using 5.4-beta6
> > > >>
> > > >>
> > > >> --
> > > >> Ilya Obshadko
> > > >
> > >
> > >
> >
> >
> > --
> > Ilya Obshadko
> >
>



-- 
Ilya Obshadko

Re: [T5.4] context isn't passed to enclosing page during form submit

Posted by Lance Java <la...@googlemail.com>.
If you contribute an appropriate ValueEncoder for Entity, you won't need
onActivate() / onPassivate(). You can use @PageActivationContext instead.


On 3 July 2014 06:11, Ilya Obshadko <il...@gmail.com> wrote:

> Oops my bad. I always try to forget about onPassivate ()
> That should fix it, thanks!
>
>
> On Thu, Jul 3, 2014 at 1:46 PM, Geoff Callender <
> geoff.callender.jumpstart@gmail.com> wrote:
>
> > What's "t:ac"? In the POST's Form Data, "t:ac" is the key of the field
> > that carries the page's activation context.
> >
> >
> > On 3 Jul 2014, at 12:41 pm, Geoff Callender <
> > geoff.callender.jumpstart@gmail.com> wrote:
> >
> > > Not a bug. Form bubbles up its context in the PREPARE_FOR_SUBMIT event.
> > Here's a typical way to deal with it:
> > >
> > >       void onPrepareForSubmit(Long id) {
> > >               this.id = id;
> > >               entity = retrieveFromDatabase(id);
> > >       }
> > >
> > > What should you pass in the context? At a minimum I'd recommend passing
> > all the parameters of its enclosing component. Then, in
> > onPrepareForSubmit(...) you can restore the component's parameter values
> > (like we restored this.id above) before proceeding. In this way a
> > component can behave independently rather than depending on its page.
> When
> > components get deeply nested then this is essential.
> > >
> > >
> > > If you want the page's onActivate(Long id) to be invoked, then you'll
> > need the *page's* context to include id, which you achieve by doing this
> in
> > the page:
> > >
> > >       Long onPassivate() {
> > >               return id;
> > >       }
> > >
> > > I'm guessing your page doesn't do that. Before clicking submit, the
> page
> > URL would look like this...
> > >
> > >       http://localhost:8080/application/page/12345
> > >
> > > ...and, on submit, the Form Data would include:
> > >
> > > t:ac:12345
> > >
> > > Geoff
> > >
> > >
> > > On 3 Jul 2014, at 11:59 am, Ilya Obshadko <il...@gmail.com>
> > wrote:
> > >
> > >> I'm not sure if this is a bug or not.
> > >>
> > >> Here's a scenario:
> > >>
> > >> Page.java
> > >>
> > >> public class Page {
> > >>   @Property
> > >>   private Entity entity;
> > >>
> > >>   void onActivate ( Long id ) {
> > >>       entity = retrieveFromDatabase ( id );
> > >>   }
> > >>
> > >> }
> > >>
> > >> Page.tml:
> > >>
> > >> <t:mycomponent entity="entity"/>
> > >>
> > >> MyComponent.tml:
> > >>
> > >> <t:form p:context="entity.id">
> > >> ...
> > >> </t:form>
> > >>
> > >>
> > >> AJAX is NOT used. If I get it right, form context must be passed to
> > >> enclosing page during form submission. However it doesn't work and
> > >> appropriate onActivate method is never called, although submission URL
> > >> looks just like expected:
> > >> http://localhost:8080/application/page.mycomponent.form/12345
> > >>
> > >> Am I missing something here? I'm using 5.4-beta6
> > >>
> > >>
> > >> --
> > >> Ilya Obshadko
> > >
> >
> >
>
>
> --
> Ilya Obshadko
>

Re: [T5.4] context isn't passed to enclosing page during form submit

Posted by Ilya Obshadko <il...@gmail.com>.
Oops my bad. I always try to forget about onPassivate ()
That should fix it, thanks!


On Thu, Jul 3, 2014 at 1:46 PM, Geoff Callender <
geoff.callender.jumpstart@gmail.com> wrote:

> What's "t:ac"? In the POST's Form Data, "t:ac" is the key of the field
> that carries the page's activation context.
>
>
> On 3 Jul 2014, at 12:41 pm, Geoff Callender <
> geoff.callender.jumpstart@gmail.com> wrote:
>
> > Not a bug. Form bubbles up its context in the PREPARE_FOR_SUBMIT event.
> Here's a typical way to deal with it:
> >
> >       void onPrepareForSubmit(Long id) {
> >               this.id = id;
> >               entity = retrieveFromDatabase(id);
> >       }
> >
> > What should you pass in the context? At a minimum I'd recommend passing
> all the parameters of its enclosing component. Then, in
> onPrepareForSubmit(...) you can restore the component's parameter values
> (like we restored this.id above) before proceeding. In this way a
> component can behave independently rather than depending on its page. When
> components get deeply nested then this is essential.
> >
> >
> > If you want the page's onActivate(Long id) to be invoked, then you'll
> need the *page's* context to include id, which you achieve by doing this in
> the page:
> >
> >       Long onPassivate() {
> >               return id;
> >       }
> >
> > I'm guessing your page doesn't do that. Before clicking submit, the page
> URL would look like this...
> >
> >       http://localhost:8080/application/page/12345
> >
> > ...and, on submit, the Form Data would include:
> >
> > t:ac:12345
> >
> > Geoff
> >
> >
> > On 3 Jul 2014, at 11:59 am, Ilya Obshadko <il...@gmail.com>
> wrote:
> >
> >> I'm not sure if this is a bug or not.
> >>
> >> Here's a scenario:
> >>
> >> Page.java
> >>
> >> public class Page {
> >>   @Property
> >>   private Entity entity;
> >>
> >>   void onActivate ( Long id ) {
> >>       entity = retrieveFromDatabase ( id );
> >>   }
> >>
> >> }
> >>
> >> Page.tml:
> >>
> >> <t:mycomponent entity="entity"/>
> >>
> >> MyComponent.tml:
> >>
> >> <t:form p:context="entity.id">
> >> ...
> >> </t:form>
> >>
> >>
> >> AJAX is NOT used. If I get it right, form context must be passed to
> >> enclosing page during form submission. However it doesn't work and
> >> appropriate onActivate method is never called, although submission URL
> >> looks just like expected:
> >> http://localhost:8080/application/page.mycomponent.form/12345
> >>
> >> Am I missing something here? I'm using 5.4-beta6
> >>
> >>
> >> --
> >> Ilya Obshadko
> >
>
>


-- 
Ilya Obshadko

Re: [T5.4] context isn't passed to enclosing page during form submit

Posted by Geoff Callender <ge...@gmail.com>.
What's "t:ac"? In the POST's Form Data, "t:ac" is the key of the field that carries the page's activation context.


On 3 Jul 2014, at 12:41 pm, Geoff Callender <ge...@gmail.com> wrote:

> Not a bug. Form bubbles up its context in the PREPARE_FOR_SUBMIT event. Here's a typical way to deal with it:
> 
> 	void onPrepareForSubmit(Long id) {
> 		this.id = id;
> 		entity = retrieveFromDatabase(id);
> 	}
> 
> What should you pass in the context? At a minimum I'd recommend passing all the parameters of its enclosing component. Then, in onPrepareForSubmit(...) you can restore the component's parameter values (like we restored this.id above) before proceeding. In this way a component can behave independently rather than depending on its page. When components get deeply nested then this is essential.
> 
> 
> If you want the page's onActivate(Long id) to be invoked, then you'll need the *page's* context to include id, which you achieve by doing this in the page:
> 
> 	Long onPassivate() {
> 		return id;
> 	}
> 
> I'm guessing your page doesn't do that. Before clicking submit, the page URL would look like this...
> 
> 	http://localhost:8080/application/page/12345
> 
> ...and, on submit, the Form Data would include:
> 	
> t:ac:12345
> 
> Geoff
> 
> 
> On 3 Jul 2014, at 11:59 am, Ilya Obshadko <il...@gmail.com> wrote:
> 
>> I'm not sure if this is a bug or not.
>> 
>> Here's a scenario:
>> 
>> Page.java
>> 
>> public class Page {
>>   @Property
>>   private Entity entity;
>> 
>>   void onActivate ( Long id ) {
>>       entity = retrieveFromDatabase ( id );
>>   }
>> 
>> }
>> 
>> Page.tml:
>> 
>> <t:mycomponent entity="entity"/>
>> 
>> MyComponent.tml:
>> 
>> <t:form p:context="entity.id">
>> ...
>> </t:form>
>> 
>> 
>> AJAX is NOT used. If I get it right, form context must be passed to
>> enclosing page during form submission. However it doesn't work and
>> appropriate onActivate method is never called, although submission URL
>> looks just like expected:
>> http://localhost:8080/application/page.mycomponent.form/12345
>> 
>> Am I missing something here? I'm using 5.4-beta6
>> 
>> 
>> -- 
>> Ilya Obshadko
> 


Re: [T5.4] context isn't passed to enclosing page during form submit

Posted by Geoff Callender <ge...@gmail.com>.
Not a bug. Form bubbles up its context in the PREPARE_FOR_SUBMIT event. Here's a typical way to deal with it:

	void onPrepareForSubmit(Long id) {
		this.id = id;
		entity = retrieveFromDatabase(id);
	}

What should you pass in the context? At a minimum I'd recommend passing all the parameters of its enclosing component. Then, in onPrepareForSubmit(...) you can restore the component's parameter values (like we restored this.id above) before proceeding. In this way a component can behave independently rather than depending on its page. When components get deeply nested then this is essential.


If you want the page's onActivate(Long id) to be invoked, then you'll need the *page's* context to include id, which you achieve by doing this in the page:

	Long onPassivate() {
		return id;
	}

I'm guessing your page doesn't do that. Before clicking submit, the page URL would look like this...

	http://localhost:8080/application/page/12345

...and, on submit, the Form Data would include:
	
t:ac:12345

Geoff


On 3 Jul 2014, at 11:59 am, Ilya Obshadko <il...@gmail.com> wrote:

> I'm not sure if this is a bug or not.
> 
> Here's a scenario:
> 
> Page.java
> 
> public class Page {
>   @Property
>   private Entity entity;
> 
>   void onActivate ( Long id ) {
>       entity = retrieveFromDatabase ( id );
>   }
> 
> }
> 
> Page.tml:
> 
> <t:mycomponent entity="entity"/>
> 
> MyComponent.tml:
> 
> <t:form p:context="entity.id">
> ...
> </t:form>
> 
> 
> AJAX is NOT used. If I get it right, form context must be passed to
> enclosing page during form submission. However it doesn't work and
> appropriate onActivate method is never called, although submission URL
> looks just like expected:
> http://localhost:8080/application/page.mycomponent.form/12345
> 
> Am I missing something here? I'm using 5.4-beta6
> 
> 
> -- 
> Ilya Obshadko