掲示板

Multiple primefaces portlet instances in liferay

11年前 に Aieie Brazorf によって更新されました。

Multiple primefaces portlet instances in liferay

New Member 投稿: 12 参加年月日: 12/12/17 最新の投稿
Hi,
I'm using primefaces to creating portlet inside my liferay application.
My problem is that: from a view i push a button, and then i open a new form with my portlet called "example_portlet". this portlet lives on a different form from the others (Form_48348239). I can go back without closing the example portlet, sò i can open another form with a different id (Form_47843743) that shows a new instance of the "example_portlet". Giving a different id to the forms that contains the portlets help width the interferences, but not resolve all the problems. For example in the "example_portlet" i have a tabView with 3 tabs (1-2-3). When i click the tab 2 in the first instance of the "example_portlet" switch correctly, but when i change form to do some actions also on the second instance of the portlet i found this instance switched on the tab 2 like the first instance. I Thought it could be a problem of ID, so i give to every element in my portlet an ID that contains the key of the form (for example: Form_734837:tabView_734837, Form_734837:inputText_734837 ... ecc), but it works much worst.
Hope someone has answers or solutions for my problems, because i've tried everything!

Aieie
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Multiple primefaces portlet instances in liferay

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
When you get a chance, it would be great if you could attach a simple project that reproduces the problem. Also, please include a list of steps (1, 2, 3, ...) to follow in order to reproduce it. Thanks! -- Neil
11年前 に Aieie Brazorf によって更新されました。

RE: Multiple primefaces portlet instances in liferay

New Member 投稿: 12 参加年月日: 12/12/17 最新の投稿
Hi Neil and thanks for being interest in my problem,
I will post a piece of code, but i think that wold not be useful, because in our application we have turned a bit the liferay structure, using it all ajax style. So our application has all time rendered the same page, and in this page portlets are loaded ajax-side.
In this conditions, when i load my protlet i found in the same page the same components. For this reason i've named all the components with dynamic ids.
The structure is like that: analyzing the portlet code with firebug we found the main div created by liferay bridge, that contains the main view of my portlet. The main view contains an h:form with dynamc id and then all the other components. Here is an example of the html produced.


<div id="[b]A0845:content[/b]" class="content"> <form id="[b]A0845:form_12345678:panel_12345678[/b]" enctype="application/x-www-form-urlencoded" ... <div class="container" style="width:100%;text-align:center;"> <div id="[b]A0845:form_12345678:tabView_12345678[/b]" class="ui-tabs ui-widget ui-widget-content ui-corner-all ui-hidden-container ui-tabs-top"> <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" role="tablist"> <li class="ui-state-default ui-tabs-selected ui-state-active ui-corner-top" aria-expanded="true" role="tab"> <a href="#A0845:form_12345678:tabView_12345678:tab1_12345678">1</a> </li> <li class="ui-state-default ui-corner-top" aria-expanded="false" role="tab"> <a href="#A0845:form_12345678:tabView_12345678:tab2_12345678">2</a> </li> <li class="ui-state-default ui-corner-top" aria-expanded="false" role="tab"> <a href="#A0845:form_12345678:tabView_12345678:tab3_12345678">3</a> </li> </ul> ........ </div></form></div>


I've got a first question: why the main div created by liferay-bridge has always the same id?Can i set it dynamic?
The code of this view is that:


