You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Stephan Windmüller <st...@cs.tu-dortmund.de> on 2009/09/10 14:11:55 UTC

Dynamically creating submit buttons, how to call submit methods?

Hello!

On a page I am looping over a list of objects. In each iteration I want
to place a button which calls an action upon the iterated object.

So basically I have something like this:

<t:loop t:source="objetcs" t:value="current" t:formState="iteration">
	<t:submit t:id="toggleState" t:context="current"/>
</t:loop>

This will not work, the id has to be unique. But how do I dynamically
generate submit buttons and calls actions in a context when they are
pressed?

TIA
 Stephan

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


Re: Dynamically creating submit buttons, how to call submit methods?

Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
Stephan Windmüller wrote:

> I tried it and at first all seemed work. But then I recognized that each
> time the system behaves like I pressed the _last_ button. The context is
> always the same, regardless of which button I press.

Hm, the above behaviour might be related to this thread:

http://www.nabble.com/5.1.0.1-SNAPSHOT-submit-context-not-workin-in-a-loop-td22379936.html

Regards
 Stephan

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


Re: Dynamically creating submit buttons, how to call submit methods?

Posted by Stephan Windmüller <st...@cs.tu-dortmund.de>.
Thiago H. de Paula Figueiredo wrote:

>> <t:loop t:source="objetcs" t:value="current" t:formState="iteration">
>> 	<t:submit t:id="toggleState" t:context="current"/>
>> </t:loop>
>> This will not work, the id has to be unique.
> You could annotate your event handler method with  
> @OnEvent(EventConstants.SELECTED) and use the context to disambiguate  
> between them.

I tried it and at first all seemed work. But then I recognized that each
time the system behaves like I pressed the _last_ button. The context is
always the same, regardless of which button I press.

My code:

<input t:type="submit" t:context="[firstObject, secondObject]"/>

@OnEvent(EventConstants.SELECTED)
public void onSelectedFromEditButton(Object1 first, Object2 second) {
 ...
}

Regards
 Stephan

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


Re: Dynamically creating submit buttons, how to call submit methods?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Thu, 10 Sep 2009 09:11:55 -0300, Stephan Windmüller  
<st...@cs.tu-dortmund.de> escreveu:

> Hello!

Hi!

> <t:loop t:source="objetcs" t:value="current" t:formState="iteration">
> 	<t:submit t:id="toggleState" t:context="current"/>
> </t:loop>
> This will not work, the id has to be unique.

You could annotate your event handler method with  
@OnEvent(EventConstants.SELECTED) and use the context to disambiguate  
between them.

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

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