Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
Danial Mustofa Habibi
[ask] Auto Refresh Portlet Liferay 6.0
10 septembre 2013 00:19
Réponse

Danial Mustofa Habibi

Rang: Regular Member

Publications: 141

Date d'inscription: 1 novembre 2011

Publications Récentes

Hi all.. I want To create Portlet For Monitoring Something, so it need like automatically refresh portlet page every interval of time,,, how i can achieve this? I've been trying with normal method like using Javascript but its didn't work... Thanks
any help would be really appreciate


Regards

Danial
Zsigmond Rab
RE: [ask] Auto Refresh Portlet Liferay 6.0
10 septembre 2013 13:01
Réponse

Zsigmond Rab

LIFERAY STAFF

Rang: Liferay Master

Publications: 650

Date d'inscription: 4 janvier 2010

Publications Récentes

Hi Danial,

why doesn't the JavaScript work?

Regards,
Zsigmond
Danial Mustofa Habibi
RE: [ask] Auto Refresh Portlet Liferay 6.0
10 septembre 2013 17:52
Réponse

Danial Mustofa Habibi

Rang: Regular Member

Publications: 141

Date d'inscription: 1 novembre 2011

Publications Récentes

Zsigmond Rab:
Hi Danial,

why doesn't the JavaScript work?

Regards,
Zsigmond


Don't know but i'm using simple java script like this

1var timer = null;
2function auto_reload()
3{
4    window.location = '/html/myurl/test.jsp';
5}

I use them in my body tag like this

1     <body onload="timer = setTimeout('auto_reload()',10000);">


Thank's

Regards

Danial
Zsigmond Rab
RE: [ask] Auto Refresh Portlet Liferay 6.0
11 septembre 2013 13:07
Réponse

Zsigmond Rab

LIFERAY STAFF

Rang: Liferay Master

Publications: 650

Date d'inscription: 4 janvier 2010

Publications Récentes

Hi Danial,

and what's happening?

Which type of portlet are you using? I think, you should use the portlet's current url for refreshing.

Regards,
Zsigmond
Danial Mustofa Habibi
RE: [ask] Auto Refresh Portlet Liferay 6.0
11 septembre 2013 20:07
Réponse

Danial Mustofa Habibi

Rang: Regular Member

Publications: 141

Date d'inscription: 1 novembre 2011

Publications Récentes

Zsigmond Rab:
Hi Danial,

and what's happening?

Which type of portlet are you using? I think, you should use the portlet's current url for refreshing.

Regards,
Zsigmond


Nothing happen, So i'm thinking trying another way using Jquery like this
 1<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
 2<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
 3 <script type="text/javascript">
 4var load;
 5var portletURL = new Liferay.PortletURL();
 6portletURL.setParameter("jspPage", "/html/monitoringtest/data.jsp");
 7portletURL.setPortletId("portlet_monitoringtest_WAR_MonitoringAppportlet");
 8load = function () {
 9    $('#portlet').load(portletURL.toString(), function() {
10      $('#portlet').append($('<p>Now is: ' + new Date() + '</p>'));
11      window.setTimeout(load, 5000);
12    });
13};
14load();

but still no luck,, it doesn work , my portlet didn't auto refresh I got how to generate URL from Createing Portlet URL javascript
any idea why it doesnt work?

I'm using MVC Portlet

Thank's


Regards

Danial
Danial Mustofa Habibi
RE: [ask] Auto Refresh Portlet Liferay 6.0
12 septembre 2013 17:29
Réponse

Danial Mustofa Habibi

Rang: Regular Member

Publications: 141

Date d'inscription: 1 novembre 2011

Publications Récentes

Hi, Dont know previous code didnt work, but I'm managed to solve this problem using this Link

heres the code

 1script type="text/JavaScript">
 2<!--
 3function timedRefresh(timeoutPeriod) {
 4   // setTimeout("location.reload(true);",timeoutPeriod);
 5// make a ajax call here. If you are using jquery then
 6$.post('<portlet:renderURL windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>"></portlet:renderURL>', function(data){
 7    $("#myportlet").html(data);
 8})
 9}
10timedRefresh(5000);
11//   -->
12
13</script>
14<div id="myportlet"></div>

Thank's


Regards


Danial