掲示板

[Solved] StrutsPortlet and IPC

14年前 に Nadine R によって更新されました。

[Solved] StrutsPortlet and IPC

Junior Member 投稿: 26 参加年月日: 09/07/30 最新の投稿
Hi everyone,

I've been trying to do IPC between 2 portlets but in vain!

My portlets extends from org.apache.portals.bridges.struts.StrutsPortlet and I am trying to use events but it is not working!

Can anyone please help?

Thanks,
Nadine
thumbnail
14年前 に Jonas Yuan によって更新されました。

RE: StrutsPortlet and IPC

Liferay Master 投稿: 993 参加年月日: 07/04/27 最新の投稿
Hi Nadine,

You may need to use Struts 2. By the way, you can use examples:

Building Inter-Portlet Communication
Inter-portlet communication (or IPC) becomes important with portlets applications,
for example, the web sites bookpubstreet.com and bookpubworkshop.com with
the capability of Control Panel and Social Office. These applications are composed
of more than one portlet for their functionality. As stated in Chapter 2, Working with
JSR-286 Portlets, JSR-286 portlets address IPC—an event model that allows portlets
to send and receive events. We will go over the simple example FAQ of IPC that
consists of two portlets: FAQ and Browse-FAQ. The Browse-FAQ portlet contains
categories: Top Questions, About Our Other Offerings, About the Television
Program, and About the Website. The portlet FAQ also contains the categories
Top Questions, About Our Other Offerings, About the Television Program, and
About the Website. Each category may contain a set of questions with an answer.
For example, the Top Questions category contains three questions: Can my child
appear on Book Street?, How do I find out when programs are on BS?, and
What are Book Playlists?.

Abstracted from the book: Liferay Portal 5.2 Systems Development

You can also download source code from the chapter 10 of Liferay
Portal 5.2 Systems Development


Hope that it helps.

Thanks

Jonas Yuan
-----------------
The Author of Liferay Books:
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
14年前 に Nadine R によって更新されました。

RE: StrutsPortlet and IPC

Junior Member 投稿: 26 参加年月日: 09/07/30 最新の投稿
Hi all,

thanks for those rapid answers. Actually Jonas, I have your book and it certainly has an example, the one you mentionned. But it's based on the javax. portlet when I using the Struts portlet. If you say that it should work, then I'm doing something wrong... I'm not using Struts 2. Let me try again.

Cheers,
Nadine
thumbnail
14年前 に Jonas Yuan によって更新されました。

RE: StrutsPortlet and IPC

Liferay Master 投稿: 993 参加年月日: 07/04/27 最新の投稿
Hi Nadine,

Thank you. The example provided in the book should work properly. It uses Generic Portlet - from the standard specification JSR-286.

Please let me know if you meet any issue related to IPC example.

Jonas Yuan
-----------------
The Author of Liferay Books:
Liferay Portal 5.2 Systems Development
Liferay Portal Enterprise Intranets
14年前 に Nadine R によって更新されました。

RE: StrutsPortlet and IPC

Junior Member 投稿: 26 参加年月日: 09/07/30 最新の投稿
Hi Jonas,

I have succeeded in implementing IPC with events! I just had a problem when using @ProcessAction, thus I decided to use processAction as such.

Thanks all,
Nadine
13年前 に Latara Smith によって更新されました。

RE: StrutsPortlet and IPC

New Member 投稿: 13 参加年月日: 10/02/15 最新の投稿
Hi Nadine,

I am trying to do the same thing as you, but I'm not quite sure how to go about it...
Could you give me some guidelines?

I have one simple jsp portlet that sends an event to a sturts portlet.
The struts portlet should revceive the event and based on it render the appropriate page.
Now the struts portlet should also enable actions.

Anyhelp would be greatly appreciated as I am quite lost at the moment...

Thanx in advance!


Latara
thumbnail
14年前 に Ahmed Hasan によって更新されました。

RE: StrutsPortlet and IPC

Expert 投稿: 306 参加年月日: 07/04/13 最新の投稿
Hi Nadine,

Ir-respective of what kind of front-end technology you use, the Inter Portlet Communication thru eventing mechanism works perfectly well.

Kindly refer to the following chapters under this link.

  • 17-inter-portlet-commn-part1.txt
  • 18-inter-portlet-commn-part2.txt


They talk about the various schemes of IPC with examples.

For any help feel free to contact me,

Ahmed Hasan
CTO, TransIT mPower Labs (P) Ltd.
info@mpowerglobal.com
mPower Global
A Liferay expert company.
thumbnail
13年前 に charles de courval によって更新されました。

RE: StrutsPortlet and IPC

Junior Member 投稿: 55 参加年月日: 10/07/31 最新の投稿
Hi Ahmed,
i've been trying to implement IPC between 2 struts2 portlet, but in vain.

I have a jsp that gives out a list of project. When I click on the edit link, I should be able to see the detail of the project. Also in the page there is an other portlet that should display a list of documents that are attached to the project.


	<s:set var="pppid" value="#project.projectId" />
	<liferay-portlet:actionurl varimpl="phu">
		<liferay-portlet:param name="struts_action" value="/project/edit" />
		<liferay-portlet:param name="form.id" value="${pppid}"></liferay-portlet:param>
	</liferay-portlet:actionurl>
		
	<s:url action="edit" namespace="/project" id="editProjectUrl">
		<s:param name="form.id" value="#project.projectId" />
	</s:url>
	<a href="${phu}">Editer</a>



