Foros de discusión

RE: Behaviuor of Multiple Portlet Instances in the same page

Salvatore Piccione, modificado hace 13 años.

Behaviuor of Multiple Portlet Instances in the same page

New Member Mensajes: 6 Fecha de incorporación: 25/01/11 Mensajes recientes
Hello everybody,

I developed a simple JSR-286 portlet in order to test how Liferay (6.0.5) handles multiple instances of the same portlet in the same page. This portlet supported VIEW, EDIT and HELP modes (I subclassed javax.portlet.GenericPortlet in order to implement the mode processing logic - just a simple redirect to specific JSP pages which provides the HTML fragment to be rendered). I created a portal page and put some instances of this portlet on that page.
I noticed that every status change of a portlet instance caused the reload of the content of the other portlets (obviousliy according to their current mode).
I am new to portlet and Liferay and, maybe, my question could be stupid. I would like to know if there is a way to avoid that a change in the mode of a portlet instance causes the other instances of the same portlet (placed in the same page) to be reloaded.

Any suggestion is appreciated.

Regards,

Salvatore
thumbnail
jelmer kuperus, modificado hace 13 años.

RE: Behaviuor of Multiple Portlet Instances in the same page

Liferay Legend Mensajes: 1191 Fecha de incorporación: 10/03/10 Mensajes recientes
You should make your portlet instanceable in that case. There is more about that here

http://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/anatomy-of-a-portlet
Salvatore Piccione, modificado hace 13 años.

RE: Behaviuor of Multiple Portlet Instances in the same page

New Member Mensajes: 6 Fecha de incorporación: 25/01/11 Mensajes recientes
Thanks for your reply, Jelmer. I forgot to write in the previous post that my simple portlet was already defined as instanceable (I put <instanceable>true</instanceable> in my liferay-portlet.xml). That strange behaviour occurs for multiple instances of the same portlet (defined as instanceable) and placed in the same page.
Oliver Bayer, modificado hace 13 años.

RE: Behaviuor of Multiple Portlet Instances in the same page

Liferay Master Mensajes: 894 Fecha de incorporación: 18/02/09 Mensajes recientes
Hi Salvatore,

setting the instancable flag as Jelmer said should work.

But if it doesn't as in your case you can use firebug to check if each portlet on your page has a different instance-id. If all have the same id then it's normal that all of them change their state at the same time. That means your changes aren't reflected. If the ids are different you have to do more debugging...

HTH Oli
Salvatore Piccione, modificado hace 13 años.

RE: Behaviuor of Multiple Portlet Instances in the same page

New Member Mensajes: 6 Fecha de incorporación: 25/01/11 Mensajes recientes
Thanks for your suggestions, Oliver.
I succefully checked that Liferay assign a unique ID to each instance of the portlet.
I also noticed that when a portlet instance changed its mode all the portal page was reloaded: this caused all other portlet instances to be reloaded. This happened because the URL of the portal page changes in order to reflect the portlet instance mode change.
I would like to know if the whole portal page is loaded because of the way I handle portlet mode. Below you can find the code of the Portlet class I defined:
public class TestMultiplePortlet extends GenericPortlet {

	public void doView(RenderRequest request, RenderResponse response)
			throws PortletException, IOException {
		System.out.println("VIEW " + request.getWindowID());
		response.setContentType("text/html");
		
	    PortletRequestDispatcher dispatcher =
	        getPortletContext().getRequestDispatcher("/WEB-INF/jsp/TestMultiplePortlet_view.jsp");
	    dispatcher.include(request, response);
		
	}


	public void doEdit(RenderRequest request, RenderResponse response)
			throws PortletException, IOException {
		System.out.println("EDIT " + request.getWindowID());
		response.setContentType("text/html");
		
        PortletRequestDispatcher dispatcher =
	        getPortletContext().getRequestDispatcher("/WEB-INF/jsp/TestMultiplePortlet_edit.jsp");
        dispatcher.include(request, response);
		
	}

	public void doHelp(RenderRequest request, RenderResponse response)
			throws PortletException, IOException {
		System.out.println("HELP " + request.getWindowID());
		response.setContentType("text/html");
		
        PortletRequestDispatcher dispatcher =
	        getPortletContext().getRequestDispatcher("/WEB-INF/jsp/TestMultiplePortlet_help.jsp");
        dispatcher.include(request, response);
		
	}
}

As you can see, every change in portlet mode causes a dispatching to a specific JSP that provides some HTML tags. Could this dispatching be the cause of the reload of the entire page? In general, is this a "normal" behaviour?
I enclosed a ZIP archive (testMultiplePortlets.zip) which contains the Eclipse Helios Project I used to define the portlet.
Sachin Hande, modificado hace 12 años.

RE: Behaviuor of Multiple Portlet Instances in the same page

New Member Mensaje: 1 Fecha de incorporación: 15/02/12 Mensajes recientes
Hi,

I am also having the same issue. I have two instances of the same portlet on the same page. Changes done to one portlet are getting refelected in the another portlet.

How can we keep the two portlets independent.?

Thanks,
Sachin
thumbnail
Raja Nagendra Kumar, modificado hace 12 años.

RE: Behaviuor of Multiple Portlet Instances in the same page

Expert Mensajes: 484 Fecha de incorporación: 2/03/06 Mensajes recientes
Check your code.. may be you are using some global data.. either from DB or global variables

In the code all of them will use same JSP page /WEB-INF/jsp/TestMultiplePortlet_view.jsp

If the JSP page does not a logic specific to each preferences of the portlet.. then all of them would see the same content..

Make sure all the view is generated based on portlet preferences, which can be customised...

e.g let the jsp render all the portlet preferences, then you would see all of them would be displaying its own preferences as customized in edit mode.

By default all the portlets are insatiable.. so need not play with this parameter..

Regards,
Raja Nagendra Kumar,
C.T.O
www.tejasoft.com
thumbnail
Roberto Javier, modificado hace 12 años.

RE: Behaviuor of Multiple Portlet Instances in the same page

New Member Mensajes: 5 Fecha de incorporación: 1/03/12 Mensajes recientes
Hi Salvatore, I have the same problem, could you solve it?
Salvatore Piccione, modificado hace 12 años.

RE: Behaviuor of Multiple Portlet Instances in the same page

New Member Mensajes: 6 Fecha de incorporación: 25/01/11 Mensajes recientes
Hello Roberto,

unfortunately I haven't found a way to solve that issue. Raja pointed out that the portlet should be "customized" in some way and I was using already the portlet preferences to configure each portlet instance. I guess the problem is due to the HTTP GET that is made in order to change the status of a portlet (e.g. from VIEW MODE to EDIT MODE and viceversa): the target URL is different from the URL of the page thats send the HTTP GET corresponding to the mode change of a portlet instance.

Regards,

Salvatore
thumbnail
Roberto Javier, modificado hace 12 años.

RE: Behaviuor of Multiple Portlet Instances in the same page

New Member Mensajes: 5 Fecha de incorporación: 1/03/12 Mensajes recientes
Thanks Salvatore,
I have 2 instances of the same portlet, I do something like this in the VIEW.JSP:

<c:set var="portletNameSpace"><portlet:namespace/></c:set>

<portlet:renderURL var="formAction">
<portlet:param name="action" value="uploadFileForm"/>
</portlet:renderURL>

<form:form id="${portletNameSpace}Form" name="${portletNameSpace}Form" action="${formAction}" commandName="uploadForm" method="post" enctype="multipart/form-data">
<form:input style="width:100%;" type="file" path="file" />
<input type="submit" value="SELECT FILE" ><br>
</form:form>


when I submit to the portlet instance 1, runs good, but later, when I submit to the instance 2, to arrive Controller preferences instance 1, and return 1 also refreshes the body. As seen in the jsp, everything is associated with the instance name, so it should work.
Do not know what else can be done.
Regards,

Roberto