掲示板

How to update jsf component from portlet to another portlet

7年前 に aroma defg によって更新されました。

How to update jsf component from portlet to another portlet

New Member 投稿: 12 参加年月日: 17/04/02 最新の投稿
I'm newbie for portlet, I have 1 Liferay plugin project and 2 portlet in project.
I want to update jsf component from portlet to portlet by click a button in one xhtml and update text in another xhtml
view1.xhtml (A-portlet)
<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">
	<h:head />
	<h:body>
		<h:form id="form1">
			<h:inputtext value="#{testAjax.textInput}" />
			<p:commandbutton value="Submit" actionListener="#{testAjax.testMethod}" update="display" />
		</h:form>
	</h:body>
</f:view>


view2.xhtml(B-portlet)
<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">
	<h:head />
	<h:body>
		<h:outputtext id="display" value="#{testAjax.textDisplay}" />
	</h:body>
</f:view>


my tried
1. update="display" error in xthml page not found component
2. update="@([id$=display])" not get any error and not update
3. in backing bean RequestContext.getCurrentInstance().update("display"); error in backing bean not found component
RequestContext.getCurrentInstance() get instance on view1.xhtml and find component in A-portlet(_a-portlet_...)

Please, tell me how.
Thank in advance.

P.S. I'm using Primefaces6.0
thumbnail
7年前 に Juan Gonzalez によって更新されました。

RE: How to update jsf component from portlet to another portlet

Liferay Legend 投稿: 3089 参加年月日: 08/10/28 最新の投稿
What Liferay version do you want to use?
7年前 に aroma defg によって更新されました。

RE: How to update jsf component from portlet to another portlet

New Member 投稿: 12 参加年月日: 17/04/02 最新の投稿
6.2 sir
thumbnail
7年前 に Kyle Joseph Stiemann によって更新されました。

RE: How to update jsf component from portlet to another portlet

Liferay Master 投稿: 760 参加年月日: 13/01/14 最新の投稿
Hi Aroma,
What you are trying to accomplish is called Inter-Portlet Communication (IPC). In Portlet 2.0, there are two standard ways of accomplishing IPC: events and public render parameters. The Liferay Faces project has demos and example code that you can look at for each of these techniques. For events IPC we have the JSF Customers and Bookings Event IPC Portlets. For public render parameters IPC we have the JSF Public Render Parameters Portlets.

