You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Allen Guo <el...@gmail.com> on 2007/05/29 04:33:21 UTC

Trigger different behavior by clicking the different button in Tapestry5.0.4

Hi All,

There are two submit button on html template below.
....
<input type="submit" t:id="update" value="UPDATE"/>
<input type="submit" t:id="back" value="BACK"/>
....

I would like to trigger a defferent method in Page class when clicking
each button. So the page class looks like
.....
public void onUpdate(){....}
public void onBack(){.....}
....
You know, if the action is just ActionLink or PageLink, I know how I can
do it.
But for button type is 'submit', what should I do?

Thanks in advanced
Allen Guo



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


RE: Trigger different behavior by clicking the different button in Tapestry5.0.4

Posted by Ben Sommerville <be...@bulletproof.com.au>.
Hi Allen,

You can use

public void onSelectedFromUpdate(){...}
public void onSelectedFromBack(){...}

A couple of things to note:
- all the standard form events (prepare, submit, validate, etc) will also
be invoked.
  I believe that selected events will be invoked between prepare and
validate
- onSelected methods must return void, so you can't do navigation from
them.  
  If you want to navigate based on the submit button you need to set a
flag/enum in the 
  onSelected method & return a page based on that from
onSuccess/onSubmit/etc

cheers
Ben

> -----Original Message-----
> From: Allen Guo [mailto:elon.guo@gmail.com] 
> Sent: Tuesday, 29 May 2007 12:33 PM
> To: Tapestry users
> Subject: Trigger different behavior by clicking the different 
> button in Tapestry5.0.4
> 
> Hi All,
> 
> There are two submit button on html template below.
> ....
> <input type="submit" t:id="update" value="UPDATE"/>
> <input type="submit" t:id="back" value="BACK"/>
> ....
> 
> I would like to trigger a defferent method in Page class when clicking
> each button. So the page class looks like
> .....
> public void onUpdate(){....}
> public void onBack(){.....}
> ....
> You know, if the action is just ActionLink or PageLink, I 
> know how I can
> do it.
> But for button type is 'submit', what should I do?
> 
> Thanks in advanced
> Allen Guo
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 


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