<!--?xml version="1.0" encoding="UTF-8"?-->
<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:p="http://primefaces.org/ui" xmlns:aui="http://liferay.com/faces/aui" xmlns:bridge="http://liferay.com/faces/bridge" xmlns:ui="http://java.sun.com/jsf/facelets" locale="#{sessionInfo.localeCode}">
	<h:head>		 
			<script type="text/javascript">
				var modify=false;
			</script>
			
			<script type="text/javascript">
				function downloadFile(url) {
					window.open(url);
				}
			</script>
			
	</h:head>
	 
	<ui:debug />
	<h:body>  
		      <p:growl showDetail="false" autoUpdate="true" closable="true" severity="info,error,fatal,warn" />
     
				
			<p:outputpanel layout="block" styleclass="content" id="content">
 				<h:form id="form_#{entryPoint.key}">
					<ui:fragment rendered="#{entryPoint.jsonRequest==null}">
 				      	 	<h:inputhidden value="#{entryPoint.jsonRequest}" id="jsonRequest" style="visibility:hidden;line-height:1px;" /> 
 						<p:remotecommand process="jsonRequest" name="jsonRequestUpdateRemote" update="@form" />
 					</ui:fragment>
	 				
					<input type="hidden" id="sender_#{entryPoint.key}" style="visibility:hidden;line-height:1px;"> 
 					<h:inputhidden value="#{entryPoint.sender}" id="senderRequest_#{entryPoint.key}" style="visibility:hidden;line-height:1px;" />
 					<input type="hidden" id="key_#{entryPoint.key}" style="visibility:hidden;line-height:1px;"> 
 					<h:inputhidden value="#{entryPoint.key}" id="keyRequest_#{entryPoint.key}" style="visibility:hidden;line-height:1px;" /> 
 					<p:remotecommand process="senderRequest_#{entryPoint.key},keyRequest_#{entryPoint.key}" name="senderRequestUpdateRemote" update="@form" global="true" immediate="true" />
 					
 					 
					<p:outputpanel styleclass="container" id="panel_#{entryPoint.key}" layout="block" style="width:100%;text-align:center;" rendered="#{entryPoint.genericBck.pageRendered}">
						<p:tabview id="tabView_#{entryPoint.key}" widgetvar="tabView_#{entryPoint.key}" dynamic="true" cache="true">
							<p:tab title="1" id="tab1_#{entryPoint.key}">
								test 1
								<p:commandbutton id="buttonAction_#{entryPoint.key}" action="#{entryPoint.genericBck.action}" value="action" />
								
							</p:tab>
							<p:tab title="2" id="tab2_#{entryPoint.key}">
								test 2
								
							</p:tab>
							<p:tab title="3" id="tab3_#{entryPoint.key}">
								test 3
								
							</p:tab>
						</p:tabview>
							
	 				</p:outputpanel>
						 
					 
			 		 
			    
			    		<ui:fragment id="jsonScript" rendered="#{entryPoint.jsonRequest==null}">
						<script type="text/javascript">
							//script executed during the loading of the page, i read the json data and store
							var valueJsonSender=#{entryPoint.sender}.params;
							document.getElementById("#{p:component('jsonRequest')}").value=valueJsonSender	;
							var nameFieldSender="sender_#{entryPoint.key}";
							var nameFieldKey="key_#{entryPoint.key}";
							document.getElementById(nameFieldSender).value="#{entryPoint.sender}";
							document.getElementById(nameFieldKey).value="#{entryPoint.key}";
 						
							jsonRequestUpdateRemote();
						</script>
					</ui:fragment>
					
					<script type="text/javascript">
                                          //script executed when i click the menu and the portlet opened previously is re-rendered, i reload the current key  and sender, so i can reload the correct bck
						if(!modify){
							modify=true;
							  
							MYjQuery('a.MYNavAnchor').click(function(event){
								var valTargetRef=event.currentTarget.href;
								if(valTargetRef.indexOf('/home/')>0  ){

									var posTargetRef=valTargetRef.indexOf('?sender=')+8;
									var posEndTargetRef=valTargetRef.indexOf('ts=')-1;
									var senderTargetRef=valTargetRef.substring(posTargetRef,posEndTargetRef); 
									
									var posKeyRef=valTargetRef.indexOf('ts=')+3;
									var keyTargetRef=valTargetRef.substring(posKeyRef); 
									document.getElementById("#{p:component('senderRequest')}").value=senderTargetRef; 
									document.getElementById("#{p:component('keyRequest')}").value=keyTargetRef;
									senderRequestUpdateRemote(); 
								}
							})
						}
					</script>	
				
				</h:form>
				
				
			</p:outputpanel>
			
	  
			
			<ui:insert name="commonStatus">
			  	<p:ajaxstatus id="commandStatus">  
    					<f:facet name="start"> 
						<p:outputpanel layout="block" style="background-image: url('../images/others/loading_animation.gif');height: 100%; width: 100%; z-index: 2000; position:fixed; top: 0px; left:0px;  background-color: #e8e6ee; vertical-align: center; background-repeat: no-repeat; background-position: center; filter:alpha(opacity=45); -moz-opacity:.45; opacity:.45;"> 
				 		
						</p:outputpanel>
   				 	</f:facet>  
  
   				 	<f:facet name="complete">  
       					 <h:outputtext value="" />  
   				 	</f:facet>
				 </p:ajaxstatus>

			</ui:insert>
			    
 			 				
	</h:body>
	
