Fórum

Javascript in Liferay 7 JSF portlet

Jatinderveer Singh, modificado 6 Anos atrás.

Javascript in Liferay 7 JSF portlet

New Member Postagens: 21 Data de Entrada: 24/02/17 Postagens Recentes
What sort of modification should we be doing in Liferay 7 JSF portlet in order for the page level javascript to be executed. I have some code which is working in Liferay6.2 where the necessary JS files are defined in Liferay-portlet.xml and have the same defined in Liferay 7 in the same place but for some reason in Liferay7 it is not able to process the chart library variable. I am using Amcharts library. Attaching the Sourcecode to reproduce the issue.
thumbnail
Andrew Jardine, modificado 6 Anos atrás.

RE: Javascript in Liferay 7 JSF portlet

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Are you creating a new project for for your Liferay7 portlet and migrating the code from the 6.2 -> 7 version? or are you trying to deploy the portlet that you built for 6.2 (namely the .WAR file) directly to the Liferay 7 server and letting the WAB conversion process take over?
Jatinderveer Singh, modificado 6 Anos atrás.

RE: Javascript in Liferay 7 JSF portlet

New Member Postagens: 21 Data de Entrada: 24/02/17 Postagens Recentes
Andrew Jardine:
Are you creating a new project for for your Liferay7 portlet and migrating the code from the 6.2 -> 7 version? or are you trying to deploy the portlet that you built for 6.2 (namely the .WAR file) directly to the Liferay 7 server and letting the WAB conversion process take over?

The code i have attached is generated from Liferay faces using maven command line and inside the generated xhtml i have inserted a demo from Amcharts. It is giving an error at browser console. You will be able to see it. I think it is not able to load the amcharts resources. I am not asking the WAB to take care of stuff. The portlet deploys just fine in server and is available for use, but at run time during the load of view it is giving error related to Amcharts javascript inserted in the view.
thumbnail
Vernon Singleton, modificado 6 Anos atrás.

RE: Javascript in Liferay 7 JSF portlet

Expert Postagens: 315 Data de Entrada: 14/01/13 Postagens Recentes
Hi Jatinderveer,

Jatinderveer Singh:
What sort of modification should we be doing in Liferay 7 JSF portlet in order for the page level javascript to be executed. I have some code which is working in Liferay6.2 where the necessary JS files are defined in Liferay-portlet.xml and have the same defined in Liferay 7 in the same place but for some reason in Liferay7 it is not able to process the chart library variable. I am using Amcharts library. Attaching the Sourcecode to reproduce the issue.


I tried your portlet, and it works fine in Liferay 7 (master). It looks like the JS files that you defined in the liferay-portlet.xml are loading. mine loaded as:
http://localhost:8080/combo?browserId=other&minifierType=&themeId=classic_WAR_classictheme&languageId=en_US&b=7003&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Famcharts.js&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Fserial.js&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Famstock.js&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Fgantt.js&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Fthemes%2Flight.js&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Fgauge.js&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Fplugins%2Fresponsive%2Fresponsive.js&t=1497460028000

Which version of Liferay 7 are you using? Also what is the exact error you are getting?
Jatinderveer Singh, modificado 6 Anos atrás.

RE: Javascript in Liferay 7 JSF portlet

New Member Postagens: 21 Data de Entrada: 24/02/17 Postagens Recentes
Vernon Singleton:
Hi Jatinderveer,

Jatinderveer Singh:
What sort of modification should we be doing in Liferay 7 JSF portlet in order for the page level javascript to be executed. I have some code which is working in Liferay6.2 where the necessary JS files are defined in Liferay-portlet.xml and have the same defined in Liferay 7 in the same place but for some reason in Liferay7 it is not able to process the chart library variable. I am using Amcharts library. Attaching the Sourcecode to reproduce the issue.


I tried your portlet, and it works fine in Liferay 7 (master). It looks like the JS files that you defined in the liferay-portlet.xml are loading. mine loaded as:
http://localhost:8080/combo?browserId=other&minifierType=&themeId=classic_WAR_classictheme&languageId=en_US&b=7003&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Famcharts.js&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Fserial.js&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Famstock.js&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Fgantt.js&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Fthemes%2Flight.js&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Fgauge.js&HibernateDXP_WAR_TestingHibernateDXP7:%2Fresources%2Famstockcharts%2Fplugins%2Fresponsive%2Fresponsive.js&t=1497460028000

Which version of Liferay 7 are you using? Also what is the exact error you are getting?


I am using Liferay DXP SP3 and i am getting following error in Browser console.


Uncaught ReferenceError: AmCharts is not defined
    at combo:1
guest:363 Uncaught ReferenceError: AmCharts is not defined
    at guest:363
Navigated to http://localhost:8080/web/guest
combo?browserId=other&minifierType=&themeId=classic_WAR_classictheme&languageId=en_US&b=7010&Hibern…:1 Uncaught ReferenceError: AmCharts is not defined
    at combo?browserId=other&minifierType=&themeId=classic_WAR_classictheme&languageId=en_US&b=7010&Hibern…:1
(anonymous) @ combo?browserId=other&minifierType=&themeId=classic_WAR_classictheme&languageId=en_US&b=7010&Hibern…:1
guest:363 Uncaught ReferenceError: AmCharts is not defined
    at guest:363
thumbnail
Vernon Singleton, modificado 6 Anos atrás.

RE: Javascript in Liferay 7 JSF portlet

Expert Postagens: 315 Data de Entrada: 14/01/13 Postagens Recentes
Hi Jatinderveer,

I sounds like this should be the answer to your question:
https://stackoverflow.com/a/43095755

Let me know if that answer helps.

- Vernon
Jatinderveer Singh, modificado 6 Anos atrás.

RE: Javascript in Liferay 7 JSF portlet

New Member Postagens: 21 Data de Entrada: 24/02/17 Postagens Recentes
Hi Vernon,
There seems to be something different in your environment because even using the solution you provided I am unable to see the graph on my view of portlet. Which LR version are you using? Can you send a screenshot of the view you are seeing? Because ideally you should be seeing a graph similar to this. Are you seeing this? I am unable to wrap my head around this.
thumbnail
Vernon Singleton, modificado 6 Anos atrás.

RE: Javascript in Liferay 7 JSF portlet

Expert Postagens: 315 Data de Entrada: 14/01/13 Postagens Recentes
Hi Jatinderveer,

Jatinderveer Singh:
There seems to be something different in your environment because even using the solution you provided I am unable to see the graph on my view of portlet. Which LR version are you using?

As I said before, I was using liferay-portal master. But today, I tried using Liferay DXP SP3, and I was able to reproduce your error. So, I installed the latest fix pack for DXP using these instructions, and that fixed the problem.

Jatinderveer Singh:
Can you send a screenshot of the view you are seeing? Because ideally you should be seeing a graph similar to this. Are you seeing this?

I attached a snapshot of what I see after installing the latest fix pack.

Jatinderveer Singh:
I am unable to wrap my head around this.

Let us know if the latest fix pack helps.

- Vernon