users@woodstock.java.net

Woodstock + AJAX

From: Rashanova <rasha.abdallah_at_murex.com>
Date: Tue, 30 Oct 2007 07:01:20 -0700 (PDT)

Hello,
I am trying to understand how the submit() and refresh() functions of ajax
components work.

I have tried to setup the following code using pure jsf-extensions (dynamic
faces):
<webuijsf:textField binding="#{ManageSession.txtID}" id="txtID"
                                                   
onChange="DynaFaces.fireAjaxTransaction(this, { execute: 'form1:txtID'});"
valueChangeListenerExpression="#{ManageSession.txtID_processValueChange}"/>

The code works in an excellent way since rendering the components on the
page will only take place after the ajax response comes back.

However I have tried to achieve the same effect using the submit and refresh
functions of the ajax components by writing something like:
function changeEvent() {
var node1 = document.getElementById("form1:txtID");
node1.submit();
var domNode = document.getElementById("form1:textField2");
domNode.refresh();
}

The problem with the above code is that the refresh function is NOT waiting
for the ajax response to come back. and Hence it is not picking up the
latest value from the server. The only way I was able to get around this is
by moving the "refresh" part to another function and using the setTimeout as
follows:
 function changeEvent(){
     var node1 = document.getElementById("form1:txtID");
      node1.submit();
      setTimeout('updateSessionInfo()',1000);
}
                        
 function updateSessionInfo() {
        var domNode = document.getElementById("form1:textField2");
         domNode.refresh();
}

1- Is there away I can get around this problem, and force the refresh to
take place ONLY after the ajax response comes back to the client?
2- If not, how can I create a call back function on the client side that
will wait for the ajax response in order to execute?
3- Since the first code snippet above (one using pure jsf dynamic faces)
works fine, what is the benefit of the submit and refresh functions
introduced into woodstock? and is it a good practice to use dynamic faces
and I did in the above example?

THanks a lot!




                                
-- 
View this message in context: http://www.nabble.com/Woodstock-%2B-AJAX-tf4718627.html#a13489211
Sent from the Project Woodstock - Users mailing list archive at Nabble.com.