</f:view>


For a more clear understanding, i'll explain a bit: there are two fields, a sender and a key, that are passed trough the url request. In my securityPhaseListener's method afterPhase i create the entity entryPoint and i save sender and key. Then i rendered the content inside the central panel reading data passed in a javascript json variable. The entity genericBck is created during this process and stored in session with a key in a way like that (inside the entryPoint class):


 public GenericBck getGenericBck(){
		 try{
			 return (GenericBck)JSFUtil.getManagedObject("genericBck"+"_"+key);
		 }catch(Exception e){
			 return null;
		 }
	 }


the method "getManagedObject" read from the FacesContext the session-application object stored. So we have the same number of bck as the number of times we open a new portlet.
So the problem is what i say yesterday: when i opened another portlet ajax-side (inside the same page), the content is rendered, the bcks are stored correctly, but when i click a tab of one portlet the content is not rendered (only the last portlet opened works), or if i click the commandButton, the action is never executed (except for the last portlet opened). if i give a generic static id to all my components, the behaviour is that the first portlet in hierarchy controls all the others (so when i switch tab in the first portlet, all the others portlet switches, and when i switch tab in another portlet, all the portlets change tab but only the content of the first portlet is rendered).

Hope you can help me. If you don't understand everything, just tell me and i will explain it in a more detailed way (also with screenshots).
Thans!

Aieie
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Multiple primefaces portlet instances in liferay

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Let me try to address this question first:
I've got a first question: why the main div created by liferay-bridge has always the same id? Can i set it dynamic?

The unique ID is generated by the BridgeContextImpl.getResponseNamespace() method. The algorithm simply takes the last 4 characters of the portlet name hashcode. But it sounds like this is not working out well for your use-case.

In order to solve problems like this, Liferay Faces Bridge has an extension mechanism that will enable you to decorate the BridgeContextFactory, so that you can provide your own BridgeContext.getResponseNamespace() algorithm.

First, create a wrapper class for the BridgeContext that overrides the getResponseNamespace() method:

package com.mycompany.myproject;
public class BridgeContextCustomImpl extends BridgeContextWrapper {

    private BridgeContext wrappedBridgeContext;

    public BridgeContextCustomImpl(BridgeContext bridgeContext) {
        this.wrappedBridgeContext = bridgeContext;
        BridgeContext.setCurrentInstance(this);
    }

    @Override
    public String getResponseNamespace() {
        // return value based on custom algorithm.
    }

    @Override
    public BridgeContext getWrapped() {
        return wrappedBridgeContext;
    }
}


Then create a wrapper class for the BridgeContextFactory:

package com.mycompany.myproject;
public class BridgeContextFactoryCustomImpl extends BridgeContextFactory {

    private BridgeContextFactory wrappedBridgeContextFactory;

    public BridgeContextFactoryCustomImpl(BridgeContextFactory bridgeContextFactory) {
        this.wrappedBridgeContextFactory =  bridgeContextFactory;
    }

    public BridgeContextFactory getWrapped() {
        return wrappedBridgeContextFactory;
    }

    @Override
    public BridgeContext getBridgeContext(BridgeConfig bridgeConfig, BridgeRequestScope bridgeRequestScope,
        PortletConfig portletConfig, PortletContext portletContext, PortletRequest portletRequest,
        PortletResponse portletResponse, Bridge.PortletPhase portletPhase, PortletContainer portletContainer,
        IncongruityContext incongruityContext) {

        BridgeContext wrappedBridgeContext = wrappedBridgeContextFactory.getBridgeContext(bridgeConfig, bridgeRequestScope, portletConfig,
            portletContext, portletRequest, portletResponse, portletPhase, portletContainer, incongruityContext);

        BridgeContext bridgeContext = new BridgeContextCustomImpl(wrappedBridgeContext);

        return bridgeContext;
    }
}


