javascript generation

UI Components for JSF
Post Reply
weiChiang
Posts: 10
Joined: 13 Mar 2011, 23:15

13 Mar 2011, 23:35

I have encountered some javascript problems in 2.2.1 and later versions of 3.0-SNAPSHOT. Early version of 3.0-SNAPSHOT seems to be OK.

When one of my own pages is rendered, the following error pops up:
Uncaught TypeError: Property '$' of object [object DOMWindow] is not a function.

It points to
<div id="locationTree" class="ui-tree ui-widget ui-widget-content ui-helper-clearfix ui-corner-all"><ul class="ui-tree-nodes ui-helper-reset"><li id="locationTree_node_0" class="ui-tree-parent USER"><div class="ui-tree-node ui-state-default"><span class="ui-helper-clearfix ui-tree-node-content ui-corner-all"><span class="ui-tree-icon ui-icon ui-icon-triangle-1-e"></span><span></span><span class="ui-tree-node-label"><span class="userStyle">Byte Mode</span></span></span></div><ul class="ui-tree-nodes ui-helper-reset ui-tree-child" style="display:none"><li id="locationTree_node_0_0" class="ui-tree-item DETAILS"><div class="ui-tree-node ui-state-default"><span class="ui-helper-clearfix ui-tree-node-content ui-corner-all"><span></span><span class="ui-tree-node-label"><span class="treeNodeStyle">1 One Highway</span><span class="treeNodeStyle">Kingswood NSW 2747</span></span></span></div></li></ul></li></ul><input type="hidden" id="locationTree_selection" name="locationTree_selection" /></div><script type="text/javascript">$(function() {widget_locationTree = new PrimeFaces.widget.Tree('locationTree', {dynamic:false,selectionMode:'single',iconStates:{}});});</script><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="-8294294347063100800:-4111709231123408733" autocomplete="off" />


On this particular page, there are 3 such errors.

My question is why some of the javascripts are rendered as jQuery() while others as $(). If there were such differences in the early releases, why there was no problems. Could it is because the new primefaces uses the new version of jquery(1.5.1?) I tried to put jquery.noconflic () at the beginning of my page, but of course it does not help.

Would someone know how to avoid such problems from my own pages. I hate to go back to the early release of primefaces, as there are features in the new primefaces I would like to use.

Thanks for the help in advance.

weiChiang
Posts: 10
Joined: 13 Mar 2011, 23:15

14 Mar 2011, 02:03

I have avoided the problem by inserting the following line in the page
$ = jQuery.noConflict ()

Although it seems to work fine now, I wonder why it is necessary to add it and I worry other problems may occur down on the line. I understand that prototype uses "$", does primefaces uses prototype? I checked the code of showcases, and didn't see such a statement or the like. Perhaps someone can shed some light on this. Thank you.
primefaces 3.0-SNAPSHOT
SF implementation: Mojarra 2.0.4
Glassfish 3

weiChiang
Posts: 10
Joined: 13 Mar 2011, 23:15

14 Mar 2011, 05:06

This is probably related to my earlier postings:

With firefox, the following error occurs; however, chrome does not complain about it.

error message: node.attr("class") is undefined.
It refers to
PrimeFaces.widget.Tree.prototype.showNodeChildren = funcaiton(node, animate)
{
var icon = node.find('.ui-tree-icon:first'),
lastClass = node.attr('class').split(' ').slice(-1), <=======
nodeIcon = icon.next(),
.....
}
primefaces 3.0-SNAPSHOT
SF implementation: Mojarra 2.0.4
Glassfish 3

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

14 Mar 2011, 10:13

PrimeFaces 3.0 will use $ instead of jQuery. We've removed noConflict mode recently. Not sure why you get an error, showcase seems fine.

weiChiang
Posts: 10
Joined: 13 Mar 2011, 23:15

14 Mar 2011, 10:53

I have jQuery code in my pages (using jQuery(...), and jQuery.extend (...)). Could this cause any conflicts?
primefaces 3.0-SNAPSHOT
SF implementation: Mojarra 2.0.4
Glassfish 3

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 38 guests