You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by lebenski <be...@gamesys.co.uk> on 2010/01/31 19:09:11 UTC

T5 - Forms created inside a loop don't fire onSuccess methods

Hi,

This is my code:

<t:loop source="draft.draftPicks" value="draftPick" volatile="true">
   <t:form t:id="pickCommentForm">
    ...
      <t:submit value="message:submit-label" />
   </t:form>
</t:loop>

This results in multiple forms getting rendered on my page; pickCommentForm,
pickCommentForm_0, pickCommentForm_1 etc.

I'm obsering that submitting this form does not fire
onSuccessFromPickCommentForm or even just onSuccess, onValidateForm etc.  Is
this because i've created multiple forms with the same id?  If so, is there
a way to support form creation inside a loop like this?

Object onSuccessFromPickCommentForm() {
  createPickComment(draftPick, getNewComment());
....

}
-- 
View this message in context: http://old.nabble.com/T5---Forms-created-inside-a-loop-don%27t-fire-onSuccess-methods-tp27395072p27395072.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5 - Forms created inside a loop don't fire onSuccess methods

Posted by lebenski <be...@gamesys.co.uk>.
Thanks - got this working! 


Thiago H. de Paula Figueiredo wrote:
> 
> On Sun, 31 Jan 2010 16:09:11 -0200, lebenski <be...@gamesys.co.uk> wrote:
> 
>> Hi,
> 
> Hi!
> 
>> This is my code:
>> <t:loop source="draft.draftPicks" value="draftPick" volatile="true">
>>    <t:form t:id="pickCommentForm">
>>     ...
>>       <t:submit value="message:submit-label" />
>>    </t:form>
>> </t:loop>
>>
>> I'm obsering that submitting this form does not fire
>> onSuccessFromPickCommentForm or even just onSuccess, onValidateForm  
>> etc.  Is this because i've created multiple forms with the same id?  If  
>> so, is there a way to support form creation inside a loop like this?
> 
> Each Form component has a different id. Just use onSuccess() and use  
> draftPick as the context to your form. Something like this:
> 
> <t:loop source="draft.draftPicks" value="draftPick" volatile="true">
>      <t:form t:id="pickCommentForm" t:context="draftPick.id">
>       ...
>         <t:submit value="message:submit-label" />
>      </t:form>
>   </t:loop>
> 
> 
> Object onSuccess(Integer id) {
>     DraftPick draftPick = load(id);
>     createPickComment(draftPick, getNewComment());
> }
> 
> By the way, you don't need to use the Submit component unless you have  
> more than one submit button in the same form.
> 
> -- 
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
> and instructor
> Owner, software architect and developer, Ars Machina Tecnologia da  
> Informação Ltda.
> http://www.arsmachina.com.br
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/T5---Forms-created-inside-a-loop-don%27t-fire-onSuccess-methods-tp27395072p27400845.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: T5 - Forms created inside a loop don't fire onSuccess methods

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Sun, 31 Jan 2010 16:09:11 -0200, lebenski <be...@gamesys.co.uk> wrote:

> Hi,

Hi!

> This is my code:
> <t:loop source="draft.draftPicks" value="draftPick" volatile="true">
>    <t:form t:id="pickCommentForm">
>     ...
>       <t:submit value="message:submit-label" />
>    </t:form>
> </t:loop>
>
> I'm obsering that submitting this form does not fire
> onSuccessFromPickCommentForm or even just onSuccess, onValidateForm  
> etc.  Is this because i've created multiple forms with the same id?  If  
> so, is there a way to support form creation inside a loop like this?

Each Form component has a different id. Just use onSuccess() and use  
draftPick as the context to your form. Something like this:

<t:loop source="draft.draftPicks" value="draftPick" volatile="true">
     <t:form t:id="pickCommentForm" t:context="draftPick.id">
      ...
        <t:submit value="message:submit-label" />
     </t:form>
  </t:loop>


Object onSuccess(Integer id) {
    DraftPick draftPick = load(id);
    createPickComment(draftPick, getNewComment());
}

By the way, you don't need to use the Submit component unless you have  
more than one submit button in the same form.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

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