Forums de discussion

how to reference one portlet from another?

thumbnail
Dave Weitzel, modifié il y a 13 années.

how to reference one portlet from another?

Regular Member Publications: 208 Date d'inscription: 18/11/09 Publications récentes
I want to add a jspf "snippet" from a new portlet to a number of existing JSP files, to offer services like the ratings or tags interfaces across multiple Liferay services.

How do I include this jspf file into an existing page, I cannot create the right renderURL or <%jsp include> tags to do this. I do not want to be using iframes either as this may break the rest of the pages (eg web forms).

Once included it will make AJAX calls back to update the database and return new content for display (which I have working in isolation)

Can anyone point me in the right direction for resources on this subject?

Dave
thumbnail
Rendi Januar, modifié il y a 13 années.

RE: how to reference one portlet from another?

New Member Publications: 13 Date d'inscription: 06/12/10 Publications récentes
Hi Dave,

If you want to include from another portlet, maybe you can used

<liferay-util:include page="$(path_page)" servletContext="$(servletContext_portlet)" />


regards,
Rendi
thumbnail
Dave Weitzel, modifié il y a 13 années.

RE: how to reference one portlet from another?

Regular Member Publications: 208 Date d'inscription: 18/11/09 Publications récentes
Hi Rendi
That looks promising - how do I establish the servletContext_portlet for my portlet though?

remember this will be called from within one portlet's jps files (say journal or wiki) and will be calling my portlet say "davetest-portlet".

Within the included jspf will be an AJAX script making call back to this portlet as well which effectively needs to be hard coded.

I can't find references to this servletContext anywhere.

Thanks
thumbnail
Rendi Januar, modifié il y a 13 années.

RE: how to reference one portlet from another?

New Member Publications: 13 Date d'inscription: 06/12/10 Publications récentes
Hi Dave,
If you want to upload page from Liferay module, u just used the path,no need to used servlet context,because default liferay it will search in ROOT folder.

regards,
Rendi
thumbnail
Dave Weitzel, modifié il y a 13 années.

RE: how to reference one portlet from another?

Regular Member Publications: 208 Date d'inscription: 18/11/09 Publications récentes
I want to be referencing a page that is in my portlet.

Within a wiki post page for example I want to include a page from my portlet that holds additional meta data for that post. Similar to the way tags or ratings work, except this isn't using tag libraries.

As an interim I am looking at including a new page in every service but then edits and enhancements would have to be applied multiple times I would rather include a common file from my own portlet.

Either way the resulting included page still has to make an AJAX call to my portlet to update the data.

How do I directly address a portlet? This would be a resourceURL type call (calling serveResource() method in the portlet).
thumbnail
Rendi Januar, modifié il y a 13 années.

RE: how to reference one portlet from another?

New Member Publications: 13 Date d'inscription: 06/12/10 Publications récentes
Hi Dave,
So you want include your page inside Liferay page, you still can used liferay-util:include
like this
<liferay-util:include page="$(pathFile)" portletId="$(portletId)" />

your portletId must be hardcode.

You can check your portlet id,type this in your portlet page to know your portlet id
System.out.println(portletDisplay.getId());


just FYI portletId and portletName is different.

If you use ajax in your page, you must add your action in LiferayAction too (ex. ViewAction.java)

regards,
Rendi
thumbnail
Dave Weitzel, modifié il y a 13 années.

RE: how to reference one portlet from another?

Regular Member Publications: 208 Date d'inscription: 18/11/09 Publications récentes
I have just got back to this project after doing some Cloud server set up work.

I have tried this but am getting nothing in the portlet that I have the include statement in. (nothing in the log or page)
I used the portletDisplay.getId() in my test page (running within my portlet) to get an id:

tw6DublinCore_WAR_tw6DublinCoreportlet_INSTANCE_bV0m

I assume the _INSTANCE_bV0m is referring to the location within the page so the real id is just:
tw6DublinCore_WAR_tw6DublinCoreportlet
which makes sense.

When I put:
<liferay-util:include page="/view.jsp" portletId="tw6DublinCore_WAR_tw6DublinCoreportlet" />

into the page of another portlet I am seeing nothing. (view.jsp is on the docroot folder of the tw6DublinCore portlet.)
It isn't obvious where the pages should actually be - experimenting locally within the portlet it seems I need to put them in my custom-jsp folder not the docroot. But either way when included within another portlets page I see no content or log errors.


Can anyone provide examples of including "pagelets" from one portlet onto another?