Foren

How to refresh the portlet page in liferay automatically

chandra sekhar, geändert vor 13 Jahren.

How to refresh the portlet page in liferay automatically

Regular Member Beiträge: 149 Beitrittsdatum: 07.07.09 Neueste Beiträge
Hi All,

How to refresh the portlet page in liferay-5.1.2 after every 5 secs.

Thanks in advance.


Regards,
Chandrasekhar
thumbnail
Apoorva Prakash, geändert vor 13 Jahren.

RE: How to refresh the portlet page in liferay automatically

Liferay Master Beiträge: 658 Beitrittsdatum: 15.06.10 Neueste Beiträge
Hello Chandra,
Put the following javascript in your JSP...
<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
	setTimeout("location.reload(true);",timeoutPeriod);
}
//   -->
</script>


Merry Christmas...

Hope this will help...

Thanks and Regards...
thumbnail
Udaya Ramakrishnan, geändert vor 12 Jahren.

RE: How to refresh the portlet page in liferay automatically

Junior Member Beiträge: 67 Beitrittsdatum: 07.09.11 Neueste Beiträge
hi

ur code refreshes the whole page. but i want a particular portlet to be refreshed.
i am using weather portlet in my portal. i want that portlet alone to be refreshed.
can u help me in this

Thanks,
Udaya.R
thumbnail
Ravi Kumar Gupta, geändert vor 12 Jahren.

RE: How to refresh the portlet page in liferay automatically

Liferay Legend Beiträge: 1302 Beitrittsdatum: 24.06.09 Neueste Beiträge
Ajax can help in this case.

Use the method with some modifications like this

<script type="text/JavaScript">
<!--
function timedRefresh(timeoutPeriod) {
   // setTimeout("location.reload(true);",timeoutPeriod);
// make a ajax call here. If you are using jquery then
$.post('<portlet:renderURL windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>"></portlet:renderURL>', function(data){
    $("#myportlet").html(data);
})
}
timedRefresh(5000);
//   -->

</script>
<div id="myportlet"></div>


HTH
ghadeer raad, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Junior Member Beiträge: 51 Beitrittsdatum: 02.06.20 Neueste Beiträge
i use liferay 7.2 ce ga2 
in which  jsp file i can put this code?
thumbnail
Olaf Kock, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
ghadeer raad:

i use liferay 7.2 ce ga2 
in which  jsp file i can put this code?
The original post is 8 years old. It's 2020. If you have a portlet that dynamically updates, consider using renderrequests, headless api access from the frontend or similar.
Consider a scenario where you're entering data into a form in another portlet on the same page, while someone thought it might be a good idea to reload the full page. You'd not be a happy user. Don't be that "someone" who causes unhappy users. As a developer you're responsible for your portlet's content. The page is somebody else's business.
ghadeer raad, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Junior Member Beiträge: 51 Beitrittsdatum: 02.06.20 Neueste Beiträge
i'm not very goode developer and i need to add auto refresh property to my portal and when i search about this subject i can't find any result in afew years  ago ,please do you have any info. about this problem
thumbnail
Olaf Kock, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
ghadeer raad:

I need to add auto refresh property to my portal
I'm questioning that... maybe you'll need to do that to your portlet...
And if it's that, the solution depends on the implementation of your portlet: Is it a server-side implementation? A Javascript-heavy implementation?
Updating/Refreshing dynamically typically involves some amount of JS, but if you start out fully headless and on the browser side, the answer will be different than if you started a server-side JSR-286 implementation.
ghadeer raad, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Junior Member Beiträge: 51 Beitrittsdatum: 02.06.20 Neueste Beiträge
how can i solve this problem i can't understand what i can do now?
thumbnail
Olaf Kock, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
ghadeer raad:

how can i solve this problem i can't understand what i can do now?
Describe your situation and requirements - what is the underlying problem that you're trying to solve. And check my post above for sentences ending in a question mark
ghadeer raad, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Junior Member Beiträge: 51 Beitrittsdatum: 02.06.20 Neueste Beiträge
i use liferay 7.2 ce ga2 and i want to make auto refresh to my portalhow can i achieve that?
thumbnail
Olaf Kock, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
ghadeer raad:

