[SOLVED] Uncaught TypeError: undefined is not a function

UI Components for JSF
Post Reply
smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

23 Nov 2012, 15:25

Interesting, Google Chrome showed me the following error in the console,

Code: Select all

<script id="pushedNotifications_s" type="text/javascript"><!--
$(function(){PrimeFaces.cw('Growl','growl',{id:'pushedNotifications',sticky:false,life:30000,escape:false,msgs:[]});});
//--></script><script type="text/javascript"><!--
$(function() {socket = new PrimeFaces.widget.Socket({url:'/webapp/primepush/userName20121123081046',autoConnect:true,transport:'websocket',fallbackTransport:'long-polling',onMessage:displayPushedMessage});});

Uncaught TypeError: undefined is not a function

//--></script>
all I did was refresh the cache by pressing F5 (refresh) key on my keyboard, tested a few pages, and I am not seeing this javascript error anymore.

If I see it anymore, then I will most likely report it here.

Issue 4926 in Issue Tracker
Last edited by smithh032772 on 23 Nov 2012, 19:32, edited 1 time in total.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

23 Nov 2012, 15:31

Hmmm, logged out the web app, and logged back into the web app, and the javascript error is showing up again.

xhtml

Code: Select all

<p:growl id="pushedNotifications" for="socketForNotifications"
         widgetVar="growl" globalOnly="false"
         life="30000" showDetail="true" showSummary="true" escape="false"/>
<p:socket id="socketForNotifications" onMessage="displayPushedMessage"
          widgetVar="socket"
          channel="/#{pf_usersController.userPushChannelId}" />
I wonder if this is caused by the the following in the above code:

Code: Select all

p:growl for="socketForNotifications"
I know this is 'not' in PrimeFaces Push showcase examples 'or' user guide, so I will remove and see if that resolves the issue.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

23 Nov 2012, 16:46

When I click on a menuitem, such as follows,

Code: Select all

<p:menuitem value="Destination" ajax="false" onclick="displayLoadingImage(true)"
            actionListener="#{pf_ordersController.setEditMenuItemSelected('Destination')}"
            immediate="true" styleClass="#{pf_ordersController.getCssForEditMenuItem('Destination')}"/>
Result:
1. 'Uncaught TypeError: undefined is not a function' javascript error
2. Lose the socket connection

I can regain the socket connection when I click one or two different menu items that don't have

Code: Select all

immediate="true"
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

23 Nov 2012, 17:14

This may be a PrimeFaces issue. Sometimes, ajax="false" requests do NOT render the following in h:head.

Code: Select all

<script type="text/javascript" src="/mcmsweb/javax.faces.resource/push/push.js.jsf?ln=primefaces"><!--

//--></script>
If the new page contains commandButton/Link/menuitem immediate="true", then this seems to be when the push.js file is NOT rendered in the h:head.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

23 Nov 2012, 17:17

To fix/workaround this issue, I'd like to 'always' (unconditionally) include this push.js file in h:head. On every page refresh, is there a way to check h:head in the xhtml via EL to let me know if this the push.js file was included or not?

If push.js file is 'not' included, then I'd like to 'render' the push.js in h:head, myself.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

rubus
Posts: 517
Joined: 01 Oct 2010, 09:41
Location: Belgium

23 Nov 2012, 18:46

Hello,

This can be a workaround.

Create a custom component (not composite, new JSF java component) and set the push.js as required resource.
The rendering of the component isn't supoosed to do something.

When you place this on the jsf page, the javascript will always be 'rendered' in the head section.

Not tested, so ....

regards
Rudy
PrimeFaces version 3.5, Tomcat 7, Mojarra 2.1.13
PrimeFaces version 4.0, Glassfish 4.0
PrimeFaces version 5.0, WLS 12.1.2
If you haven't read the forum rules read them now : viewtopic.php?f=3&t=1194

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

23 Nov 2012, 19:27

@rubus, thanks for the response!

I think your recommendation was very similar to BalusC's response to my question (below) on Stackoverflow.com.

How can I conditionally render .js file in h:head, if file was not rendered after Full Page Refresh (FPR)?
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

hazkarah
Posts: 1
Joined: 25 Feb 2015, 19:32

25 Feb 2015, 19:59

Hello,
the post is too old but i have similar problem.
I have included one included_page.xhtml on a page.xhtml using <ui:include> and when I have updated the reference to the panel I got the message "TypeError: b is undefined".
So i found that in included_page.xhtml I've included the tag <h:head> with some style definitions in <style> tag causing the inclusion of primefaces.js again and throwing the error.
So you have to remove the <h:head> tag and just put <style> directly in the code.

Sorry for my english.


Example:

Code: Select all

page.xhtml ->
<p:autocomplete  update="renderAgain" />
...
<h:panelGroup id="renderAgain">
<ui:include src="included_page.xhtml">
</ui:include>
</h:panelGroup>


included_page.xhtml ->
<ui:composition>
...
<h:head>
  <style type="text/css">
       ...
  </style>
</h:head>
....
</ui:composition>



fixed_included_page.xhtml -> 
<ui:composition>
...
  <style type="text/css">
       ...
  </style>
....
</ui:composition>

PrimeFaces 5.1
JBoss Developer Studio 8.0.0.GA | JBoss Wildfly 8.2.0 | Maven 3.2.3
Hibernate 4.3.6 | Spring 4.1.2 | Spring Security 3.2.5.RELEASE

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 26 guests