We're running against MyFaces 2.1 and we have some code on the client that calls getViewState(aValidFormReference) during the intial rendering of the page. It's causing a JavaScript error and preventing proper operation after the page has loaded. The flow of execution looks like this:

1) We call getViewState(aValidFormReference).

2) The getViewState function does some checking and processing which includes:

    ...
    var ajaxUtils = new myfaces._impl.xhrCore._AjaxUtils(0);
    ...
    ajaxUtils.encodeSubmittableFields(ret, null, null, form, null);
    ...

Two things to note about this.

a) The AjaxUtils is created without any onWarning or onException handlers (which it ends up complaining later). b) The encodeSubmittableFields function expects to get the following parameters:

function(targetBuf, request, context, item, parentItem, partialIds)

So the valid form instance is set as the item parameter but parentItem is set to null (as we're already passing in the form per the getViewState signature). Looking at what the encodeSubmittableFields function does shows that the first thing it checks for is the parentItem:

    ...
    try {
        if (!parentItem) {
this._onWarning(request, context, "myfaces._impl.xhrCore._AjaxUtils", "encodeSubmittableFields " + "Html-Component is not nested in a Form-Tag");
            return null;
        }
    ...

Since there is nothing for handling onWarning, it then falls through to the catch code and tries to do an onException, which also fails. I'm not sure if there are 1 or more bugs involved here.

Should there be a check to see if the item passed in to encodeSubmittableFields is a form to begin? Should the AjaxUtils be created with proper onWarning and onException handlers? Should the form be passed in as the parentItem rather than the item to be processed (or perhaps the parameter order is not correct)?

I can create JIRAs as necessary once I understand which behaviour is problematic.

Deryk

Reply via email to