Then, in your portlet's WEB-INF/faces-config.xml, specify your factory:

<faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:bridge="http://www.liferay.com/xml/ns/liferay-faces-bridge-2.0-extension" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0" xsi:schemalocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
	<factory>
		<factory-extension>
			<bridge:bridge-context-factory>com.mycompany.myproject.BridgeContextFactoryCustomImpl</bridge:bridge-context-factory>
		</factory-extension>
	</factory>
</faces-config>


After you rebuild and re-deploy your portlet WAR, the settings should take effect.
11年前 に Aieie Brazorf によって更新されました。

RE: Multiple primefaces portlet instances in liferay

New Member 投稿: 12 参加年月日: 12/12/17 最新の投稿
Hi Neil,
i think your tip could be a first step in order to solve my problem.
I have done exactly what you say , the class has been loaded correctly (i've tested it in debug mode) but the only method that is never called is my getResponseNamespace ovveride:


@Override
    public String getResponseNamespace() {
        String id="BridgePanel_"+String.valueOf(System.currentTimeMillis());
    	return id;
    }


I've inspected the call hierarchy of the method getReponseNamespace, and i've seen that this method is called by class ExternalContextImpl, so i wonder if i'll have to implement other classes.

Returning at my original problem, have you got any other tip?
Thanks a lot

Aieie
11年前 に Aieie Brazorf によって更新されました。

RE: Multiple primefaces portlet instances in liferay

New Member 投稿: 12 参加年月日: 12/12/17 最新の投稿
I'm here again,
i was testing the prime portlet 3 demo that is downloadable from the liferay-faces website, and putting this portlet in the same page of my own portlet, it has the same problem of interference when multiple portlets are opened. I think you can use that portlet to try what i'm saying.
Clicking the link "show comments" only in the first portlet works and re-render the textArea, instead in the second portlet doesn't work, and the textArea is never shown.

Aieie
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Multiple primefaces portlet instances in liferay

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
I just tried to reproduce the problem you described with the following steps:

1) Start Liferay 6.1.1 CE GA2 with Tomcat 7.

2) Download the primefaces3-portlet WAR from the demos page.

3) Copied the WAR to the Liferay /deploy folder

4) Visit http://localhost:8080

5) Login as Administrator

6) Create a new portal page

7) Click on the new portal page

8) Add the primefaces3-portlet TWICE to the new portal page

9) Refresh the portal page

10) Click on "Show Comments" in both portlets

11) Look at HTML source, and the bridge generated an outermost-div with id "A9808" for one and "A4383" for the other.

... But it's working fine for me. No errors, no collisions, no problems.

Are these similar to the steps that you followed?

Also, when you get a chance, I would like to know more about what you wrote here:

because in our application we have turned a bit the liferay structure, using it all ajax style.
So our application has all time rendered the same page, and in this page portlets are loaded ajax-side.


Specifically, what do you mean when you say "ajax style" and "ajax side"?
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Multiple primefaces portlet instances in liferay

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Forgot to mention that regarding your question about ExternalContext, it should simply call through to your BridgeContext decorator. You shouldn't need to do anything else. If you were to set a breakpoint inside BridgeContextImpl.getResponseNamespace(), I'd be interested to know what the callstack looks like.
11年前 に Aieie Brazorf によって更新されました。

RE: Multiple primefaces portlet instances in liferay

New Member 投稿: 12 参加年月日: 12/12/17 最新の投稿
Neil Griffin:


10) Click on "Show Comments" in both portlets

11) Look at HTML source, and the bridge generated an outermost-div with id "A9808" for one and "A4383" for the other.

... But it's working fine for me. No errors, no collisions, no problems.

Are these similar to the steps that you followed?


The steps are similar, and following that everything works!But try to upload a file, in both theese portlets, and you will saw that only in one portlet you will be able to see the uploaded file, in the other the upload doesn't work, and if you try to click again the link "show comments" only in one portlet works. It seems like after the upload method, something have been broken.
11年前 に Aieie Brazorf によって更新されました。

RE: Multiple primefaces portlet instances in liferay

New Member 投稿: 12 参加年月日: 12/12/17 最新の投稿
About the ResponseNamespace method, with a break point, the method is never called. I follow your tip, but all the other methods are called (if i override for example "getFacesViewId()" it's called from the bridge context), but the overrided ResponseNamespace is never called. Sò i ask to you if there's something else to override.

Doing a lot of various test, i realized that the cause of my portlet interference is the protlet bridge div's id.
I'll try to explain the structure, so you could better understand the problem.

In my liferay application, my url is often "locahost:8080/...../home" and the content is rendered ajax-side.
There is a button, that opens a new div containing the page where my portlet is instantiated.
imagine these steps:

-click the button "open my portlet"
- the new div appears, but the page mapped in url is often "../home" (remember everything is ajax-side), but in the content is loaded the "page" that contains my portlet
- the portlet is loaded. With firebug i analyze the source and see that the portlet-bridge auto generated div has id = "A3875".
- without closing these div, i click again "open my portlet" and another div is created, with contains the page with another instance of my portlet.
- Analyzing with firebug, also this div has id= "A3875".

So i have 2 portlet, in different div, but that has the portlet-bridge auto-generated div with the same id.
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Multiple primefaces portlet instances in liferay

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
I will try the BridgeContext factory wrapper today and see if I can reproduce the problem. I'll get back to you on that.

Quick question -- when you wrote:
- the new div appears, but the page mapped in url is often "../home" (remember everything is ajax-side), but in the content is loaded the "page" that contains my portlet


I am interested to know how the procedure as to how you are creating the new div, and how the div contains the contents of a "page", since a page is a full <html>...</html> document and not a fragment of markup.
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Multiple primefaces portlet instances in liferay

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Sorry, my fault emoticon -- I've corrected the instructions above -- the fix is to add the call to BridgeContext.setCurrentInstance(this); at the end of the constructor like this:

    public BridgeContextCustomImpl(BridgeContext bridgeContext) {
        this.wrappedBridgeContext = bridgeContext;
        [b]BridgeContext.setCurrentInstance(this);[/b]
    }
11年前 に Aieie Brazorf によって更新されました。

RE: Multiple primefaces portlet instances in liferay

New Member 投稿: 12 参加年月日: 12/12/17 最新の投稿
Hi Neil,
first of all, merry Christmas and Happy new Year!
I've tried the new solution you gave, and it works!!
Now i can control the bridge auto-generated div's id.
I've encountered new problems, because of the structure of my application, but is not a liferay problem i think. The only matter is that for the moment i can't test if the portlets with 2 different div's id interferences each other.
But soon (next week) i will report if this solution works!
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Multiple primefaces portlet instances in liferay

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Hi Aieie,

I'm so glad to hear that it is working now. Looking forward to hearing more next week.

Merry Christmas and Happy New Year to you too!

Neil
11年前 に Aieie Brazorf によって更新されました。

RE: Multiple primefaces portlet instances in liferay

New Member 投稿: 12 参加年月日: 12/12/17 最新の投稿
Hi Neil,
i will begin the 2013 with a question for you. I need to know if in the class BridgeContextCustomImpl i have the visibility of the PortletRequest. In the request i have a parameter that will help me with the portlet interference's problem, so i can use this parameter in getResponseNamespace method .
Hope you can help.
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Multiple primefaces portlet instances in liferay

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Hi Aieie,

The BridgeContext abstract class has the following method that you can call from your getResponseNamespace() method:

/**
	 * Returns the {@link PortletRequest} associated with the current request.
	 */
	public abstract PortletRequest getPortletRequest();


Best Regards,

Neil
11年前 に Aieie Brazorf によって更新されました。

RE: Multiple primefaces portlet instances in liferay

New Member 投稿: 12 参加年月日: 12/12/17 最新の投稿
Hi Neil,
new problems incoming.
I'm trying to get url parameters from FacesContext.getCurrentInstance().getExternalContext().getRequest(), but when the object request obtained is a ResourceRequest, i can't obtain the http parameter of the url, in the parameter map there are only resource parameters..is there a way to obtain the http parameters of the url from a resourceRequest?
Thanks for help
11年前 に Steven Behne によって更新されました。

RE: Multiple primefaces portlet instances in liferay

New Member 投稿: 4 参加年月日: 12/10/17 最新の投稿
Hi,

i know i interrupt your topic, but maybe both you could help me with a little thing. Is there any InstanceManagingClass inside of Liferay, where i can get the unique id of a portlet-instance?

request.getAttribute("PORTLET_ID").toString() can't help me out.

Thanks
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Multiple primefaces portlet instances in liferay

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Is there any InstanceManagingClass inside of Liferay, where i can get the unique id of a portlet-instance?


A new message thread is probably best in order to keep topics/questions separate. emoticon

I would recommend that you try something like the following...

If you are using the liferay-faces-portal.jar dependency, you can do something like this:
LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
ThemeDisplay themeDisplay = liferayFacesContext.getThemeDisplay();
PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();


Otherwise, you can do something like this:

FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
ThemeDisplay themeDisplay = (ThemeDisplay) externalContext.getRequestMap().get(WebKeys.THEME_DISPLAY);
PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();


You might want to check out all of the getter methods available on the PortletDisplay object. It might be the getPortletName() method that you are interested in.
11年前 に Aieie Brazorf によって更新されました。

RE: Multiple primefaces portlet instances in liferay

New Member 投稿: 12 参加年月日: 12/12/17 最新の投稿
Hi Neil,
i would like to know something more about the getResponseNamespace method of BridgeContextCustomImpl class. In particular, i realized that this method is called every time i view the portlet. I'll explain better. When i enter in this method (debug) i get the request with the method FacesContext.getCurrentInstance().getExternalContext().getRequest(), i noticed that we have 2 different type of request, RENDERREQUEST and RESOURCEREQUEST. A renderRequest is a rendering request of a new component, instead of the resourceRequest that is a viewing request of an existing component.
Obviously, i wold like to generate my custom response namespace only during a renderRequest, on the contrary i would mantain the old response Namespace when i get a resource request.
I've created a member of BridgeContextCustomImpl class (protected String responseNamespaceCustom) , where i store the previously generated id, sò with the resource request in the getResponseNamespace method i recover and return the old id, with the renderRequest i generate a new one.
But it doesn't work. Because (i really don't know why) there are many instances of BridgeContextCustomImpl, sò i can't recover the old member id generated.
If you don't understand what i write, i'll explain better.
Hope you could help me.
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Multiple primefaces portlet instances in liferay

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Hi Aieie,

