留言板

Inter Portlet Navigation

thumbnail
Hans Beling,修改在12 年前。

Inter Portlet Navigation

New Member 帖子: 11 加入日期: 11-8-15 最近的帖子
Hi,

I am still new with Liferay and portlet-programming. So far I use MVCPortlet for my controller class. I already programmed a lot within one portlet but I should have a second portlet as a Menu or Navigation-Portlet which can call particular action methods.

Is there a way? I tried the <lifery-portlet:actionURL> tag but nothing happened at all.
My code:
<a href="<liferay-portlet:actionURL portletName='addsiswa_WAR_siswaportlet_INSTANCE_h5F0'
var="viaMethod" windowState="<%= WindowState.NORMAL.toString() %>">
<portlet:param name="unused" value="1"/> </liferay-portlet:actionURL>">IPC via method</a>

So I wonder if I have to change the whole program to using struts or something else rather than the MVCPortlet from Liferay?

For any answer I would be very thankful!

Hans
thumbnail
jelmer kuperus,修改在12 年前。

RE: Inter Portlet Navigation

Liferay Legend 帖子: 1191 加入日期: 10-3-10 最近的帖子
There is , but you probably would want to use events for this

eg : http://www.ibm.com/developerworks/websphere/library/techarticles/0803_hepper/0803_hepper.html#N1009F
thumbnail
Hans Beling,修改在12 年前。

RE: Inter Portlet Navigation

New Member 帖子: 11 加入日期: 11-8-15 最近的帖子
Thank you for your fast reply Jelmer!
I already read the page you recommended. I could not yet apply it because there was no complete working example. But if the event would work, so would I have to change my <portlet-class> in portlet.xml? How to connect that again with the already written database application, currently controlled in my <portlet-class> which extends MVCPortlet?

Thanks,
Hans
thumbnail
Mani kandan,修改在12 年前。

RE: Inter Portlet Navigation

Expert 帖子: 492 加入日期: 10-9-15 最近的帖子
Try this linkInter-portlet
thumbnail
Jignesh Vachhani,修改在12 年前。

RE: Inter Portlet Navigation

Liferay Master 帖子: 803 加入日期: 08-3-10 最近的帖子
thumbnail
Hans Beling,修改在12 年前。

RE: Inter Portlet Navigation

New Member 帖子: 11 加入日期: 11-8-15 最近的帖子
Hi,

thank you for the links. I am amazed the processEvent() function is called using event although I use MVCPortlet not GenericPortlet. But when calling the response.setRenderParameter("jspPage", "/html/menu/menu.jsp"); method the jsp isn't shown. How can I force a rendering?

Thanks!
thumbnail
Hans Beling,修改在12 年前。

RE: Inter Portlet Navigation

New Member 帖子: 11 加入日期: 11-8-15 最近的帖子
Sorry,

just found out the jsp was called but the passed object was empty so it looked as if there was nochange to the view.jsp. But the menu.jsp was actually called! So thank you the IPC is already OK but to make it work as a menu portlet I still work on emoticon
thumbnail
Hans Beling,修改在12 年前。

RE: Inter Portlet Navigation

New Member 帖子: 11 加入日期: 11-8-15 最近的帖子
Hi,

the processEvent(EventRequest request, EventResponse response) method works well but now I wonder how I can call my bunch of existing methods in the MVCPortlet class with the signature of for example: public void test(ActionRequest request, ActionResponse response) throws IOException, PortletException {} .

If anyone could help me with that the IPC applied for Navigation would be working and useful.

Thanks!
thumbnail
Ravi Kumar Gupta,修改在12 年前。

RE: Inter Portlet Navigation

Liferay Legend 帖子: 1302 加入日期: 09-6-24 最近的帖子
The method signature you just mentioned are the methods generally used for some action in action phase of portlet. With one request you can call only one process action method in one portlet which can cause one or multiple process event methods in another portlets to be executed. I could not see a reason for calling multiple action methods. If you just want to pass actionreq and actionres in another method, you can do that only in the portlet sending event.

For navigation portlet > call exactly one processAction method which will set some value and send an event to another portlets.. now rest of the portlets will work accordingly.

One more thing.. in MVCportlet you can have multiple methods with ActionReq and ActionRes. Just keep the method names identical to your action name while generating actionURL.

HTH
thumbnail
Hans Beling,修改在12 年前。

RE: Inter Portlet Navigation

New Member 帖子: 11 加入日期: 11-8-15 最近的帖子
Hi Ravi,

thanks for your reply. My case is that I have already built an application existing of about 100+ methods in a MVCPortlet (I call it Application Portlet). Many of that Methods have to be called by a user from a second portlet (Navigation Portlet or Menu Portlet) but also from the pages inside the existing portlet. I tried to have a Menu Portlet where I wanted to pass first the users data to filter the suitable Menu for. Later from that Menu Portlet I have to call the functions in the Application Portlet.

So I started using Event IPC. Event IPC triggers a processEvent method on the receivers side. But I want to use Event IPC again from the Menu Portlet to control and call the Application Portlet methods. So if I can receive Events only in the processEvent method how can I dispatch to other methods which are action method in the application Portlet?

Thanks,

Hans
thumbnail
Ravi Kumar Gupta,修改在12 年前。

RE: Inter Portlet Navigation

Liferay Legend 帖子: 1302 加入日期: 09-6-24 最近的帖子
I got your concern.. but the thing is why those methods have actionReq and actionRes if you want to call from processEvent(). I dont know whether a EventReq/res can be converted in ActionReq/res.

If you have some logic written in action methods then try to separate the logic and put in a method which you can call even if you dont have actionReq/Res object.

Like if this is your method..
doProcess(ActionReq, ActionRes){
// Get the book id from req
// code to do process on the book
}

Now you can break it like
doProcess(ActionReq, ActionRes){
//get the book id
doProcessOnBook(bookId)
}

doProcessOnBook(bookId){
// code to do process on the book
}

Now this doProcessOnBook can also be called by processEvent()..
thumbnail
Hans Beling,修改在12 年前。

Resolved (答复)

New Member 帖子: 11 加入日期: 11-8-15 最近的帖子
Hi all,

thanks for your help!

For me to have the existing Liferay MVCPortlet working (not to be busy with rewriting) the liferay-portlet:actionURL - tag worked well!

<a href='<liferay-portlet:actionURL portletName="receivertest_WAR_Testportlet"
name="second" />'>
second! method called</a>

portletName is the target portlet's name (specified by <%=portletDisplay.getId() %> in the targets view.jsp)

name="second": second is the target portlet's MVCPortlet Action Method... :
public void second(ActionRequest request,
ActionResponse response) throws IOException, PortletException {
...
}

Regards,

Hans