Foren
Inter portlet communication: 3 portlets, not refreshing the last portlet
Ranen Das, geändert vor 10 Jahren.
Inter portlet communication: 3 portlets, not refreshing the last portlet
Regular Member Beiträge: 137 Beitrittsdatum: 06.04.11 Neueste Beiträge
Hello Guys,
Problem Description:- Portlet 1 : it has got dropdown list--> select an option-->click submit-->Portlet 2 displays data in a chart(=this is first IPC)-->click a part of the chart in Portlet 2---> it should display another chart in a portlet(which is Portlet 3) below Portlet 2 -->this is the second place of IPC-->codes get executed properly, executed jsp code also, but the portlet 3 does not get the data in a chart,but if I refresh whole page, I can see the Portlet 3 with the desired data in a chart.
Now the question here is why the portlet 2-- to portlet 3 communication time, the page did not get refresh. If the page gets refresh then I would see my output, so issue is not refreshing the page, during portlet 1 to portket 2 communication - page gets automatically refreshed.
here is code snippet:-
Problem Description:- Portlet 1 : it has got dropdown list--> select an option-->click submit-->Portlet 2 displays data in a chart(=this is first IPC)-->click a part of the chart in Portlet 2---> it should display another chart in a portlet(which is Portlet 3) below Portlet 2 -->this is the second place of IPC-->codes get executed properly, executed jsp code also, but the portlet 3 does not get the data in a chart,but if I refresh whole page, I can see the Portlet 3 with the desired data in a chart.
Now the question here is why the portlet 2-- to portlet 3 communication time, the page did not get refresh. If the page gets refresh then I would see my output, so issue is not refreshing the page, during portlet 1 to portket 2 communication - page gets automatically refreshed.
here is code snippet:-
Portlet 1:-
portlet.xml:-
<portlet>
<portlet-name>ChartHandler</portlet-name>
<display-name>ChartHandler</display-name>
<portlet-class>DSChartController1</portlet-class>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>ChartHandler</title>
</portlet-info>
<supported-publishing-event>
<qname xmlns:x="http://liferay.com/events">x:chart.data</qname>
</supported-publishing-event>
</portlet>
<portlet>
<portlet-name>DisplayHandler</portlet-name>
<display-name>DisplayHandler</display-name>
<portlet-class>
DSChartDisplayController2
</portlet-class>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>DisplayHandler</title>
</portlet-info>
<supported-processing-event>
<qname xmlns:x="http://liferay.com/events">x:chart.data</qname>
</supported-processing-event>
<supported-publishing-event>
<qname xmlns:x="http://liferay.com/events">x:tradeOrigin.data</qname>
</supported-publishing-event>
</portlet>
<portlet>
<portlet-name>PieDrillDown</portlet-name>
<display-name>PieDrillDown</display-name>
<portlet-class>
DSPieChartDrillDownController
</portlet-class>
<supports>
<mime-type>text/html</mime-type>
<portlet-mode>view</portlet-mode>
</supports>
<portlet-info>
<title>PieDrillDown</title>
</portlet-info>
<supported-processing-event>
<qname xmlns:x="http://liferay.com/events">x:tradeOrigin.data</qname>
</supported-processing-event>
</portlet>
<event-definition>
<qname xmlns:x="http://liferay.com/events">x:chart.data</qname>
<value-type>java.lang.String</value-type>
</event-definition>
<event-definition>
<qname xmlns:x="http://liferay.com/events">x:tradeOrigin.data</qname>
<value-type>java.lang.String</value-type>
</event-definition>
Portlet 1 Controller:-
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String chartName= (String) request.getParameter("chartName");
request.setAttribute("chartName", chartName);
QName qname = new QName("http://liferay.com/events","chart.data");
response.setEvent(qname, chartName);
}
Portlet 2 Controller:-
@ProcessEvent(qname = "{http://liferay.com/events}chart.data")
public void receiveEvent(EventRequest request, EventResponse response)
{
Event event = request.getEvent();
String chartName = (String)event.getValue();
response.setRenderParameter("chartName", chartName);
}
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {
String tradeOrigin = request.getParameter("tradeOrigin");
request.setAttribute("tradeOrigin", tradeOrigin);
QName qname = new QName("http://liferay.com/events","tradeOrigin.data");
response.setEvent(qname, tradeOrigin);
}
Portlet 3 controller:-
@ProcessEvent(qname = "{http://liferay.com/events}tradeOrigin.data")
public void receiveEvent(EventRequest request, EventResponse response)
{
Event event1 = request.getEvent();
String tradeOrigin = (String)event1.getValue();
response.setRenderParameter("tradeOrigin", tradeOrigin);
}
public void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException{
String tradeOrigin = renderRequest.getParameter("tradeOrigin");
if(tradeOrigin!=null && tradeOrigin.length() >0){
PieDetailBean pieDetailBean = new PieDetailBean(tradeOrigin);
renderRequest.setAttribute("pieDetailBean", pieDetailBean);
viewJSP = "/JSP/pieDetail.jsp";
}
include(viewJSP, renderRequest, renderResponse);
}
protected void include(String path, RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException {
PortletRequestDispatcher portletRequestDispatcher = getPortletContext().getRequestDispatcher(path);
if (portletRequestDispatcher == null) {
System.out.println(path + " is not a valid include");
} else {
portletRequestDispatcher.include(renderRequest, renderResponse);
}
}
And portlet 3 view jsp:-
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://www.fusioncharts.com/jsp/core" prefix="fc" %>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineobjects />
<c:set var="folderPath" value="/ChartHandler-portlet/FusionCharts/" />
<c:set var="title" value="FusionCharts - Array Example using Single Series Column 3D Chart" scope="request" />
<c:set var="header1" value="FusionCharts - Examples" scope="request" />
<c:set var="header2" value=" " scope="request" />
<c:set var="jsPath" value="${folderPath}" scope="request" />
<%@page import="com.bfds.web.bean.PieDetailBean"%>
<%
PieDetailBean pieDetailBean = (PieDetailBean)renderRequest.getAttribute("pieDetailBean");
%>
<tags:template2>
<table>
<tbody><tr>
<td>
<fc:render chartId="${pieDetailBean.chartIdPieDetail}" swfFilename="/ChartHandler-portlet/FusionCharts/Column2D.swf" width="450" height="300" debugMode="false" registerWithJS="false" xmlData="${pieDetailBean.pieDetailXml}" />
</td>
</tr>
</tbody></table>
</tags:template2>