You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mike Leonardo <mi...@ifactory.com> on 2008/08/08 22:59:27 UTC

T5: Form using Zone with two submits - possible bug?

Hello,
I have a form that uses the zone parameter so that the submission is handled as an Ajax reload.
The problem is that my form has two submit buttons, but Tapestry seems to always trigger the "selected" event for the first button, regardless of which one I click. 

I've created this small test page to prove it to myself:

MyTestPage.tml
----------
<t:zone id="testZone">
<t:form zone="testZone">
Value: ${value}
<t:textfield value="value" />
<input type="submit" t:type="submit" t:id="firstButton" value="Submit" />
<input type="submit" t:type="submit" t:id="secondButton" value="Submit2" />
</t:form>
</t:zone>


MyTestPage.java
-----------
public class MyTestPage {
	@Property private int value;
	@InjectComponent private Form form;
	
	void onSelectedFromFirstButton() {
		System.out.println("Reached First Button");
	}
	
	void onSelectedFromSecondButton() {
		System.out.println("Reached Second Button");
	}
}

Only my method "OnSelectedFromFirstButton" is visited, never the "OnSelectedFromSecondButton".
I also tried an onchange javascript event to just submit the form (i.e. not pushing any buttons) and it still triggers the first button event.
Is this is a bug, or do I not understand how this works?

Thanks for any help!
- Mike



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


Re: T5: Form using Zone with two submits - possible bug?

Posted by Angelo Chen <an...@yahoo.com.hk>.
a solution is documented on the wiki page:
http://wiki.apache.org/tapestry/Tapestry5HowToUseForms
look for "Dealing with multiple submits"


Mike Leonardo wrote:
> 
> Hello,
> I have a form that uses the zone parameter so that the submission is
> handled as an Ajax reload.
> The problem is that my form has two submit buttons, but Tapestry seems to
> always trigger the "selected" event for the first button, regardless of
> which one I click. 
> 
> I've created this small test page to prove it to myself:
> 
> MyTestPage.tml
> ----------
> <t:zone id="testZone">
> <t:form zone="testZone">
> Value: ${value}
> <t:textfield value="value" />
> <input type="submit" t:type="submit" t:id="firstButton" value="Submit" />
> <input type="submit" t:type="submit" t:id="secondButton" value="Submit2"
> />
> </t:form>
> </t:zone>
> 
> 
> MyTestPage.java
> -----------
> public class MyTestPage {
> 	@Property private int value;
> 	@InjectComponent private Form form;
> 	
> 	void onSelectedFromFirstButton() {
> 		System.out.println("Reached First Button");
> 	}
> 	
> 	void onSelectedFromSecondButton() {
> 		System.out.println("Reached Second Button");
> 	}
> }
> 
> Only my method "OnSelectedFromFirstButton" is visited, never the
> "OnSelectedFromSecondButton".
> I also tried an onchange javascript event to just submit the form (i.e.
> not pushing any buttons) and it still triggers the first button event.
> Is this is a bug, or do I not understand how this works?
> 
> Thanks for any help!
> - Mike
> 
> 
> 
> ---------------------------------------------------------------------
> 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://www.nabble.com/T5%3A-Form-using-Zone-with-two-submits---possible-bug--tp18898971p18902318.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: Form using Zone with two submits - possible bug?

Posted by Stephane Decleire <sd...@cariboo-networks.com>.
Hi Mike,

This is a bug tracked in JIRA as TAPESTRY-2324 and TAPESTRY-2505.

Stephane

Mike Leonardo a écrit :
> Hello,
> I have a form that uses the zone parameter so that the submission is handled as an Ajax reload.
> The problem is that my form has two submit buttons, but Tapestry seems to always trigger the "selected" event for the first button, regardless of which one I click. 
>
> I've created this small test page to prove it to myself:
>
> MyTestPage.tml
> ----------
> <t:zone id="testZone">
> <t:form zone="testZone">
> Value: ${value}
> <t:textfield value="value" />
> <input type="submit" t:type="submit" t:id="firstButton" value="Submit" />
> <input type="submit" t:type="submit" t:id="secondButton" value="Submit2" />
> </t:form>
> </t:zone>
>
>
> MyTestPage.java
> -----------
> public class MyTestPage {
> 	@Property private int value;
> 	@InjectComponent private Form form;
> 	
> 	void onSelectedFromFirstButton() {
> 		System.out.println("Reached First Button");
> 	}
> 	
> 	void onSelectedFromSecondButton() {
> 		System.out.println("Reached Second Button");
> 	}
> }
>
> Only my method "OnSelectedFromFirstButton" is visited, never the "OnSelectedFromSecondButton".
> I also tried an onchange javascript event to just submit the form (i.e. not pushing any buttons) and it still triggers the first button event.
> Is this is a bug, or do I not understand how this works?
>
> Thanks for any help!
> - Mike
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>