i use liferay 7.2 ce ga2 and i want to make auto refresh to my portalhow can i achieve that?
well, that part  was clear, but the underlying problem isn't. You've come up with a solution to auto-refresh. But we don't know what you'd like to refresh: A custom portlet's content (e.g. database content)? A content article? Some out-of-the-box content?
What's the business case? Apart from just triggering a page reload (which you could easily do with a bit of JS any time, at the cost of interrupting anyone currently working on a form on the page)
ghadeer raad, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Junior Member Beiträge: 51 Beitrittsdatum: 02.06.20 Neueste Beiträge
and if i want to do the JS method how i can do this?
ghadeer raad, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Junior Member Beiträge: 51 Beitrittsdatum: 02.06.20 Neueste Beiträge
I want to auto-refresh to the main page of portal because the notification can't appear to the user until he reload the page
thumbnail
Olaf Kock, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
ghadeer raad:

I want to auto-refresh to the main page of portal because the notification can't appear to the user until he reload the page


I bet that if someone can show you a way to just show the notifications (your business requirement), you won't care much about the page being refreshed (your proposed solution).
That's why I'm always asking about the underlying business problem.
Now that this is clear, let's see if someone already solved this problem. I bet there's an API that one could trigger dynamically (e.g. under /api/jsonws) that reveals the number of notifications. It "only" doesn't seem to be utilized in the default implementation, but that's the direction that I'd go.
A trivial option is to write your own NotificationPoller portlet that polls&displays the notifications dynamically. A more elegant version would use the same signalling that Liferay uses. As I'm not your typical go-to-person for frontend questions, I'm leaving the concrete idea for someone else for now.
ghadeer raad, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Junior Member Beiträge: 51 Beitrittsdatum: 02.06.20 Neueste Beiträge
No i don't want a way to just show the notifications ,i want a way to reload the page to see new notifections
thumbnail
Olaf Kock, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
ghadeer raad:

No i don't want a way to just show the notifications ,i want a way to reload the page to see new notifections

I still stand by my claim from above. But as you ask about it: The notifications will automatically be correct on reload, so you'll need this technique.
ghadeer raad, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Junior Member Beiträge: 51 Beitrittsdatum: 02.06.20 Neueste Beiträge
i think i can't understand u very well because my english language it's not very well,so please can u explain your idea in simple way?and i have another question ,i need liferay sdk plugin 7.2 put when i search about it i can't find it can u help me to find it?i'm so sorry sorry for disturbing you
thumbnail
Olaf Kock, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
My question is:
1. Do you want the notifications to appear?
OR
2. Do you want to reload the page?

Number 1 is a business problem. Number 2 is a technical question.
Especially if you say "I need 2 because 1" - that's called XY-Problem http://xyproblem.info/
You've insisted on needing 2, that's why I gave up on providing a solution for 1.

Liferay has a rich API, which you can inspect and find the way to obtain the number of notifications, through Javascript Ajax-requests. And then make use of the result any way you like. It'll require some programming skills, and we don't know about your experience level.
If someone here provides code snippets, they might be helpful or distracting - again: Because of the xy-problem: Code snippets are solutions. And often they're solutions to other problems than yours.
thumbnail
Olaf Kock, geändert vor 3 Jahren.

RE: How to refresh the portlet page in liferay automatically

Liferay Legend Beiträge: 6403 Beitrittsdatum: 23.09.08 Neueste Beiträge
Cross-referencing. Please limit yourself to one thread per topic in future, and collect all the important information there.
  • https://liferay.dev/forums/-/message_boards/message/119775167
  • https://liferay.dev/forums/-/message_boards/message/119467254
  • https://liferay.dev/forums/-/message_boards/message/6906123
  • https://liferay.dev/forums/-/message_boards/message/119398405
  • https://liferay.dev/forums/-/message_boards/message/119780546