You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by "Werner Punz (JIRA)" <de...@myfaces.apache.org> on 2011/06/18 20:59:47 UTC

[jira] [Updated] (MYFACES-3178) jsf.js: Calling jsf.getViewState() with a direct reference to a form element throws an exception

     [ https://issues.apache.org/jira/browse/MYFACES-3178?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Werner Punz updated MYFACES-3178:
---------------------------------

       Resolution: Fixed
    Fix Version/s: 2.1.2-SNAPSHOT
                   2.0.8-SNAPSHOT
           Status: Resolved  (was: Patch Available)

Thanks for reporting the bug and sending in the patch.


> jsf.js: Calling jsf.getViewState() with a direct reference to a form element throws an exception
> ------------------------------------------------------------------------------------------------
>
>                 Key: MYFACES-3178
>                 URL: https://issues.apache.org/jira/browse/MYFACES-3178
>             Project: MyFaces Core
>          Issue Type: Bug
>          Components: General, JSR-314
>    Affects Versions: 2.1.0, 2.1.1
>         Environment: Client
>            Reporter: Deryk Sinotte
>             Fix For: 2.0.8-SNAPSHOT, 2.1.2-SNAPSHOT
>
>         Attachments: MYFACES-3178.patch, getViewState.xhtml
>
>
> The jsf.getViewState() function is a standard part of the JSF client API.  Currently, if I call this function with a valid reference to a form object, an exception is thrown.  Firefox 4 (with Firebug) reports it as:
> this._onException is not a function
> I believe the problem stems from the getViewState implementation itself in Impl.js:
>     getViewState : function(form) {
>         /**
>          *  typecheck assert!, we opt for strong typing here
>          *  because it makes it easier to detect bugs
>          */
>         if (form) {
>             form = this._Lang.byId(form);
>         }
>         if (!form
>                 || !form.nodeName
>                 || form.nodeName.toLowerCase() != "form") {
>             throw new Error(this._Lang.getMessage("ERR_VIEWSTATE"));
>         }
>         var ajaxUtils = new myfaces._impl.xhrCore._AjaxUtils(0);
>         var ret = this._Lang.createFormDataDecorator([]);
>         ajaxUtils.encodeSubmittableFields(ret, null, null, form, null);
>         return ret.makeFinal();
>     },
> In that function, some checking is done to ensure that the form is a valid reference, then a new AjaxUtils is created with no parameters. Typically these would be warning and exception handlers.  Since these handlers are missing, when encodeSubmittable fields runs into a problem and tries to use the handler, the above noted exception occurs.
> When encodeSubmittableFields is called, the form reference is set as the parameter expected for an individual form item and the parentItem is null.  I believe the form should be set as the parent item:
>         ajaxUtils.encodeSubmittableFields(ret, null, null, null, form, null);
> By setting it as the parent item, the encoding logic should be able to handle it correctly.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira