Foros de discusión
Portlet is loaded twice on one page
Derek Li, modificado hace 13 años.
Portlet is loaded twice on one page
New Member Mensajes: 14 Fecha de incorporación: 28/04/11 Mensajes recientes
Hi all,
I'm currently facing a problem that the portlet I'm developing is loaded twice if the page is refreshed. My portlet is developed using ExtJS, which generates a grid panel after the portlet is loaded. But unfortunately, the portlet is loaded twice, which makes the javascript code that generates the grid panel execute twice. Then I'm seeing two grid panels on the page in the same portlet area. But if I refresh the page again, the duplicate panel disappears.
Here is how I find my portlet is loaded twice. I open the console panel in fire bug and find there are two items of my portlet. The response of these two items are the same. But I can't see any other portlet that has the same problem.
Does anyone have any idea about this issue? Thanks.
I'm currently facing a problem that the portlet I'm developing is loaded twice if the page is refreshed. My portlet is developed using ExtJS, which generates a grid panel after the portlet is loaded. But unfortunately, the portlet is loaded twice, which makes the javascript code that generates the grid panel execute twice. Then I'm seeing two grid panels on the page in the same portlet area. But if I refresh the page again, the duplicate panel disappears.
Here is how I find my portlet is loaded twice. I open the console panel in fire bug and find there are two items of my portlet. The response of these two items are the same. But I can't see any other portlet that has the same problem.
Does anyone have any idea about this issue? Thanks.
Hitoshi Ozawa, modificado hace 12 años.
RE: Portlet is loaded twice on one page
Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
Is this happening on all web browsers - e.g. IE, Chrome, Firefox?
Unfortunately, I haven't experienced this with any web browser.
Unfortunately, I haven't experienced this with any web browser.
Derek Li, modificado hace 12 años.
RE: Portlet is loaded twice on one page
New Member Mensajes: 14 Fecha de incorporación: 28/04/11 Mensajes recientesHitoshi Ozawa:
Is this happening on all web browsers - e.g. IE, Chrome, Firefox?
Unfortunately, I haven't experienced this with any web browser.
This only happens on Firefox.
Hitoshi Ozawa, modificado hace 12 años.
RE: Portlet is loaded twice on one page
Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientesThis only happens on Firefox.
Thought so. This may be a problem with AlloyUI. Different web browser have different rendering technique. It seems rendering is being called twice on Firefox in your situation. I've seen this happen when there is an unintended recursive call.
It may a problem with AlloyAU, with your code, or Firefox but I can't comment any further. You'll just have to trace where the second call is being made.
Derek Li, modificado hace 12 años.
RE: Portlet is loaded twice on one page
New Member Mensajes: 14 Fecha de incorporación: 28/04/11 Mensajes recientesHitoshi Ozawa:
This only happens on Firefox.
Thought so. This may be a problem with AlloyUI. Different web browser have different rendering technique. It seems rendering is being called twice on Firefox in your situation. I've seen this happen when there is an unintended recursive call.
It may a problem with AlloyAU, with your code, or Firefox but I can't comment any further. You'll just have to trace where the second call is being made.
I have made some changes to the file webapps\ROOT\html\portal\render_portlet.jsp. When a porltet is loaded to the page the following code is executed:
Liferay.Portlet.onLoad(
{
canEditTitle: <%= showConfigurationIcon %>,
columnPos: <%= columnPos %>,
isStatic: '<%= staticVar %>',
namespacedId: 'p_p_id<%= HtmlUtil.escapeJS(renderResponseImpl.getNamespace()) %>',
portletId: '<%= HtmlUtil.escapeJS(portletDisplay.getId()) %>',
refreshURL: '<%= HtmlUtil.escapeJS(PortletURLUtil.getRefreshURL(request, themeDisplay)) %>'
}
);
So, I just leave a log when the above code is run by adding:
console.log('<%= HtmlUtil.escapeJS(PortletURLUtil.getRefreshURL(request, themeDisplay)) %>');
Then I am able to know what is happening when a portlet is loaded. But unfortunately, the portlet that has issue only loaded once here. I have no idea where the second load happens. And it seems that the load doesn't happen immediately after the above code is run, because I find that the request of loading portlet doesn't come right after the log. Any further ideas?
Hitoshi Ozawa, modificado hace 12 años.
RE: Portlet is loaded twice on one page
Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientes
It's not the portlet coding. Use Firebug to trace when the second div is being created. There's usally a workaround to get around some particularity of Firefox.
Instead of trying to prevent the second div from being created, it may just be easier to execute a reload on the portlet to make the second one disappear.
Instead of trying to prevent the second div from being created, it may just be easier to execute a reload on the portlet to make the second one disappear.
Olaf Kock, modificado hace 12 años.
RE: Portlet is loaded twice on one page
Liferay Legend Mensajes: 6403 Fecha de incorporación: 23/09/08 Mensajes recientes
Do the two items have different IDs? e.g. take a look at the DOM code and identify portlet boundaries. If you have it once on the page (e.g. one <div id="p_p_id_YOUR-PORTLET-NAME_INSTANCE_Aen1_"> with the javascript twice in it, then (most likely) your portlet generates the javascript blocks wrong, e.g. twice. (you won't have the ...INSTANCE_xxxx part of the id when you don't have an instanceable portlet)
Hitoshi Ozawa, modificado hace 12 años.
RE: Portlet is loaded twice on one page
Liferay Legend Mensajes: 7942 Fecha de incorporación: 24/03/10 Mensajes recientesBut if I refresh the page again, the duplicate panel disappears.
If the portlet is generating new ids on each refresh, I think there would still be 3 panels after the second refresh.
I've sometimes seen differences between the browsers.
Well, the easiest way to solve this problem is for Derek to attach his portlet here.
Derek Li, modificado hace 12 años.
RE: Portlet is loaded twice on one page
New Member Mensajes: 14 Fecha de incorporación: 28/04/11 Mensajes recientesHitoshi Ozawa:
But if I refresh the page again, the duplicate panel disappears.
If the portlet is generating new ids on each refresh, I think there would still be 3 panels after the second refresh.
I've sometimes seen differences between the browsers.
Well, the easiest way to solve this problem is for Derek to attach his portlet here.
The weird thing is the duplicate panel only comes out on the first refresh after I open the browser, it disappears on the second refresh, and after that it never comes out again no matter how many times I refresh the page unless I restart the browser.
Derek Li, modificado hace 12 años.
RE: Portlet is loaded twice on one page
New Member Mensajes: 14 Fecha de incorporación: 28/04/11 Mensajes recientesOlaf Kock:
Do the two items have different IDs? e.g. take a look at the DOM code and identify portlet boundaries. If you have it once on the page (e.g. one <div id="p_p_id_YOUR-PORTLET-NAME_INSTANCE_Aen1_"> with the javascript twice in it, then (most likely) your portlet generates the javascript blocks wrong, e.g. twice. (you won't have the ...INSTANCE_xxxx part of the id when you don't have an instanceable portlet)
They have exactly the same ID. That explains why the two grid panels are generated in the same portlet boundaries.
Tanweer Ahmed ., modificado hace 1 año.
RE: Portlet is loaded twice on one page
Expert Mensajes: 322 Fecha de incorporación: 11/03/10 Mensajes recientes
Derek,
Are you somewhere using a Ajax call or window.location in this jsp ?
Are you somewhere using a Ajax call or window.location in this jsp ?
Derek Li, modificado hace 12 años.
RE: Portlet is loaded twice on one page
New Member Mensajes: 14 Fecha de incorporación: 28/04/11 Mensajes recientesTanweer Ahmed Ansari:
Derek,
Are you somewhere using a Ajax call or window.location in this jsp ?
I do use Ajax call, but that only triggers after the portlet finishes loading.
Sharana Basavaraj Ballari, modificado hace 12 años.
RE: Portlet is loaded twice on one page
Regular Member Mensajes: 139 Fecha de incorporación: 10/09/07 Mensajes recientes
Hi There,
I think it is just because you have deployed the portlet too many times with different name or Id, the old instance is still there in the Liferay Layout typeSettings I belive.
The best thing and quick solution that you can have is,
Delete the current Page, create it again and add the portlet. by doing this typeSettings will get newly created and you may not face the duplication issue.
HTH,
Sharan
I think it is just because you have deployed the portlet too many times with different name or Id, the old instance is still there in the Liferay Layout typeSettings I belive.
The best thing and quick solution that you can have is,
Delete the current Page, create it again and add the portlet. by doing this typeSettings will get newly created and you may not face the duplication issue.
HTH,
Sharan
Konstantin Chudinov, modificado hace 10 años.
RE: Portlet is loaded twice on one page
Junior Member Mensajes: 43 Fecha de incorporación: 23/04/13 Mensajes recientes
I have the same problem! How do you fix it?
I also use ExtJS (charts) on portlet page. Chart prints twice
I also use ExtJS (charts) on portlet page. Chart prints twice
Andew Jardine, modificado hace 10 años.
RE: Portlet is loaded twice on one page
Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
Hey Guys,
I was suffering the same issue and figured out that they were the result 404's. I found a fix after crawling through the MainServlet -- though i still don't understand the solution. The solution I used was to add the following to my init.jsp in each of my portlets --
-- as soon as I used this code and redeployed I no longer saw my render methods running multiple times, regardless of the missing resources.
I was suffering the same issue and figured out that they were the result 404's. I found a fix after crawling through the MainServlet -- though i still don't understand the solution. The solution I used was to add the following to my init.jsp in each of my portlets --
PortletURL currentURLObj = PortletURLUtil.getCurrent(liferayPortletRequest, liferayPortletResponse);
String currentURL = currentURLObj.toString();
-- as soon as I used this code and redeployed I no longer saw my render methods running multiple times, regardless of the missing resources.
Anil T, modificado hace 10 años.
RE: Portlet is loaded twice on one page
Expert Mensajes: 313 Fecha de incorporación: 14/01/12 Mensajes recientes
Hi Andew,
I have used your above code in my portlet but still its calling render method twice. Have you found any solution ? Please share with us .
Thanks,
Anil
I have used your above code in my portlet but still its calling render method twice. Have you found any solution ? Please share with us .
Thanks,
Anil
Zsolt - Jácint Balogh, modificado hace 8 años.
RE: Portlet is loaded twice on one page
Junior Member Mensajes: 91 Fecha de incorporación: 9/10/13 Mensajes recientes
Hi all,
I had the same problem with Liferay 6.2. In my case the problem was that I used the # in the SRC tag of an image.
I spend 2 days from my life finding this.
Somebody can explain me why is this?
Regards,
Zsolt
I had the same problem with Liferay 6.2. In my case the problem was that I used the # in the SRC tag of an image.
<img src="#">
this one refreshed the page twice and the action method was called twice.<img src="/documents/10658/21815/cfd8c9df-9a54-4df7-a905-6e2bbc34b5cf/bf06cf6a-38d4-4875-918d-08fed62b9745">
With this one worked.I spend 2 days from my life finding this.
Somebody can explain me why is this?
Regards,
Zsolt
Andrew Jardine, modificado hace 8 años.
RE: Portlet is loaded twice on one page
Liferay Legend Mensajes: 2416 Fecha de incorporación: 22/12/10 Mensajes recientes
In the end for me (with 6.1 GA2) it was the same issue (if memory serves). We found that broken resource links (in certain situations) were causing portlets on the page to load more than once. Interestingly though, the currentURL code I referenced in my other post also seemed to resolved the problem for us on certain pages.
Olaf Kock, modificado hace 8 años.
RE: Portlet is loaded twice on one page
Liferay Legend Mensajes: 6403 Fecha de incorporación: 23/09/08 Mensajes recientesZsolt - Jácint Balogh:
Hi all,
I had the same problem with Liferay 6.2. In my case the problem was that I used the # in the SRC tag of an image.this one refreshed the page twice and the action method was called twice.<img src="#">
Of course it did. # is an anchor in the current page - in other words the URL that you state as the location of your image is the same URL that you load the current page as. The resulting duplicate HTML code for the current page is html, not jpg/png/gif or similar, thus the browser does not display it as image. But as you state that the browser can find an image under the current URL, it will happily request the image before deciding not being able to show it. And that's what you observe - server side - as duplicate page request.