thanks that works partially. 

However, the event is only catched twice: 
1. on pageload (??m the sendRequest isn't called, but somehow the
getTheLink()-method is executed.)
2. the first time i send a onchange. 

However after the first onchange all other onchange-event don't get
getTheLink() executed, although sendRequest() is called on the client-side
each time. 

This is my relevant code: 

in  html: 
<script>
function sendRequest() 
    {
        alert("sendRequest reached");
        new Ajax.Request('${theLink}',
{asynchronous:true,onSuccess:handleResponse});
    } 
</script>
...
<select t:type="select" t:model="themaList" t:value="thema"
onchange="sendRequest()" name="thema" id="thema" tabindex="4" 
class="formElement"/>

in the page-class: 
        public String getTheLink() 
        {
                System.out.println("catched!!");
                return "catched!";
        } 

Do you 've got any idea what causes this behavior? 

Thanks,
Geert-Jan




HugoPalma wrote:
> 
> I would suggest that you use AJAX instead of doing the form submit. 
> Although the AJAX integration in T5 is still not implemented it's very 
> easy to do using the provided prototype and json javascripts. I did this 
> successfully for some simple events also.
> Shortly, here's how i did it:
> 
> In my page i have these two javascript functions:
> 
> function handleResponse(xhrResponse) {
>         var json = xhrResponse.responseText.evalJSON(true);
> 
>         //Do whatever you want with the server response
>     }
>     // -->
> 
>     function sendRequest() {
>             new Ajax.Request('${theLink}', {asynchronous:true, 
> onSuccess:handleResponse});
>     }
> 
> On the page class i have:
> 
> public String getTheLink() {
>         Link l = _resources.createActionLink("myAction", false);
>         return l.toURI();
>     }
> 
> public StreamResponse onMyAction() {
>         Collection<Casta> castas =
> _regiaoDao.getRegiao(regiao).getCastas();
> 
>         JSONObject jsonObject = new JSONObject();
>           // Add whatever info you want to send to the client
> 
>         return new TextStreamResponse("text/xml", jsonObject.toString());
>     }
> 
> And that's it. Works great. All you have to do now is call the 
> sendRequest function from whatever javascript event you want to catch.
> Hope this helps.
> 
> Britske wrote:
>> I have a use-case in which i need to catch a onchange of of
>> select-component
>> on the server-side. 
>> The only way I know how to do that is do a javascript
>> onchange='this.form.submit()' and catch the onsubmit() event on the
>> serverside.
>>
>> This works well when i don't have a submit-component in the form as well. 
>> However, when I do have a submit the onchange doesn't give a onsubmit()
>> on
>> the serverside anymore. 
>>
>> So, the onchange in the following snippet doesn't give a server side
>> onsubmit()-event:
>>
>> <body>
>> <form t:type="form" t:id="form" id="form">
>>      <select t:type="select" t:model="countryList" t:value="country"
>> onchange="this.form.submit();"/>
>>     <input t:type="Submit" value="All results"/>
>> </form>
>> </body>
>>
>> However, the following does:
>>
>> <body>
>> <form t:type="form" t:id="form" id="form">
>>      <select t:type="select" t:model="countryList" t:value="country"
>> onchange="this.form.submit();"/>
>>     <!--<input t:type="Submit" value="All results"/>-->
>> </form>
>> </body>
>>
>> This isn't expected behavior since both examples do work with plain html
>> form elements. 
>> anyone?
>>
>> Geert-Jan
>>   
> 
> 

-- 
View this message in context: 
http://www.nabble.com/t5-form-submit-not-fired-tf4645307.html#a13271036
Sent from the Tapestry - User mailing list archive at Nabble.com.


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

Reply via email to