Liferay is a Gartner Magic Quadrant Leader for the Sixth Year! Find out why

Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
donino pienni
Javascript error: Cannot read property 'preventNotification' of undefined
7 marzo 2012 4.02
Risposta

donino pienni

Punteggio: Junior Member

Messaggi: 80

Data di Iscrizione: 2 luglio 2011

Messaggi recenti

System: Windows & Linux
Release: Bundle Liferay 6.1GA1 / Tomcat 7

Hi,

I developped a custom 286 portlet, it works pretty well but currently i get this javascript error in the browser console, for each window where this portlet is set up:

Uncaught TypeError: Cannot read property 'preventNotification' of undefined

The error relates to the resource "<Liferay Root>/html/js/everything.jsp:3", wich i guess is dynamically built. Although the portlet works, there are few issues that may be caused by this error: for example, if i minify a portlet window and then refresh the page, the restore option won't work, i have to maximize the window to "wake up" it.

Please could someone give me clues about this javascript error?

Thanks!
António Silva
RE: Javascript error: Cannot read property 'preventNotification' of undefin
13 aprile 2012 10.06
Risposta

António Silva

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 13 aprile 2012

Messaggi recenti

I have the same problem. emoticon

How I can solve this ?
André Bunse
RE: Javascript error: Cannot read property 'preventNotification' of undefin
13 aprile 2012 10.51
Risposta

André Bunse

Punteggio: Junior Member

Messaggi: 85

Data di Iscrizione: 15 marzo 2012

Messaggi recenti

Hi,