the first problem is that when I click on the link, instead of calling the /project/edit action, it calls back the /project/list action. Now I manage to bypass this by using a redirect to the edit action.

Here is the code from the execute method in ListProjectAction.java

@Override
public String execute() throws Exception {
	String ret = SUCCESS;
	if (renderRequest != null) {
		long userId = PortalUtil.getUserId(renderRequest);

		projects = ProjectLocalServiceUtil.list(userId);
	} else if (actionRequest != null) {

		QName qName = new QName("http://liferay.com/events", "acq.publish.project.id");
		actionResponse.setEvent(qName, String.valueOf(form.getId()));

		ret = "success_edit";
	}
	return ret;

}


and the code from ProjectFileAction.java

@ProcessEvent(qname="{http://liferay.com/events}acq.publish.project.id")
public void catchProjectId(EventRequest request, EventResponse response){
	
	System.out.println("catchProjectId: " );
	
	Event event = request.getEvent(); 
	String projectId = (String)event.getValue(); 
	response.setRenderParameter("projectId", projectId); 
}

@Override
public String execute() throws Exception {

	String projectId = renderRequest.getParameter("projectId");
	
	System.out.println("ProjectFileAction.execute() ==&gt; projectId : " + projectId);

	return super.execute();
}


why is the method catchProjectId never called ?
Can I use events IPC with struts2 ?

I'm using Liferay 6.0.5 and Struts 2.2.1

thanks
Charles
13年前 に Tony Luo によって更新されました。

RE: StrutsPortlet and IPC

New Member 投稿: 20 参加年月日: 10/12/11 最新の投稿
Hi charles de courval ,

I am using Struts2 for portlet development and has the extractly the same question you met.

Have you solve it or has another workaround? Looks forward to your help.
thumbnail
13年前 に charles de courval によって更新されました。

RE: StrutsPortlet and IPC

Junior Member 投稿: 55 参加年月日: 10/07/31 最新の投稿
Hi Tony,
To which question are you referring ? The project list to the project detail or the IPC using Struts 2.
For the later, all the example I've seen using struts2 with Liferay 6.0.5, show that the portlet used in you portlet definition is the jsr168 and not the jsr286 dispatcher. Hence there is no IPC possible.
In your portlet.xml you'd see something like this:
<portlet id="HelloStruts2">
		<portlet-name>hellostruts2</portlet-name>
		<display-name xml:lang="EN">Hello Struts 2</display-name>
		<portlet-class>org.apache.struts2.portlet.dispatcher.Jsr168Dispatcher</portlet-class></portlet>


There is a Jsr286Dispatcher that exist that would support IPC, but it's in its alpha stage with no outlook on when it's comming out.

If you're referring to the project list to project detail part. I'll need more detail. But have you tried using the MVCPortlet that is packaged with Liferay 6.0.5 ?

cheers.
13年前 に Tony Luo によって更新されました。

RE: StrutsPortlet and IPC

New Member 投稿: 20 参加年月日: 10/12/11 最新の投稿
Hi Charles de Courval ,

Actually I referred to the project list to the project detail issue.

I have a page "List" with a portlet to show my item list and a page "Detail" with a portlet to show the item details, which is very similar to your requirement.

I use Struts2 to implment this application. And now I I can use "http://localost/web/guest/detail" to the detail page. But I don't know how I can send the itemId to that page. "http://localhost/web/guest/detail?itemId=1" just doesn't work for me.
thumbnail
13年前 に Charles de Courval によって更新されました。

RE: StrutsPortlet and IPC

Junior Member 投稿: 55 参加年月日: 10/07/31 最新の投稿
Hi,
IPC using struts2 is not doable. The only way I know how would be for your list portlet to put the itemId in session and for the detail portlet to retrieve it from the session. This post might help you.

cheers.
13年前 に Tony Luo によって更新されました。

RE: StrutsPortlet and IPC

New Member 投稿: 20 参加年月日: 10/12/11 最新の投稿
Hi Charles de Courval ,

If I use Struts2 Action to save the parameter in the session, I will fail to redirect to the detail page.

ActionResponse.sendRedirect will cause IllegalStateException.

What's your solution for this issue or how do you redirect?
thumbnail
9年前 に Subhasis Roy によって更新されました。

RE: StrutsPortlet and IPC

Expert 投稿: 275 参加年月日: 12/01/20 最新の投稿
Did you get any success on that.

I am using Spring portlet and having the same problem
thumbnail
13年前 に ankit yakkundi によって更新されました。

RE: StrutsPortlet and IPC

Regular Member 投稿: 221 参加年月日: 10/03/05 最新の投稿
Hi..
I am using Liferay 6 and plugin SDK.
I have created two struts portlet.
I have the following requirement:-
When the user clicks on the link on a portlet A residing on Page A i would like to navigate the user to Page B and portlet B on that page populated.


Is it possible??
I have heard about InterPortlet Communication,but not Inter Portlet-Page Communication..

Any idea,suggestions are welcome..
Thanks in advance.
12年前 に neelam bhandari によって更新されました。

RE: StrutsPortlet and IPC

Regular Member 投稿: 102 参加年月日: 11/08/16 最新の投稿
hi,
any success yet?i need to implement the same.I am using IPC event to generate the event but how to redirect to that page.

Regards
Neelam
thumbnail
9年前 に Subhasis Roy によって更新されました。

RE: StrutsPortlet and IPC

Expert 投稿: 275 参加年月日: 12/01/20 最新の投稿
Hi,

I got success in IPC using event. I am using spring portlet. Attaching the reference.

Check the URL