Re: [OT] Ajax - generic processStateChange

2005-06-23 Thread Marc Demlenne
Thank you Jeff, your solution is exactly what i was looking for. 

Now i'd have another question, still slightly off-topic in a
struts-list, but is there an ajax list ?

In order to keep compatibility for all users, including those who
don't enable JavaScript, I need to have a solution where ajax use is
usefull but not mandatory. Is there a some good practice to offer the
end-user a page that use AJAX if javascript is enabled, (with
supported-version), but fall back to a more classical way if not ?

Any help is welcome.


On 21/06/05, Jeff Beal [EMAIL PROTECTED] wrote:
 Event handlers have to be functions.  When you write
 'onreadystatechange = processStateChange(spanID);', the
 processStateChange() function is *immediately* executed, and the
 returned value is assigned to the event handler.  This works great if
 your processStateChange returns a function, but if it returns (for
 example) an int, there are problems.
 
 Use an anonymous JavaScript function for your event handler:
 
 function retrieveURL(name, spanID) {
   req.onreadystatechange = function() { processStateChange(spanID); };
 }
 
 On 6/21/05, Marc Demlenne [EMAIL PROTECTED] wrote:
 
  I'd like to have smthg like
  function retrieveURL(name, spanID) {
...
req.onreadystatechange = processStateChange(spanID) ;
...
  }
 
 


-- 
Marc Demlenne

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



Re: [OT] Ajax - generic processStateChange

2005-06-21 Thread Frank W. Zammetti
No, you cannot pass a paremter the way you are trying... 
req.onreadystatechange registers an event handler with the 
XMLHttpRequest object, and it just takes a reference to a function.


The way to handle this is to set the span ID in a page-scope variable 
that your state change handler will reference.


However, are you using my AjaxTags project for this?  If so, what you 
are trying to do is already supported, you simply use the stdInnerHTML 
handler attached to the event you want on the form element you want.


Frank

Marc Demlenne wrote:
Hi all, 


Using Ajax (with Struts, but it's not really a struts issue), is it
possible to use the function called processStateChange by Franck
with an argument ?

I would like to have one function beeing able to be used more times in
a page, updating different span zones according to the control who
called it.

Basically, in what Franck calls retrieveURL, we have : 
  req.onreadystatechange = processStateChange ;


I'd like to have smthg like
function retrieveURL(name, spanID) {
  ...
  req.onreadystatechange = processStateChange(spanID) ;
  ...
}

function processStateChange (spanID) {
  ...
  document.getElementById(spanID).innerHTML = req.responseText;
  ...
}

But this won't work. What would be the correct way to implement this ? 


Thanks a lot for any help !




--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com


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



Re: [OT] Ajax - generic processStateChange

2005-06-21 Thread Jeff Beal
Event handlers have to be functions.  When you write
'onreadystatechange = processStateChange(spanID);', the
processStateChange() function is *immediately* executed, and the
returned value is assigned to the event handler.  This works great if
your processStateChange returns a function, but if it returns (for
example) an int, there are problems.

Use an anonymous JavaScript function for your event handler:

function retrieveURL(name, spanID) {
  req.onreadystatechange = function() { processStateChange(spanID); };
}

On 6/21/05, Marc Demlenne [EMAIL PROTECTED] wrote:

 I'd like to have smthg like
 function retrieveURL(name, spanID) {
   ...
   req.onreadystatechange = processStateChange(spanID) ;
   ...
 }


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