Hello. Your HTML looks a bit strange - you're opening a 'head' tag but not
closing it before the body opens. Also you have input items that are
appearing outside of the form scope. Sort out your HTML template and try
again - I'd be interested to know how you go.



Ulrich Stärk wrote:
> 
> I'd like to bring up an issue I already posted to the user mailing list 
> but got no response for:
> 
> Today I noticed a strange behaviour of T4's EventListeners. I wanted an 
> Any component which renders as a button to submit a form and call my 
> listener method after form submission. The docs say that's what the 
> EventListener's submitForm parameter is for. So I went about and wrote 
> an EventListener, targeted it at my Any component, made it listen to the 
> onclick event and set submitForm to my form (page class and HTML 
> template below). When I tested my work nothing at all happened. I then 
> checked the generated HTML and found that Tapestry did not generate any 
> event connection code. When I removed the submitForm parameter it 
> suddenly did and my listener method got called the way it's supposed to.
> 
> I dived into T4's sources and found out the following:
> 
> In ComponentEventConnectionWorker Tapestry stores a list of event 
> connections to form components which are not rendered yet and renders 
> those when the corresponding form component gets rendered. It stores 
> those connections in a Map and uses the form's _id_ as a key (in 
> filterFormEvents on line 412). It then checks all components whether 
> they got deferred connections to be set up by querying the map using the 
> component's _extended id_ and therefore never finds any deferred 
> connections for any component. I changed isDeferredForm, 
> linkDeferredForm and mapFormNames to use the form's id and suddenly 
> Tapestry generates the connection setup javascript code and my form's 
> submit listener gets called.
> 
> But my listener methods which I annotated with the EventListener 
> annotation still don't get called.
> 
> Am I doing something wrong or is this a bug in Tapestry for which I 
> should file an issue?
> 
> Uli
> 
> page class:
> 
> public abstract class TestPage extends BasePage
> {
>      public abstract boolean getChecked();
> 
>      @EventListener(targets="submitFormAsync", events="onclick", 
> submitForm="myForm", async=true)
>      public void submitFormAsync() {
>          System.out.println("EventListener called from submitFormAsync");
>      }
> 
>      @EventListener(targets="submitForm", events="onclick", 
> submitForm="myForm")
>      public void submitForm() {
>          System.out.println("EventListener called from submitForm");
>      }
> 
>      @EventListener(targets="callListenerAsync", events="onclick", 
> async=true)
>      public void callListenerAsync() {
>          System.out.println("EventListener called from
> callListenerAsync");
>      }
> 
>      public void formListener()
>      {
>          System.out.println("Form's listener got called");
>          System.out.println("checked: " + getChecked());
>      }
> }
> 
> page template:
> 
> <html jwcid="@Shell" title="Test Page"
>    xmlns='http://www.w3.org/1999/xhtml'
>    doctype='html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" 
> \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\";'
>    debugEnabled="true"
>    browserLogLevel="DEBUG"
>    consoleEnabled="true">
> <head>
> <title>Test Page</title>
> <body jwcid="@Body">
> <form jwcid="[EMAIL PROTECTED]" listener="listener:formListener">
> <input jwcid="@Checkbox" value="ognl:checked" /><br />
> 
> </form>
> <p><input jwcid="[EMAIL PROTECTED]" type="button" value="literal:submit 
> form via EventListener" /></p>
> <p><input jwcid="[EMAIL PROTECTED]" type="button" 
> value="literal:submit form async via EventListener" /></p>
> <p><input jwcid="[EMAIL PROTECTED]" type="button" 
> value="literal:call an EventListener async without submitting the Form" 
> /></p>
> </body>
> </html>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/T4-EventListeners-and-formSubmit-tp15700830p16750982.html
Sent from the Tapestry - Dev mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to