Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Dipesh Sahu
Link Asset Publisher to a custom portlet
19. Dezember 2011 12:19
Antwort

Dipesh Sahu

Rang: New Member

Nachrichten: 10

Eintrittsdatum: 23. Juli 2011

Neue Beiträge

Hi,

I have a custom portlet for displaying a quiz question (multiple choice), on the right side of the page.
Now I have also created a Asset Publisher for this portlet. It displays the list of all the questions, on the left side of the page.
Now my requirement is when I click on a specific question on the asset publisher, the specific parameters (say - question id) be passed to the custom quiz portlet (on the same page).

I went through quite a few discussions, but most of them were related to web content display.
I am using liferay version 6.0.6.

Can anyone please help me.

Thanks in advance.
Jelmer Kuperus
RE: Link Asset Publisher to a custom portlet
19. Dezember 2011 23:50
Antwort

Jelmer Kuperus

Rang: Liferay Legend

Nachrichten: 1190

Eintrittsdatum: 10. März 2010

Neue Beiträge

Well you can do a number of things. You could change the portlet definition of assetpublisher in ext. Make it support a public render parameter that gets read by your other portlet. But that tighty couples your portlet to the assetpublisher. And changes in ext ar generally ill adviced. Instead in this case i would use liferay's clientside ipc. Send a javascript event from the asset publisher that gets picked up by your portlet who catches the even, constructs a portlet url in javascript and performs a redirect
Dipesh Sahu
RE: Link Asset Publisher to a custom portlet
20. Dezember 2011 13:21
Antwort

Dipesh Sahu

Rang: New Member

Nachrichten: 10

Eintrittsdatum: 23. Juli 2011

Neue Beiträge

Hi Jelmer,

I was unable to find any message / forum / wiki in which there is any sample code for client side ipc for asset publisher.
So I tried doing a server side redirect... but was unsuccessful.

The following is my liferay-portlet.xml
The portlet is "abc-quiz" displays the quiz question. Parameter needs to be passed to this portlet.
The portlet "question-admin" is where asset publisher is present.


 1<liferay-portlet-app>
 2
 3    <portlet>
 4        <portlet-name>abc-quiz</portlet-name>
 5        <icon>/icon.png</icon>
 6        <instanceable>true</instanceable>
 7        <header-portlet-css>/css/quiz_main.css</header-portlet-css>
 8        <footer-portlet-javascript>/js/quiz_main.js</footer-portlet-javascript>
 9    </portlet>
10
11    <portlet>
12        <portlet-name>question-admin</portlet-name>
13        <icon>/icon.png</icon>
14        <control-panel-entry-category>content</control-panel-entry-category>
15        <control-panel-entry-weight>1.5</control-panel-entry-weight>
16        <asset-renderer-factory>
17            com.abc.portal.quiz.asset.QuestionAssetRendererFactory
18        </asset-renderer-factory>       
19        <instanceable>false</instanceable>
20        <header-portlet-css>/css/question-admin.css</header-portlet-css>
21        <header-portlet-javascript>/js/test.js</header-portlet-javascript>
22    </portlet>
23        .
24        .
25        .
26</liferay-portlet-app>



The class QuestionAssetRenderer does the rendering, with the various getters and setters.
 1
 2
 3
 4public class QuestionAssetRenderer extends BaseAssetRenderer
 5{
 6.
 7.
 8.
 9
10    public String render(RenderRequest request, RenderResponse response, String template) throws Exception
11    {
12        HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(request);
13        httpRequest = PortalUtil.getOriginalServletRequest(httpRequest);
14        httpRequest.setAttribute("QUESTION_ID", _question.getQuestionId());
15        PortletURL portletURL = PortletURLFactoryUtil.create(httpRequest ,"abcquiz_WAR_quizportlet_INSTANCE_c9mX", 20701 ,PortletRequest.RENDER_PHASE);
16       
17        String path = portletURL.toString();
18        return path ;
19
20    }
21}

I know I've hard-coded a few values for portletURL, but that's for the time being.


The control is still not going to the desired (2nd) portlet.
Can you please advise.

Thanks
Brian Scott Schupbach
RE: Link Asset Publisher to a custom portlet
28. Februar 2013 08:41
Antwort

Brian Scott Schupbach

Rang: Expert

Nachrichten: 331

Eintrittsdatum: 23. Oktober 2008

Neue Beiträge

I'm using Liferay 6.1 GA2 and I get an error saying that the URL provided is not valid because it is not in the context root. I can't return a path back to my portlet with the custom asset. It only lets me return a path that is relative to the root.

To get around this will I need to create a EXT plugin? You'd think that if you have the ability to create custom asset types that you should be able to use .jsp files within your own portlet instead of needing to create a separate EXT plugin.

Can anyone verify?