+ Start a Discussion
tyshocktyshock 

AJAX Toolkit Feedback

I just wanted to provide some feedback on my experiences with getting up-to-speed with the AJAX toolkit.  A couple of my criticisms stem from the fact that some of the code from blog entry "http://blog.sforce.com/sforce/2006/04/ajax_toolkit_be.html" does not seem to work.
 
I could not get the browsersupport javascript to 'auto-append' when following the instuctions from the referenced blog.  It said I could add a query string variable to the script URL, but I couldn't get that to work.  I had to add a second include statement.  Not a big inconvenience to do this, but it did cost me ~15-20 minutes of time to figure out.
 
 
The Property.bind() calls referenced don't work.  Or, if they do work, they are not straightforward to use.  In the blog, Dave uses:
 
dynaBean.getItem("Name").bind("nameField");
 
This will not work.  Looking at the code, it appears to expect a handle to the actual element as a parameter, ie:
 
dynaBean.getItem("Name").bind(document.getElementById("nameField") );
 
However, that call didn't work either.  I didn't dig any further.
 
Once I figured out how autobinding works, single binds didn't even matter for the task at hand. However, a powerful point on autobinding that I had to 'figure out for myself' was that the fields being bound will use 'introspection' on their target form elements to render themselves. Thus, if I bind a picklist to a text field, it is just a flat field with the current value populated.  But, if I bind a picklist to a select field, it is rendered as a full select list with all picklist options.  I like this!

That's it for now.  I'll provide more feedback in the future as I begin to tackle more complex tasks than simple CRUD operations.
 
Thanks!
DevAngelDevAngel
Tyshock,

Thanks for the feedback.  I've been using the browser=true parameter for a very long time now and it does work.  https://www.salesforce.com/services/lib/ajax/beta3.3/sforceclient.js?browser=true needs to be the src of a script tag.  Just pasting that url into firefox to view the complete set of js files will not work.  (The technique used is to add a new script tag to the head element of a page, so it must be in the context of a well formed html page).   Please elaborate on your usage so that I can cover the bases.

The property binding does requre an element reference.  The blog will be corrected to indicate this.  I may also modify the toolkit to accept a reference or an id string.  I like the id string as it promotes cleaner code.  When using getElementById the binding works as suggested.  Make sure your using the id attribute on your elements and not the name attribute.  Also, the ids must be unique.  This is different from the afBind attribute type of binding where ids are not used.

You can also add another parameter to the propert.bind function like:

Code:
 obj.getItem("Level__c").bind(document.getElementById("txtLevel"), true);

This will cause the element txtLevel to be replaced by an element that is appropriate for the type of field being bound.  In the code above, Level__c is a picklist and element txtLevel is a text field.  When the page is rendered and Level__c is bound to txtLevel, txtLevel is replaced with a select element with the appropriate picklist values populated and the actual field value selected.  This method does not currently provide the level of control for layout that you might like, so using the appropriate element for the binding is probably better.

Please keep up the good feedback as I take it all to heart.

Cheers

tyshocktyshock

OK, the browser=true does work as you stated.  Like you guessed, I was just pasting the 2 urls in firefox and assuming there was some serverside magic going on to concat the 2 scripts together. 

I could never get the single field binds to work, even as you suggested.  I would get you a code sample where i'm having problems, but i switched to full autobind many iterations ago.  If I run into it again, i will be sure to post.

On that blog entry, you also have the autobind syntax example using the attribute 'sfBind' instead of 'afBind'.  That should be corrected. 

Thanks

 

 

 

 

tyshocktyshock

I can confirm more problems with the binding.

If you define a field with the autobind attribute, then include the name and usewidget (ie, afBind='name=CloseDate;useWidget=true'), then the calendar widget will not correctly set the value of the input element, and the input element will not correctly map to the dynabean.

 

DevAngelDevAngel
UseWidget should not be used.  This has never been fleshed out to the point of surfacing in a public way.
ClintHegneyClintHegney
Any way to view this documentation other than the link that was provided in the post by tyshock? Some of the text is cut off on the right hand side of the content area and I would like to be able to see that. Thanks.