Posted by Charles Palmer
on 13.05.2006 21:26
Hi Guys

I am playing with Rico for the first time and thought I would simplify 
some of the examples on your demo pages. I succeeded with the first one 
(inner HTML) - see here:
http://acutetech.railsplayground.net/rico/rolodemo/innerHTML.html
but have failed with the second (Form Letter Updater) - see here:
http://acutetech.railsplayground.net/rico/rolodemo/formletter.html

The problem seems to be in formLetterUpdater.js in setPerson, when the 
Ajax response comes back. It looks like aPerson.getAttribute does not 
exist, so aPerson.getAttribute(attr) won't work, which prevents the 
update proceeding as intended. (perhaps because ajaxUpdate is getting 
the wrong object?)

I've added some debug messages into the code at the above URL.

As far as I can see, my server-side php script is returning identical 
XML as the Rico demo (see here:
http://openrico.org/rico/ajax_person_info_xml?firstName=Debbie&lastName=Holloman
and here:
http://acutetech.railsplayground.net/rico/rolodemo/php/ajax_person_info_xml.php?firstName=Debbie&lastName=Holloman

Any suggestions gratefully received. I'm stuck!

Charles Palmer
Posted by Charles Palmer
on 13.05.2006 22:03
PS - I had been working with Firefox 1.5. I've tried it with IE 6.0 and 
it behaves differently (less debug info displayed).
Posted by Tam Pham (Guest)
on 14.05.2006 15:09
Charles,

In method ajaxUpdate, make sure this call "ajaxResponse.childNodes[0]" 
returns the whole "person" element. You can also try using 
ajaxResponse.getElementsByTagName('person'). Please print out the 
response on the client side using RicoUtil.getContentAsString(element)


Regards
Posted by Charles Palmer
on 14.05.2006 20:59
Found it!

(Thanks to Tam for his pointer which got me going...)

My php script that generates the xml (ajax_person_info_xml.php) was 
generating xml with white space in it (newlines, tabs, spaces etc). That 
was obviously screwing up the ajaxResponse.childNodes[0] etc. 
Interestingly, white space does not seem to matter in the other example 
(innerHTML) which uses ajaxEngine.registerAjaxElement instead of 
ajaxEngine.registerAjaxObject.

I think I remember reading something about "white space bad" in xml, but 
it's never troubled me before. Is this a general feature of parsing xml?

Regards - Charles
Posted by Hans Mauser (Guest)
on 22.06.2006 10:26
Hmm, i tested it with static a static Xml-file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ajax-response>
<response type="object" id="formLetterUpdater">
<person title="Mrs." fullName="Debbie Holloman"
firstName="Debbie"
lastName="Holloman"
streetAddress="2243 Fallenwood Street"
city="Dallas"
state="TX"
zipcode="75555-3483"
occupation="Administrative Assistant"
phoneNumber="(214) 555-2343"
mobileNumber="(214) 555-2144"
personNotes="Has a house on the east-side by my cousin." />
</response>
</ajax-response>

but even without spaces / tabs in it, i get:

"aPerson.getAttribute is not a function" !!!

in formLetterUpdater.js Line:22
Posted by Benjamin Ben
on 15.01.2007 12:29
I have the same kind of problems !

RicoUtil.getContentAsString(ajaxResponse);
give me this :
<person title="Mrs." fullName="Debbie Holloman" firstName="Debbie" 
lastName="Holloman" streetAddress="2243 Fallenwood Street" city="Dallas" 
state="TX" zipcode="75555-3483" occupation="Administrative Assistant" 
phoneNumber="(214) 555-2343" mobileNumber="(214) 555-2144" 
personNotes="Has a house on the east-side by my cousin." />

RicoUtil.getContentAsString(ajaxResponse.childNodes[0]);
is empty!!!

My data.xml called by ajaxEngine.registerRequest is:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ajax-response>
<response type="object" id="formLetterUpdater">
<person title="Mrs." fullName="Debbie Holloman" firstName="Debbie" 
lastName="Holloman" streetAddress="2243 Fallenwood Street" city="Dallas" 
state="TX" zipcode="75555-3483" occupation="Administrative Assistant" 
phoneNumber="(214) 555-2343" mobileNumber="(214) 555-2144" 
personNotes="Has a house on the east-side by my cousin." />
</response>
</ajax-response>


So when my update script is running:
ajaxUpdate: function(ajaxResponse) {
    this.setPerson(ajaxResponse.childNodes[0]);
}

in setPerson:
aPerson.getAttribute('streetAddress') is empty.

Does someone have an idea? With an element registering 
ajaxEngine.registerAjaxElement evreything work, but when I try an object 
registering : ajaxEngine.registerAjaxObject( 'formLetterUpdater', 
formLetterUpdater ); I've got this bug.

Regards
Posted by Benjamin Ben
on 15.01.2007 16:51
More info

//if I try
var debug = ajaxResponse.getElementsByTagName("*");

// then the getAtribute fonction work
debug[0].getAttribute('fullName'); //return Debbie Holloman

// If I try ask var debug = ajaxResponse.getElementsByTagName("person"); 
it
// doesn't work. Any ideas?