Unfortunately, there is no standards based way to perform IPC via Ajax in Portlet 2.0 (it's coming in Portlet 3.0 though emoticon). You could accomplish this through PrimeFaces Ajax Push if PrimeFaces Issue #337 were implemented (+1 the issue and Subscribe if you want it implemented), but for now it's not even possible with PrimeFaces Ajax Push.

- Kyle
7年前 に aroma defg によって更新されました。

RE: How to update jsf component from portlet to another portlet

New Member 投稿: 12 参加年月日: 17/04/02 最新の投稿
Thanks, sir
IPC need refresh page and scoped(application, session), right ?
7年前 に aroma defg によって更新されました。

RE: How to update jsf component from portlet to another portlet

New Member 投稿: 12 参加年月日: 17/04/02 最新の投稿
I tried do this link and read this but not success, sad

I just need send a text from portlet(view1.xthml) to another portlet(view2.xhtml)
view1.xhtml

<h:form id="form1">
<h:commandbutton id="btnSubmit" value="mytext" actionListener="#{clouderaView.submit}" />
<h:form id="form1"></h:form></h:form>

view2.xhtml

<h:form id="form1">
<h:inputtext value="#{model1Bean.txtRender}" />
</h:form>


portlet.xml

<portlet-app ....>
	<portlet id="portlet1">
		<portlet-name>portlet1</portlet-name>
		<display-name>portlet1</display-name>
		<portlet-class>javax.portlet.faces.GenericFacesPortlet</portlet-class>
		<init-param>
			<name>javax.portlet.faces.defaultViewId.view</name>
			<value>/WEB-INF/views/view.xhtml</value>
		</init-param>
		<init-param>
			<name>javax.portlet.faces.bridgePublicRenderParameterHandler</name>
			<value>com.liferay.sample.LiferayHandler</value>
		</init-param>
		.........
		<supported-public-render-parameter>txtRender</supported-public-render-parameter>
	</portlet>
	<portlet>
		<portlet-name>chart-pie</portlet-name>
		<display-name>Chart Pie</display-name>
		<portlet-class>
			javax.portlet.faces.GenericFacesPortlet
		</portlet-class>
		<init-param>
			<name>javax.portlet.faces.defaultViewId.view</name>
			<value>/WEB-INF/views/chartPie.xhtml</value>
		</init-param>
		<init-param>
			<name>javax.portlet.faces.bridgePublicRenderParameterHandler</name>
			<value>cdg.liferay.sample.LiferayHandler</value>
		</init-param>
		........
		<supported-public-render-parameter>txtRender</supported-public-render-parameter>
	</portlet>
	<public-render-parameter>
		<identifier>txtRender</identifier>
		<qname xmlns:x="http://liferay.com/pub-render-params">x:txtRender</qname>
	</public-render-parameter>
</portlet-app>

LiferayHandler.java

public class LiferayHandler implements BridgePublicRenderParameterHandler{
	private static final Logger log = LoggerFactory.getLogger(LiferayHandler.class);
	
	public void processUpdates(FacesContext facesContext) {
		log.debug("processUpdates");
	}
}

Can you explain me step by step, How to use public render parameters
thumbnail
7年前 に Kyle Joseph Stiemann によって更新されました。

RE: How to update jsf component from portlet to another portlet

Liferay Master 投稿: 760 参加年月日: 13/01/14 最新の投稿
Hi Aroma,
If you are using JSF 2.2 use the 4.0.0 version of the PRP portlet. If you are using JSF 2.1 use the 3.0.0 version of the PRP portlet. Please try copying the code from the PRP portlets project to a project generated by our archetypes. Once you get that working, change the code in the portlets to whatever you need specifically.

- Kyle
7年前 に aroma defg によって更新されました。

RE: How to update jsf component from portlet to another portlet

New Member 投稿: 12 参加年月日: 17/04/02 最新の投稿
Kyle Joseph Stiemann:
Hi Aroma,
If you are using JSF 2.2 use the 4.0.0 version of the PRP portlet. If you are using JSF 2.1 use the 3.0.0 version of the PRP portlet. Please try copying the code from the PRP portlets project to a project generated by our archetypes. Once you get that working, change the code in the portlets to whatever you need specifically.

- Kyle



Can I send a map<String, Number> parameter or send String type only
7年前 に aroma defg によって更新されました。

RE: How to update jsf component from portlet to another portlet

New Member 投稿: 12 参加年月日: 17/04/02 最新の投稿
I found it, this link portlet session solved my issue and easy to use
next, pie chart in primefaces(6.0) not display on portlet 6.2, I will post new thread
thumbnail
7年前 に Kyle Joseph Stiemann によって更新されました。

RE: How to update jsf component from portlet to another portlet

Liferay Master 投稿: 760 参加年月日: 13/01/14 最新の投稿
Hi Aroma,
<private-session-attributes>false</private-session-attributes> is a vendor-specific feature of Liferay Portal that is not compatible with our standards-based JSF portlet bridge. Among other side-effects, <private-session-attributes>false</private-session-attributes> can cause memory leaks in @ViewScoped beans.

Could you explain more about your design?

Are you trying to view the same data in different ways (in different portlets)? PRP is more appropriate for that use-case. For example, if you can use a simple String id value to access the data in either portlet, it would probably be easier to use PRP.

Or, are you trying to change and modify the data in other portlets? In that case, you should probably use events IPC. As long as the data you are sending between portlets is Serializable you can use whatever type of payload you want with events IPC.

- Kyle
7年前 に aroma defg によって更新されました。

RE: How to update jsf component from portlet to another portlet

New Member 投稿: 12 参加年月日: 17/04/02 最新の投稿
Kyle Joseph Stiemann:
Hi Aroma,
<private-session-attributes>false</private-session-attributes> is a vendor-specific feature of Liferay Portal that is not compatible with our standards-based JSF portlet bridge. Among other side-effects, <private-session-attributes>false</private-session-attributes> can cause memory leaks in @ViewScoped beans.

Could you explain more about your design?

Are you trying to view the same data in different ways (in different portlets)? PRP is more appropriate for that use-case. For example, if you can use a simple String id value to access the data in either portlet, it would probably be easier to use PRP.

Or, are you trying to change and modify the data in other portlets? In that case, you should probably use events IPC. As long as the data you are sending between portlets is Serializable you can use whatever type of payload you want with events IPC.

- Kyle


My Portal contain 2 portlets 1st picklist (input) 2rd piechart(output) and I need to send PieChartModel(Primefaces) I will try events IPC after I solved my new issue I develop on Liferay 6.2. CE GA5, I can deploy on it but, cant deploy on 6.2 CE GA4

07:12:54,012 INFO  [HookHotDeployListener:693] Registering hook for LiferayPortlet
07:12:54,017 INFO  [HookHotDeployListener:821] Hook for LiferayPortlet is available for use
07:12:54,018 INFO  [PortletHotDeployListener:344] Registering portlets for LiferayPortlet
07:12:54,431 INFO  [PortletHotDeployListener:497] 2 portlets for LiferayPortlet are available for use
07:12:54,934 INFO  [HotDeployEvent:145] Plugin LiferayPortlet requires marketplace-portlet
07:12:54,934 INFO  [PortletHotDeployListener:525] Unregistering portlets for LiferayPortlet
07:12:54,939 INFO  [PortletHotDeployListener:565] 2 portlets for LiferayPortlet were unregistered
07:12:54,939 INFO  [HookHotDeployListener:952] Hook for LiferayPortlet was unregistered
07:12:54,940 INFO  [PluginPackageUtil:1016] Reading plugin package for LiferayPortlet
07:12:54,940 WARN  [PluginPackageUtil:1114] Plugin package on context LiferayPortlet cannot be tracked because this WAR does not contain a liferay-plugin-package.xml file


How to solve
thumbnail
7年前 に Neil Griffin によって更新されました。

RE: How to update jsf component from portlet to another portlet

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Note: The Liferay 6.2. CE GA5 / GA4 issue is being addressed in a separate thread titled Deploy my portlet to Liferay CE 6.2 GA4 not error not appear