Forums de discussion

Liferay not refreshing the whole page when navigating in between pages

JB Shaik, modifié il y a 6 années.

Liferay not refreshing the whole page when navigating in between pages

Junior Member Publications: 35 Date d'inscription: 22/03/17 Publications récentes
Hi,

I am using Js frameworks for UI like Angular Js 2 and Integrated them to Liferay as portlet applications and added to pages in Liferay. When I navigate in between pages in Liferay, first time If I navigate from UI my angular components loads properly and when I navigate from UI the next time to my angular portlet page, then my angular component won't load and gives me an error "Error: Zone already loaded.". If I just refresh(F5 key) the page, then it loads fine. Any number of times I go the page by entering the URL manually in the browser the page loads. But If I navigate from the application, then only first time it works and all other times, it just gives me this error. Is there any way to tell Liferay to just reload the whole page on each navigation.
thumbnail
Olaf Kock, modifié il y a 6 années.

RE: Liferay not refreshing the whole page when navigating in between pages (Réponse)

Liferay Legend Publications: 6403 Date d'inscription: 23/09/08 Publications récentes
JB Shaik:
I am using Js frameworks for UI like Angular Js 2 and Integrated them to Liferay as portlet applications


You're not telling us a lot about what you actually do, apart from "integrating". The key here (I'm assuming you're talking Liferay 7) is the SPA (single page application) framework that won't load full pages. I see three options:
  • deactivate SPA for your portlet
  • deactivate SPA globally
  • Change your "integration" so that it's aware of Liferay's SPA


As I don't know the details about your integration, and I'm not a JS-guy anyways, this is as much info as I can provide with the level of information you disclose. Somebody else might be able to provide more, or alternatively you might want to provide some more information (e.g. simplified code)
JB Shaik, modifié il y a 6 années.

RE: Liferay not refreshing the whole page when navigating in between pages

Junior Member Publications: 35 Date d'inscription: 22/03/17 Publications récentes
Hi Olaf,

I'm using Liferay DXP.

I have already deactivated SPA at portlet level, but not globally. As per your suggestion below, I have deactivated SPA globally by setting the below in portal-ext.prop file and now pages are refreshing as expected. Thanks for the assistance.

javascript.single.page.application.enabled=false
thumbnail
Olaf Kock, modifié il y a 5 années.

RE: Liferay not refreshing the whole page when navigating in between pages

Liferay Legend Publications: 6403 Date d'inscription: 23/09/08 Publications récentes
instead of a complete deactivation, you might also want to follow the SPA tutorial at https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-1/automatic-single-page-applications and adapt the JS code.

After all, SPA brings significant improvements in usability by specifically omitting full page reloads.
thumbnail
Christoph Rabel, modifié il y a 5 années.

RE: Liferay not refreshing the whole page when navigating in between pages

Liferay Legend Publications: 1554 Date d'inscription: 24/09/09 Publications récentes
I am not convinced here.
I never saw any measurements convincing me that the feature is really worth it. I leave it on as long I don't have any issues related to it.

But I had troubles with the SPA feature in every project so far. It interfered with our JS, we had weird rendering behavior (odd jumping images), issues with hashes in urls (that one was fixed, I believe), issues with tracking code. Of course, some was caused by developers "doing it wrong", most developers have no idea that they need to use data-senna-track or onEndNavigate (or something like that). Sometimes this is also hard to do since there is library code that causes issues. We currently have 1 MB

Worst problem is, that sometimes the whole thing gets stuck. This sometimes happens at least in Internet explorer. Our customers have reported quite often that the portal "stops working" aka clicks don't do anything anymore. Refreshing the page helps. Of course, it only happens after some time and is not reproducible in a controlled manner at all.

So, if a problem appears, I usually just disable SPA and it very, very often helps.

I never measured it myself but I would be quite interested in seeing a measurement, how much (if at all) it indeed improves performance.
thumbnail
Rodrigo Abril, modifié il y a 5 années.

RE: Liferay not refreshing the whole page when navigating in between pages

New Member Publications: 7 Date d'inscription: 23/04/18 Publications récentes
JB Shaik:
Hi,

I am using Js frameworks for UI like Angular Js 2 and Integrated them to Liferay as portlet applications and added to pages in Liferay. When I navigate in between pages in Liferay, first time If I navigate from UI my angular components loads properly and when I navigate from UI the next time to my angular portlet page, then my angular component won't load and gives me an error "Error: Zone already loaded.". If I just refresh(F5 key) the page, then it loads fine. Any number of times I go the page by entering the URL manually in the browser the page loads. But If I navigate from the application, then only first time it works and all other times, it just gives me this error. Is there any way to tell Liferay to just reload the whole page on each navigation.



Late reply but... for any lost soul trying to find its way
You can achieve this with adding the attribute data-senna-track="temporary" to your tags

<link data-senna-track="temporary" rel="stylesheet" href="${css_folder}/file.css">
 <script data-senna-track="temporary" src="${javascript_folder}/file.js"></script>

more info:
https://sennajs.com