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.jumpst...@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.jumpst...@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.obsha...@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

Reply via email to