[richfaces-issues] [JBoss JIRA] (RF-13780) Random JavaScript error due to missing attribute 'richfaces.RICH_CONTAINER'

Michael B (JIRA) issues at jboss.org
Thu Aug 14 14:42:29 EDT 2014


    [ https://issues.jboss.org/browse/RF-13780?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12993067#comment-12993067 ] 

Michael B commented on RF-13780:
--------------------------------

[~michpetrov] thanks for the hint. I tried to debug into the JavaScript, but in a complex xhtml where the problem does not occur every time, this is really hard to catch... 

However in several attempts I could at least create a state as follows once:
There is a rich:tree on the page. Once the page loads, the function {code}attachToDom{code} is invoked for the tree and all its visible nodes. I didn't see any problems when the components are registered.

When the page was loaded, a click on one of the tree expander icons produces a function call to {code}richfaces.ui.TreeNode.emitToggleEvent{code}

This function calls 
{code}
richfaces.$ = function(source) {
   var element = richfaces.getDomElement( source );
   ...
{code}

In firebug I see that the "element" is evaluated to the expander icon. Since it is a rather complex page layout the ids of the components are pretty long (....tree:treeModelAdapter.0.treeModelAdapter.2:treeNode.rf-tr-nd.rf-tr-nd-colps), but I think that's one of the treeNode-ids for which the component was attached before. Looking at the debugger {code}element[richfaces.RICH_CONTAINER]{code} evaluates to an Object, however {code}element[richfaces.RICH_CONTAINER][component]{code} evaluates to "null", leading to the problem described above.

So maybe there is a wrong condition under which the "component" is set to "null"?
Maybe the function "detach" being invoked at some wrong point in time?
{code}
detach: function(source) {
                source = source || this.id;
                var element = richfaces.getDomElement(source);
                element && element[richfaces.RICH_CONTAINER] && (element[richfaces.RICH_CONTAINER].component = null);
            },
{code}
At least that's the only spot I found where the "component"  is set back to "null".
Do you have any ideas about how to pinpoint the problem?


> Random JavaScript error due to missing attribute 'richfaces.RICH_CONTAINER'
> ---------------------------------------------------------------------------
>
>                 Key: RF-13780
>                 URL: https://issues.jboss.org/browse/RF-13780
>             Project: RichFaces
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: component, component-tree
>    Affects Versions: 4.3.7
>         Environment: RichFaces 4.3.7
> Mojarra 2.1.29
> Java 7 Update 67 (x64)
> Tomcat 7.0.52 (x64) 
> Firefox 31
>            Reporter: Michael B
>
> First of all: this is a bug report which may be related to RF-13776, since it also originates in the same spot of the JavaScript library of RichFaces.
> Preface:
> The problem is difficult to reproduce systematically, since it only seems to occur in one of n cases of loading one and the same complex xhtml (with exactly the same data from the backing bean).
> The problem is described based on the rich:tree component when clicking on the expand icon of a treeNode which fires a "ToggleEvent".
> Occasionally there is a JavaScript error in the last line of 
> {code}
>     richfaces.ui.TreeNode.emitToggleEvent = function(nodeId) {
>         var node = document.getElementById(nodeId);
>         if (!node) {
>             return;
>         }
>         richfaces.$(node).__fireToggleEvent();
>     };
> {code}
> When the problem occurs, the expression {code}richfaces.$(node){code} evaluates to 'undefined'. 
> Debugging into the function when the problem occurs:
> {code:title=richfaces.$|borderStyle=solid}
> richfaces.$ = function(source) {
>    var element = richfaces.getDomElement( source );
>    if(element)
>    {
>       return( element[richfaces.RICH_CONTAINER] || {} )["component"]
>    }
> };
> {code}
> While the element is correctly evaluated to the treeNode/treeNodeToggle-source, the expression {code}element[richfaces.RICH_CONTAINER]{code} evaluates to 'undefined'.
> Reloading the page one or more times produces correct results, where the attribute is set.
> To be able to provide a reproducable example of the problem, please provide some information under which circumstances the property may not be set correctly for some components. Please also give us a hint, where to debug into the RF JavaScript code to find the spot where this property is set.
> Although the problem doesn't occur all the time, it happens quite often with the effect of breaking the entire application. So for future versions I would suggest a check if {code}richfaces.$(xyz){code} evalutes to a valid result, before invoking any operations on the result and maybe write a message to the a4j:log in cases where a valid result is expected but not returned.



--
This message was sent by Atlassian JIRA
(v6.2.6#6264)


More information about the richfaces-issues mailing list