The BridgeContext is a ThreadLocal singleton instance (similar in scope to FacesContext). Since the current thread is associated with an underlying HttpServletRequest, a new instance is created for each request.

If you want to re-use your custom response namespace from request to request, then I think you have two choices:

1. Store the custom response namespace in a PortletSession attribute.

2. Store the custom response namespace in as a ViewScope attribute.

Neil
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Multiple primefaces portlet instances in liferay

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
is there a way to obtain the http parameters of the url from a resourceRequest?


You should be able to get a query string parameter using one of these approaches:

1. If you're using the liferay-faces-portal.jar dependency, you can do this:

LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
String foo = liferayFacesContext.getRequestQueryStringParameter("foo");


2. Get the entire query string from a request attribute:

FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
String queryString = externalContext.getRequestMap().get("javax.servlet.forward.query_string");


3. Get the original URL using the Liferay Portal API:

import com.liferay.portal.util.PortalUtil;
...
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
String url = PortalUtil.getPortalURL(portletRequest);
thumbnail
11年前 に Neil Griffin によって更新されました。

RE: Multiple primefaces portlet instances in liferay

Liferay Legend 投稿: 2655 参加年月日: 05/07/27 最新の投稿
Right, the upload failure is a known issue (see FACES-1384 for more info). If possible I would like to leave file upload out of the discussion for now, so that we can focus on your main issue (the id of the outermost div).