the message comes from "portlet.js" when Liferay inject html

 1            
 2    Liferay.provide(
 3        Portlet,
 4        'addHTML',
 5        function(options) {
 6            var data = options.data;
 7            var dataType = 'html';
 8
 9<snip>
10
11       A.io.request(
12                url,
13                {
14                    after: {
15                        success: function() {
16                            if [b](!data.preventNotification)[/b] {
17                                Liferay.fire('updatedLayout');
18                            }
19                        }
20                    },
21                    data: data,

How do you populate your portlet?


Maybe that is the reason why every new portlet from sdk adds
1This is the <b>MyName</b> portlet.

emoticon


HTH
André
António Silva
RE: Javascript error: Cannot read property 'preventNotification' of undefin
13 aprile 2012 11.04
Risposta

António Silva

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 13 aprile 2012

Messaggi recenti

I forgot to say that my problem have a slight difference because to me this happens with RSS Portlet that come with Liferay 6.1.

I will see what you say in RSS Portlet source code.
André Bunse
RE: Javascript error: Cannot read property 'preventNotification' of undefin
13 aprile 2012 11.45
Risposta

André Bunse

Punteggio: Junior Member

Messaggi: 85

Data di Iscrizione: 15 marzo 2012

Messaggi recenti

António Silva:
I forgot to say that my problem have a slight difference because to me this happens with RSS Portlet that come with Liferay 6.1.

I will see what you say in RSS Portlet source code.

I can reproduce it with a RSS Portlet installed.

Lowest layer of call stack is "IO._rS" from "io-base.js" (onReadyStateChange event handling),
but i can't directly see a solution to this problem.

But i think a browser who runs with production code should never caught exceptions.
Don't know if IE or other can handle this, i use Chrome and can set this in the debugger.

Are there side effects in your case?

Keep on coding
André
António Silva
RE: Javascript error: Cannot read property 'preventNotification' of undefin
13 aprile 2012 12.03
Risposta

António Silva

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 13 aprile 2012

Messaggi recenti

André Bunse:
António Silva:
I forgot to say that my problem have a slight difference because to me this happens with RSS Portlet that come with Liferay 6.1.

I will see what you say in RSS Portlet source code.

I can reproduce it with a RSS Portlet installed.

Lowest layer of call stack is "IO._rS" from "io-base.js" (onReadyStateChange event handling),
but i can't directly see a solution to this problem.

But i think a browser who runs with production code should never caught exceptions.
Don't know if IE or other can handle this, i use Chrome and can set this in the debugger.

Are there side effects in your case?

Keep on coding
André

If I refresh the page I cannot change RSS Portlet options anymore and when I try to open options give thatar error on Chrome Java console "Javascript error: Cannot read property 'preventNotification' of undefined".
André Bunse
RE: Javascript error: Cannot read property 'preventNotification' of undefin
13 aprile 2012 12.44
Risposta

André Bunse

Punteggio: Junior Member

Messaggi: 85

Data di Iscrizione: 15 marzo 2012

Messaggi recenti

António Silva:
If I refresh the page I cannot change RSS Portlet options anymore and when I try to open options give thatar error on Chrome Java console "Javascript error: Cannot read property 'preventNotification' of undefined".

Ok, i see the same behaviour. If i find a solution i will post it.

André
António Silva
RE: Javascript error: Cannot read property 'preventNotification' of undefin
17 aprile 2012 8.53
Risposta

António Silva

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 13 aprile 2012

Messaggi recenti

André Bunse:
António Silva:
If I refresh the page I cannot change RSS Portlet options anymore and when I try to open options give thatar error on Chrome Java console "Javascript error: Cannot read property 'preventNotification' of undefined".

Ok, i see the same behaviour. If i find a solution i will post it.

André

I solve the problem, in the file liferay-portlet.xml in \tomcat-7.0.23\webapps\ROOT\WEB-INF.

On rss portlet configuration you have this:
 1    <portlet>
 2        <portlet-name>39</portlet-name>
 3        <icon>/html/icons/rss.png</icon>
 4        <struts-path>rss</struts-path>
 5        <configuration-action-class>com.liferay.portlet.rss.action.ConfigurationActionImpl</configuration-action-class>
 6        <portlet-data-handler-class>com.liferay.portlet.rss.lar.RSSPortletDataHandlerImpl</portlet-data-handler-class>
 7        <preferences-owned-by-group>true</preferences-owned-by-group>
 8        <use-default-template>false</use-default-template>
 9        <instanceable>true</instanceable>
10        <private-request-attributes>false</private-request-attributes>
11        <private-session-attributes>false</private-session-attributes>
12        [b][size=6]<render-weight>0</render-weight>[/size][/b]
13        <header-portlet-css>/html/portlet/rss/css/main.css</header-portlet-css>
14        <css-class-wrapper>portlet-rss</css-class-wrapper>
15    </portlet>


You need to change to:
 1<portlet>
 2        <portlet-name>39</portlet-name>
 3        <icon>/html/icons/rss.png</icon>
 4        <struts-path>rss</struts-path>
 5        <configuration-action-class>com.liferay.portlet.rss.action.ConfigurationActionImpl</configuration-action-class>
 6        <portlet-data-handler-class>com.liferay.portlet.rss.lar.RSSPortletDataHandlerImpl</portlet-data-handler-class>
 7        <preferences-owned-by-group>true</preferences-owned-by-group>
 8        <use-default-template>false</use-default-template>
 9        <instanceable>true</instanceable>
10        <private-request-attributes>false</private-request-attributes>
11        <private-session-attributes>false</private-session-attributes>
12        [b][size=6]<render-weight>50</render-weight>[/size][/b]
13        <header-portlet-css>/html/portlet/rss/css/main.css</header-portlet-css>
14        <css-class-wrapper>portlet-rss</css-class-wrapper>
15    </portlet>
Dale Larsen
RE: Javascript error: Cannot read property 'preventNotification' of undefin
18 aprile 2012 9.04
Risposta

Dale Larsen

Punteggio: New Member

Messaggi: 1

Data di Iscrizione: 14 febbraio 2011

Messaggi recenti

André Bunse:
António Silva:
If I refresh the page I cannot change RSS Portlet options anymore and when I try to open options give thatar error on Chrome Java console "Javascript error: Cannot read property 'preventNotification' of undefined".

Ok, i see the same behaviour. If i find a solution i will post it.

André



I am seeing a similar Javascript error with the chat portlet. This actually prevents you from initiating a chat session with a desired friend. You can see Online Friends, but if you click on them to chat, the chat window does not come up (because of these prior Js errors).

In Chrome, I receive:

Uncaught TypeError: Cannot read property 'preventNotification' of undefined everything.jsp:3

In Firefox, I receive:

j is undefined

I noticed in a subsequent post Antonio mentioned changing the render-weight of the rss portlet in liferay-portlet.xml. Not sure what exactly this does and if a similar fix could apply to the chat portlet.

Any help/insight would be appreciated.
Thomas Berg
RE: Javascript error: Cannot read property 'preventNotification' of undefin
5 maggio 2012 10.15
Risposta

Thomas Berg

Punteggio: Regular Member

Messaggi: 134

Data di Iscrizione: 7 settembre 2009

Messaggi recenti

The above is NOT a fix even if it solves the immediate problem.
Setting the render-weight to anything higher than 0 prevents the portlet from being loaded asynchronously (in parallell). This problem (or at least similar) also exists with 6.0 releases, see LPS-21886

/ Thomas