Volker,

I've been playing with the dojo.io.bind stuff lately, after having used 
Prototype for awhile, and there indeed is no built-in equivalent to the 
Ajax.Updater in Prototype. 

BUT, what Ajax.Updater does can be pretty easily replicated in your own 
javascript class, as what it is actually doing behind the scenes is relatively 
simple.  In many other cases, I have tended to find that the Ajax.Updater stuff 
is overly simple, and I've needed to use custom responders anyway.

By default, Ajax.Updater just uses innerHTML to do the replacing of your 
"container" with any HMTL returned from the server.  If that is all you need 
(along with eval'ing any script blocks), it is pretty easy to replicate in your 
own handler method. 

In my own experience, I've needed more than this.  For example, what if you 
need to refresh multiple components on the page that are not all children of 
some "ajax zone" sort of container?  I.E., the "partial rendering" approach.  
Then you would generally have multiple fragments of HTML returned that all need 
to be treated separately.  Ajax.Updater does not handle this directly, but I've 
found that dojo has some utility methods such as dojo.html.createNodesFromText 
that make this pretty easy to do in a custom handler.

I'd be happy to take a look at any Tobago code you have in mind and assist in 
converting it over to use dojo. 

- Jeremy   

-----Original Message-----
From: Volker Weber [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, April 18, 2006 7:42 AM
To: MyFaces Development
Subject: Re: Which Javascript library to use for AJAX components?

Hi,

dojo.io.bind is a replacment for prototypes Ajax.Request.

the Ajax.Updater replaces the content of a html element with the
response of a ajax request, including optional evaluating of javascript
content.

e.g

---------- begin html ----------------

<div id="divId" >
  [ any content. e.g. complete tobago sheet]
</div>

<button onclick="replaceDivContent('divId')"> Do ajax request</button>

---------- end html ----------------

---------- begin javascript ----------------

function replaceDivContent(id) {

  var options = {
    method: 'post',
    asynchronous: true,
    parameters: '',
    evalScripts: true
  };

  var div = document.getElementById('id');

  // Tobago.form is the html form element
  var url = Tobago.form.action + "?affectedAjaxComponent="
    + id + '&' + Form.serialize(Tobago.form);

  new Ajax.Updater(container, url, options);
}

---------- end javascript ----------------



Regards,
  Volker


Gerald Müllan wrote:
> Hi Volker,
> 
> Yes, sure. I can not remember the Ajax.Updater functionality exactly,
> but dojo provides a really easy to use Ajax api. I think the
> dojo.io.bind stuff should be the one, you are searching for.
> 
> Just code:
> 
> dojo.io.bind({
>     url: "...",
>     load: function(type, evaldObj){ /* do something */ },
>     mimetype: "text/plain",
>     transport: "XMLHTTPTransport"
> });
> 
> A pretty good intro about dojo.io.bind can be found at:
> 
> http://dojotoolkit.org/docs/intro_to_dojo_io.html
> 
> Hope that helps,
> 
> regards,
> 
> Gerald
> 
> On 4/18/06, Volker Weber <[EMAIL PROTECTED]> wrote:
> 
>>Hi Gerald,
>>
>>is there a equivalent for Ajax.Updater from prototype.js in dojo?
>>
>>I like to test replacement of prototype.js in tobago, but i don't like
>>to reimplement this.
>>
>>Regards,
>>  Volker
>>
>>
>>Gerald Müllan wrote:
>>
>>>Hi,
>>>
>>>you should use the dojo library in all future components wherever possible.
>>>
>>>We want to completely left out prototype and other js libraries in the 
>>>future.
>>>
>>>Which component you wanna realize?
>>>
>>>cheers,
>>>
>>>Gerald
>>>
>>>On 4/18/06, sharath reddy <[EMAIL PROTECTED]> wrote:
>>>
>>>
>>>>Hello,
>>>>
>>>>I am planning to develop an AJAX component for
>>>>MyFaces. I looked at the exising components to see
>>>>which Javascript libary they used.
>>>>
>>>>Some components use Dojo. Others use Prototype!
>>>>
>>>>Which one is the standard going forward?
>>>>
>>>>Regards,
>>>>Sharath
>>>>
>>>>__________________________________________________
>>>>Do You Yahoo!?
>>>>Tired of spam?  Yahoo! Mail has the best spam protection around
>>>>http://mail.yahoo.com
>>>>
>>>
>>>
>>>
>>>--
>>>Gerald Müllan
>>>Schelleingasse 2/11
>>>1040 Vienna, Austria
>>>0043 699 11772506
>>>[EMAIL PROTECTED]
>>>
>>
>>--
>>Don't answer to From: address!
>>Mail to this account are droped if not recieved via mailinglist.
>>To contact me direct create the mail address by
>>concatenating my forename to my senders domain.
>>
> 
> 
> 
> --
> Gerald Müllan
> Schelleingasse 2/11
> 1040 Vienna, Austria
> 0043 699 11772506
> [EMAIL PROTECTED]
> 

-- 
Don't answer to From: address!
Mail to this account are droped if not recieved via mailinglist.
To contact me direct create the mail address by
concatenating my forename to my senders domain.

Reply via email to