掲示板

Javascript in Liferay 7 JSF portlet

6年前 に Jatinderveer Singh によって更新されました。

Javascript in Liferay 7 JSF portlet

New Member 投稿: 21 参加年月日: 17/02/24 最新の投稿
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
6年前 に Andrew Jardine によって更新されました。

RE: Javascript in Liferay 7 JSF portlet

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
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?
6年前 に Jatinderveer Singh によって更新されました。

RE: Javascript in Liferay 7 JSF portlet

New Member 投稿: 21 参加年月日: 17/02/24 最新の投稿
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
6年前 に Vernon Singleton によって更新されました。

RE: Javascript in Liferay 7 JSF portlet

Expert 投稿: 315 参加年月日: 13/01/14 最新の投稿
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?
6年前 に Jatinderveer Singh によって更新されました。

RE: Javascript in Liferay 7 JSF portlet

New Member 投稿: 21 参加年月日: 17/02/24 最新の投稿
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
6年前 に Vernon Singleton によって更新されました。

RE: Javascript in Liferay 7 JSF portlet

Expert 投稿: 315 参加年月日: 13/01/14 最新の投稿
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
6年前 に Jatinderveer Singh によって更新されました。

RE: Javascript in Liferay 7 JSF portlet

New Member 投稿: 21 参加年月日: 17/02/24 最新の投稿
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
6年前 に Vernon Singleton によって更新されました。

RE: Javascript in Liferay 7 JSF portlet

Expert 投稿: 315 参加年月日: 13/01/14 最新の投稿
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

添付ファイル: