Foros de discusión

IPC between a jsf-portlet and a wiki portlet

Rene Ramacher, modificado hace 9 años.

IPC between a jsf-portlet and a wiki portlet

New Member Mensajes: 12 Fecha de incorporación: 19/12/14 Mensajes recientes
Hi,

I’m developing a jsf-portlet (named WikiControl) which provides the parameter "WikiTitle" as a public render parameter. This public render parameter should be mapped to the “title”-parameter of the wiki-portlet (the one that comes with Liferay) to control the wiki page that is shown in that wiki-portlet. I was able to configure the WikiControl-portlet such that Liferay recognizes that it provides the public render parameter "WikiTitle". I have done so by adding the following lines to the portlet.xml file:

<portlet>
<portlet-name>WikiControl</portlet-name>
…
<supported-public-render-parameter>WikiTitle</supported-public-render-parameter>
</portlet>
<public-render-parameter>
<identifier>WikiTitle</identifier>
<qname xmlns:x="http://www.liferay.com/public-render-parameters">x:WikiTitle</qname>
</public-render-parameter>


I configured the wiki-portlet such that it reads the “WikiTitle” render parameter as the value of its “title” parameter (see attached figure).

The value of the “WikiTitle” render parameter is set within the method “openPage” of the backing-bean which is called from the view. The method looks like this:


public String openPage(WikiPage p) {
	FacesContext facesContext = FacesContext.getCurrentInstance();
	Object responseObject = facesContext.getExternalContext().getResponse();
	if (responseObject != null &amp;&amp; responseObject instanceof ActionResponse) {
		ActionResponse actionResponse = (ActionResponse) responseObject;
		actionResponse.setRenderParameter("WikiTitle", p.getTitle());
	}
	return "/views/WikiControlView.xhtml";
}


The invocation of the method from the view is implemented using a commandLink as follows:


<h:commandlink value="#{p.title}" action="#{meinMock.openPage(p)}">
</h:commandlink>


I checked that the method "openPage" is actually invoked and that the page is reloaded. Unfortunately, neither the wiki portlet reacts on the parameter nor is the parameter included in the URL after I clicked the aforementioned link.

Can anybody give me a hint what the problem could be?

Thank you in advance
René

Archivos adjuntos:

thumbnail
Vernon Singleton, modificado hace 9 años.

RE: IPC between a jsf-portlet and a wiki portlet

Expert Mensajes: 315 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi Rene,

Rene Ramacher:
I checked that the method "openPage" is actually invoked and that the page is reloaded. Unfortunately, neither the wiki portlet reacts on the parameter nor is the parameter included in the URL after I clicked the aforementioned link.

Can anybody give me a hint what the problem could be?

Could you try our try our jsf2-ipc-pub-render-params-portlet(s) in your environment and let us know if they are working?

If those portlets are working, take a look at them and any differences between those two and yours. Specifically, the faces-config.xml file.

Hope that helps,
Vernon
Rene Ramacher, modificado hace 9 años.

RE: IPC between a jsf-portlet and a wiki portlet

New Member Mensajes: 12 Fecha de incorporación: 19/12/14 Mensajes recientes
Hi Vernon,

thank you for your response. I tried the jsf2-ipc-pub-render-params-portlet in my environment and it is working as it should. I can select a customer in the customer Portlet and the details to the selected customer are shown in the booking Portlet.

However, I think that my requirements are slightly different: The demo shows the inter-Portlet-communication between two jsf Portlets. As far as I understand the demo, the public render parameter is shared between the Portlets through the faces-bridge-portlet. This parameter-sharing is configured in the faces-config.xml file. But in my situation, I have a jsf-Portlet on the one hand and the wiki-portlet on the other hand. I couldn’t configure a parameter-sharing between my jsf-Portlet and the wiki-portlet within the faces-config.xml file, because the wiki-portlet isn’t a jsf-portlet. This is why I belief that I need to share the parameter through the URL instead of sharing the parameter through the faces-bridge.

What I have done so far is to generate the URL by my own within a function of the backing-bean:


public String getLink(WikiPage pc) {
 FacesContext facesContext = FacesContext.getCurrentInstance();
 ExternalContext externalContext = facesContext.getExternalContext();
 PortletResponse portletResponse = (PortletResponse) externalContext.getResponse();
    	
 LiferayPortletResponse liferayPortletResponse =
            PortalUtil.getLiferayPortletResponse(portletResponse);
    	
 LiferayPortletURL liferayPortletURL =  liferayPortletResponse.createLiferayPortletURL( "view" );
 liferayPortletURL.setParameter("WikiTitle", pc.getTitle());
 return liferayPortletURL.toString();   	        
}


In the view, I integrate the generated link per WikiPage using the h:outputLink tag where p is a wikipage:


<h:outputlink value="#{meinMock.getLink(p)}">
	<h:outputtext value="#{p.title}"></h:outputtext>
</h:outputlink>


The approach works. Nevertheless, I’m in doubt whether it is a good choice to generate the link by my own instead of using the faces navigation mechanism.

René
thumbnail
Vernon Singleton, modificado hace 9 años.

RE: IPC between a jsf-portlet and a wiki portlet (Respuesta)

Expert Mensajes: 315 Fecha de incorporación: 14/01/13 Mensajes recientes
Hi René,

Rene Ramacher:
The approach works. Nevertheless, I’m in doubt whether it is a good choice to generate the link by my own instead of using the faces navigation mechanism

Glad to hear that you got it working.

I went ahead and took the opportunity to try this myself with our out-of-the-box wiki portlet:

I modified our showcase portlet.xml with the following (which you can find in our portlet-custom.xml):
		<supported-public-render-parameter>title</supported-public-render-parameter>
	
	<public-render-parameter>
		<identifier>title</identifier>
		<qname xmlns:w="http://www.liferay.com/public-render-parameters/wiki">w:title</qname>
	</public-render-parameter>

So, now our showcase-portlet can set the wiki's public render parameter called "title".
Then, I simply added this blurb to create a link in our showcase portlet:
... xmlns:portlet="http://java.sun.com/portlet_2_0" ...

<portlet:renderurl var="myRenderURL">
	<portlet:param name="title" value="#{showcaseModelBean.selectedComponent.useCaseName}" />
</portlet:renderurl>

<a href="#{myRenderURL}">#{showcaseModelBean.selectedComponent.useCaseName}</a><br>

And now the showcase has a link to the corresponding wiki page with that title "#{showcaseModelBean.selectedComponent.useCaseName}".

I also tried the way that you showed, using an outputLink like this:
<h:outputlink value="#{showcaseBackingBean.link}">
	<h:outputtext value="#{showcaseModelBean.selectedComponent.useCaseName}"></h:outputtext>
</h:outputlink>

And a corresponding getter method in my request scoped backing bean as follows:
	public String getLink() {
		ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
		MimeResponse mimeResponse = (MimeResponse) externalContext.getResponse();
		PortletURL renderUrl = mimeResponse.createRenderURL();
		renderUrl.setParameter("title", showcaseModelBean.getSelectedComponent().getUseCaseName());
		return renderUrl.toString();
	}

And that seems to work also.

Hope that helps,
Vernon