掲示板

Portlet is loaded twice on one page

12年前 に Derek Li によって更新されました。

Portlet is loaded twice on one page

New Member 投稿: 14 参加年月日: 11/04/28 最新の投稿
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.
thumbnail
12年前 に Hitoshi Ozawa によって更新されました。

RE: Portlet is loaded twice on one page

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
Is this happening on all web browsers - e.g. IE, Chrome, Firefox?

Unfortunately, I haven't experienced this with any web browser.
12年前 に Derek Li によって更新されました。

RE: Portlet is loaded twice on one page

New Member 投稿: 14 参加年月日: 11/04/28 最新の投稿
Hitoshi 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.
thumbnail
12年前 に Hitoshi Ozawa によって更新されました。

RE: Portlet is loaded twice on one page

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
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.
12年前 に Derek Li によって更新されました。

RE: Portlet is loaded twice on one page

New Member 投稿: 14 参加年月日: 11/04/28 最新の投稿
Hitoshi 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?
thumbnail
12年前 に Hitoshi Ozawa によって更新されました。

RE: Portlet is loaded twice on one page

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
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.
thumbnail
12年前 に Olaf Kock によって更新されました。

RE: Portlet is loaded twice on one page

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
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)
thumbnail
12年前 に Hitoshi Ozawa によって更新されました。

RE: Portlet is loaded twice on one page

Liferay Legend 投稿: 7942 参加年月日: 10/03/24 最新の投稿
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. emoticon
12年前 に Derek Li によって更新されました。

RE: Portlet is loaded twice on one page

New Member 投稿: 14 参加年月日: 11/04/28 最新の投稿
Hitoshi 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. emoticon


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.
12年前 に Derek Li によって更新されました。

RE: Portlet is loaded twice on one page

New Member 投稿: 14 参加年月日: 11/04/28 最新の投稿
Olaf 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.
thumbnail
1年前 に Tanweer Ahmed . によって更新されました。

RE: Portlet is loaded twice on one page

Expert 投稿: 322 参加年月日: 10/03/11 最新の投稿
Derek,

Are you somewhere using a Ajax call or window.location in this jsp ?
12年前 に Derek Li によって更新されました。

RE: Portlet is loaded twice on one page

New Member 投稿: 14 参加年月日: 11/04/28 最新の投稿
Tanweer 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.
thumbnail
12年前 に Sharana Basavaraj Ballari によって更新されました。

RE: Portlet is loaded twice on one page

Regular Member 投稿: 139 参加年月日: 07/09/10 最新の投稿
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
thumbnail
10年前 に Konstantin Chudinov によって更新されました。

RE: Portlet is loaded twice on one page

Junior Member 投稿: 43 参加年月日: 13/04/23 最新の投稿
I have the same problem! How do you fix it?
I also use ExtJS (charts) on portlet page. Chart prints twice
thumbnail
10年前 に Andew Jardine によって更新されました。

RE: Portlet is loaded twice on one page

Liferay Legend 投稿: 2416 参加年月日: 10/12/22 最新の投稿
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 --


        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.
thumbnail
10年前 に Anil T によって更新されました。

RE: Portlet is loaded twice on one page

Expert 投稿: 313 参加年月日: 12/01/14 最新の投稿
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
thumbnail
8年前 に Zsolt - Jácint Balogh によって更新されました。

RE: Portlet is loaded twice on one page

Junior Member 投稿: 91 参加年月日: 13/10/09 最新の投稿
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.

<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
thumbnail
8年前 に Andrew Jardine によって更新されました。

RE: Portlet is loaded twice on one page

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

RE: Portlet is loaded twice on one page

Liferay Legend 投稿: 6403 参加年月日: 08/09/23 最新の投稿
Zsolt - 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.

<img src="#">
this one refreshed the page twice and the action method was called twice.


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.