HI On Sun, Aug 28, 2011 at 2:45 PM, cqasker <cqas...@yahoo.com> wrote: > I have some questions about linksubmit/submit in a loop. I have some enums > {e1, e2, e3} for example. In the loop I generate a linksubmit for each enum > and pass the enum in the linksubmit context parameter and an event called > "handleEnum" in the event parameter. From what I understand, theoretically > this linksubmit should generate a call to my "handleEnum" event handler so > I can set some properties and then later the onSuccess event handler method > should be invoked and . > > However 3 things happened that I didn't expect: > 1) The context expression "oneEnum" always evaluated to the last value of > the loop (e3) and only my ha ndleEnum method was called. When I converted > the LinkSubmit to a EventLink, this worked fine.
defer = false > 2) my onSuccess method was never called. When I moved the onSuccess method > form the component to the page where the form was defined, it was called. onSuccess method is part of the form-event-handling phase and are triggered by the form. As the events in tapestry bubble out to the outer components so inner components cannot handle them If you want to you can inject formsupport and then use storeAndExecute/execute methods to execution an action > 3) I noticed that in my onSuccess method, the parameter "handler" was null. The code in template does not show handler bound to any form field. Is it a service ? in that case, you have to @Inject it > On a submit, when are parameters re-bound? In Tapestry4, after a form > submission, the rewind was rebuilt from the encoded form state and all > components had their params rebound with the correct values and I was able > to access my parameters in my form submit listener methods. > > I am still learning tapestry 5 but can anyone explain these behaviors and > perhaps suggest a better method of getting what I want accomplished? I > pasted the relevant code below. > This might help http://tapestry.apache.org/component-events.html > The code is based on: > http://tapestry.apache.org/current/tapestry-core/ref/org/apache/tapestry5/corelib/components/Submit.html > inside a component I have: > <ul> > <t:loop source="someEnums" value="oneEnum"> > <li> > > > name of oneEnum > > > </li> > </t:loop> > </ul> > > and: > > public enum MyEnum {e1, e2, e3} > > @Parameter > private Handler handler; > > @Property > private MyEnum oneEnum; > > @Property > private MyEnum selectedEnum; > > public MyEnum[] getSomeEnums() > {return MyEnum.values();} > > @SuppressWarnings("unused") > @Component(parameters = {"event=enumHandle", "context=oneEnum"}) > private LinkSubmit linkEnum; > > @OnEvent(value = "enumHandle") > void handleEnumClick(String oneEnum) //oneEnum is always e3 > { > selectedEnum = MyEnum.valueof(oneEnum); > } > > Object onSuccess() //is not called unless I move to page class > { > handler.handle(selectedEnum); //the handler parameter is null > return null; > } > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/LinkSubmit-in-a-loop-tp4742981p4742981.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > > -- Regards Taha Hafeez Siddiqi (tawus) http://tawus.wordpress.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org