View Full Version : problems with formUpdate

12 Dec 2006, 8:58 AM

I think there are problems with the function yahoo.ext.UpdateManager.formUpdate in the version 0.33-rc3 of yahoo UI ext.
To explain those problems here is a simple html form with two fields : parameter1 and parameter2 :
(sorry i didn't find how print html characters in this forum) :

[input type="text" name="parameter1" value="test1" /]
[input type="text" name="parameter2" value="test2" /]
[input type="button" value="test" onclick="ajaxFormUpdate('testForm','testDiv','/myAction.do' )" /]

The form is submitted via Ajax with the function ajaxFormUpdate :

function ajaxFormUpdate(formName, divId, action) {
var updater = getEl(divId).getUpdateManager();
updater.formUpdate(formName, action);

Here is the div for the ajax return :

The form's action, "myAction", simply gets the form parameters and prints them.
I have commentted the results :

public class MyAction extends Action {

public ActionForward execute(....., HttpServletRequest request, .....) {

String parameter1 = request.getParameter("parameter1");
System.out.println(parameter1); --] Prints "null"

String parameter2 = request.getParameter("parameter2");
System.out.println(parameter2); --] Prints "test2"

return null ;

You can see that the first parameter is not set, it should be "test1".
So i have debugged the function formUpdate, which calls the function YAHOO.util.Connect.setForm in order to build the form query string (parameter1=value1&parameter2=value2...) before ajax call.
The form query string, which is the property named _sFormData in the class YAHOO.util.Connect, is set to this value when i submit my form :


The first parameter could not be found since its name is concatenated with "null".
That is the problem : the property sFormData of class YAHOO.util.Connect is initialized to null.
It should be initialized with an empty string ("").
Particularly this initialization should be done in the function setForm, before the "for" statement which analyse the form fields.
Or else the query string "grows" as you submit your form several times and contains parameters doubloons :


This proposition fix the problem :
in the function YAHOO.util.Connect.setForm (yahoo ext version : 0.33-rc3), add the line " this._sFormData=''; " before the for statement :

// Iterate over the form elements collection to construct the
// label-value pairs.
setForm:function(formId, isUpload, secureUri)
this._sFormData=''; // line to add

for (var i=0; i[oForm.elements.length; i++){
oElement = oForm.elements[i];
oDisabled = oForm.elements[i].disabled;




12 Dec 2006, 9:34 AM
That's a YUI bug, not a YUI-ext bug. YAHOO.util.Connect is part of YUI - you should check whether this issue has been raised on their support forum.

FYI: to get HTML to post correctly in your message, click the 'Disable HTML in this post' box

12 Dec 2006, 11:02 AM
I think it's a bug I reported to YAHOO in a previous version of YUI. Try upgrading to 0.12.