Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Multiple primefaces portlet instances in liferay Aieie Brazorf 17 dicembre 2012 1.59
RE: Multiple primefaces portlet instances in liferay Neil Griffin 17 dicembre 2012 7.48
RE: Multiple primefaces portlet instances in liferay Aieie Brazorf 18 dicembre 2012 7.53
RE: Multiple primefaces portlet instances in liferay Neil Griffin 21 dicembre 2012 13.01
RE: Multiple primefaces portlet instances in liferay Aieie Brazorf 19 dicembre 2012 1.34
RE: Multiple primefaces portlet instances in liferay Aieie Brazorf 19 dicembre 2012 2.59
RE: Multiple primefaces portlet instances in liferay Neil Griffin 20 dicembre 2012 11.35
RE: Multiple primefaces portlet instances in liferay Neil Griffin 20 dicembre 2012 11.47
RE: Multiple primefaces portlet instances in liferay Aieie Brazorf 21 dicembre 2012 0.22
RE: Multiple primefaces portlet instances in liferay Aieie Brazorf 21 dicembre 2012 2.49
RE: Multiple primefaces portlet instances in liferay Neil Griffin 21 dicembre 2012 4.47
RE: Multiple primefaces portlet instances in liferay Neil Griffin 21 dicembre 2012 13.04
RE: Multiple primefaces portlet instances in liferay Aieie Brazorf 27 dicembre 2012 0.48
RE: Multiple primefaces portlet instances in liferay Neil Griffin 27 dicembre 2012 3.56
RE: Multiple primefaces portlet instances in liferay Aieie Brazorf 2 gennaio 2013 3.56
RE: Multiple primefaces portlet instances in liferay Neil Griffin 7 gennaio 2013 12.54
RE: Multiple primefaces portlet instances in liferay Aieie Brazorf 8 gennaio 2013 8.06
RE: Multiple primefaces portlet instances in liferay Steven Behne 9 gennaio 2013 6.12
RE: Multiple primefaces portlet instances in liferay Neil Griffin 9 gennaio 2013 8.26
RE: Multiple primefaces portlet instances in liferay Aieie Brazorf 14 gennaio 2013 4.47
RE: Multiple primefaces portlet instances in liferay Neil Griffin 14 gennaio 2013 12.18
RE: Multiple primefaces portlet instances in liferay Neil Griffin 9 gennaio 2013 8.20
RE: Multiple primefaces portlet instances in liferay Neil Griffin 21 dicembre 2012 4.42
Aieie Brazorf
Multiple primefaces portlet instances in liferay
17 dicembre 2012 1.59
Risposta

Aieie Brazorf

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 17 dicembre 2012

Messaggi recenti

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
Neil Griffin
RE: Multiple primefaces portlet instances in liferay
17 dicembre 2012 7.48
Risposta

Neil Griffin

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2179

Data di Iscrizione: 26 luglio 2005

Messaggi recenti

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
Aieie Brazorf
RE: Multiple primefaces portlet instances in liferay
18 dicembre 2012 7.53
Risposta

Aieie Brazorf

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 17 dicembre 2012

Messaggi recenti

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.

 1
 2<div id="[b]A0845[/b]" class="liferay-faces-bridge-body">
 3 <div id="[b]A0845:content[/b]" class="content">
 4  <form id="[b]A0845:form_12345678[/b]" enctype="application/x-www-form-urlencoded"...
 5   <div id="[b]A0845:form_12345678:panel_12345678[/b]" class="container" style="width:100%;text-align:center;">
 6    <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">
 7     <ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" role="tablist">
 8       <li class="ui-state-default ui-tabs-selected ui-state-active ui-corner-top" aria-expanded="true" role="tab">
 9           <a href="#A0845:form_12345678:tabView_12345678:tab1_12345678">1</a>
10       </li>
11       <li class="ui-state-default ui-corner-top" aria-expanded="false" role="tab">
12           <a href="#A0845:form_12345678:tabView_12345678:tab2_12345678">2</a>
13       </li>
14       <li class="ui-state-default ui-corner-top" aria-expanded="false" role="tab">
15           <a href="#A0845:form_12345678:tabView_12345678:tab3_12345678">3</a>
16       </li>
17      </ul>
18
19........


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:

  1
  2<?xml version="1.0" encoding="UTF-8"?>
  3<f:view
  4    xmlns="http://www.w3.org/1999/xhtml"
  5    xmlns:c="http://java.sun.com/jsp/jstl/core"
  6    xmlns:f="http://java.sun.com/jsf/core"
  7    xmlns:h="http://java.sun.com/jsf/html"
  8    xmlns:p="http://primefaces.org/ui"
  9    xmlns:aui="http://liferay.com/faces/aui"
 10    xmlns:bridge="http://liferay.com/faces/bridge"
 11    xmlns:ui="http://java.sun.com/jsf/facelets"
 12    locale="#{sessionInfo.localeCode}" 
 13>
 14    <h:head  >         
 15            <script type="text/javascript">
 16                var modify=false;
 17            </script>
 18            
 19            <script type="text/javascript">
 20                function downloadFile(url) {
 21                    window.open(url);
 22                }
 23            </script>
 24            
 25    </h:head>
 26    
 27    <ui:debug />
 28    <h:body  > 
 29              <p:growl   showDetail="false"  autoUpdate="true" closable="true" severity="info,error,fatal,warn" />
 30    
 31               
 32            <p:outputPanel layout="block" styleClass="content" id="content">
 33                 <h:form id="form_#{entryPoint.key}">
 34                    <ui:fragment  rendered="#{entryPoint.jsonRequest==null}">
 35                                <h:inputHidden value="#{entryPoint.jsonRequest}" id="jsonRequest" style="visibility:hidden;line-height:1px;"   />
 36                         <p:remoteCommand process="jsonRequest" name="jsonRequestUpdateRemote"  update="@form" />
 37                     </ui:fragment>
 38                     
 39                    <input type="hidden" id="sender_#{entryPoint.key}"    style="visibility:hidden;line-height:1px;"/>
 40                     <h:inputHidden value="#{entryPoint.sender}" id="senderRequest_#{entryPoint.key}"  style="visibility:hidden;line-height:1px;"/>
 41                     <input type="hidden" id="key_#{entryPoint.key}"    style="visibility:hidden;line-height:1px;"/>
 42                     <h:inputHidden value="#{entryPoint.key}" id="keyRequest_#{entryPoint.key}"  style="visibility:hidden;line-height:1px;"/>
 43                     <p:remoteCommand process="senderRequest_#{entryPoint.key},keyRequest_#{entryPoint.key}" name="senderRequestUpdateRemote" update="@form" global="true" immediate="true" />
 44                     
 45                     
 46                    <p:outputPanel  styleClass="container"  id="panel_#{entryPoint.key}"  layout="block" style="width:100%;text-align:center;" rendered="#{entryPoint.genericBck.pageRendered}">
 47                        <p:tabView id="tabView_#{entryPoint.key}" widgetVar="tabView_#{entryPoint.key}" dynamic="true" cache="true" >
 48                            <p:tab title="1" id="tab1_#{entryPoint.key}" >
 49                                test 1
 50                                <p:commandButton id="buttonAction_#{entryPoint.key}" action="#{entryPoint.genericBck.action}"  value="action" />
 51                               
 52                            </p:tab>
 53                            <p:tab title="2" id="tab2_#{entryPoint.key}" >
 54                                test 2
 55                               
 56                            </p:tab>
 57                            <p:tab title="3" id="tab3_#{entryPoint.key}" >
 58                                test 3
 59                               
 60                            </p:tab>
 61                        </p:tabView>
 62                           
 63                     </p:outputPanel>
 64                        
 65                     
 66                     
 67               
 68                        <ui:fragment id="jsonScript" rendered="#{entryPoint.jsonRequest==null}">
 69                        <script type="text/javascript">
 70                            //script executed during the loading of the page, i read the json data and store
 71                            var valueJsonSender=#{entryPoint.sender}.params;
 72                            document.getElementById("#{p:component('jsonRequest')}").value=valueJsonSender    ;
 73                            var nameFieldSender="sender_#{entryPoint.key}";
 74                            var nameFieldKey="key_#{entryPoint.key}";
 75                            document.getElementById(nameFieldSender).value="#{entryPoint.sender}";
 76                            document.getElementById(nameFieldKey).value="#{entryPoint.key}";
 77                        
 78                            jsonRequestUpdateRemote();
 79                        </script>
 80                    </ui:fragment>
 81                   
 82                    <script type="text/javascript">
 83                                          //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
 84                        if(!modify){
 85                            modify=true;
 86                              
 87                            MYjQuery('a.MYNavAnchor').click(function(event){
 88                                var valTargetRef=event.currentTarget.href;
 89                                if(valTargetRef.indexOf('/home/')>0  ){
 90
 91                                    var posTargetRef=valTargetRef.indexOf('?sender=')+8;
 92                                    var posEndTargetRef=valTargetRef.indexOf('ts=')-1;
 93                                    var senderTargetRef=valTargetRef.substring(posTargetRef,posEndTargetRef);
 94                                    
 95                                    var posKeyRef=valTargetRef.indexOf('ts=')+3;
 96                                    var keyTargetRef=valTargetRef.substring(posKeyRef);
 97                                    document.getElementById("#{p:component('senderRequest')}").value=senderTargetRef;
 98                                    document.getElementById("#{p:component('keyRequest')}").value=keyTargetRef;
 99                                    senderRequestUpdateRemote();
100                                }
101                            })
102                        }
103                    </script>   
104               
105                </h:form>
106               
107               
108            </p:outputPanel>
109            
110      
111            
112            <ui:insert name="commonStatus">
113                  <p:ajaxStatus id="commandStatus" > 
114                        <f:facet name="start">
115                        <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;">
116                        
117                        </p:outputPanel>
118                        </f:facet> 
119 
120                        <f:facet name="complete"> 
121                            <h:outputText value="" /> 
122                        </f:facet>
123                 </p:ajaxStatus>
124
125            </ui:insert>
126               
127                              
128    </h:body>
129   
130</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):

1
2 public GenericBck getGenericBck(){
3         try{
4             return (GenericBck)JSFUtil.getManagedObject("genericBck"+"_"+key);
5         }catch(Exception e){
6             return null;
7         }
8     }


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
Neil Griffin
RE: Multiple primefaces portlet instances in liferay
21 dicembre 2012 13.01
Risposta

Neil Griffin

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2179

Data di Iscrizione: 26 luglio 2005

Messaggi recenti

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:

 1package com.mycompany.myproject;
 2public class BridgeContextCustomImpl extends BridgeContextWrapper {
 3
 4    private BridgeContext wrappedBridgeContext;
 5
 6    public BridgeContextCustomImpl(BridgeContext bridgeContext) {
 7        this.wrappedBridgeContext = bridgeContext;
 8        BridgeContext.setCurrentInstance(this);
 9    }
10
11    @Override
12    public String getResponseNamespace() {
13        // return value based on custom algorithm.
14    }
15
16    @Override
17    public BridgeContext getWrapped() {
18        return wrappedBridgeContext;
19    }
20}


Then create a wrapper class for the BridgeContextFactory:

 1package com.mycompany.myproject;
 2public class BridgeContextFactoryCustomImpl extends BridgeContextFactory {
 3
 4    private BridgeContextFactory wrappedBridgeContextFactory;
 5
 6    public BridgeContextFactoryCustomImpl(BridgeContextFactory bridgeContextFactory) {
 7        this.wrappedBridgeContextFactory =  bridgeContextFactory;
 8    }
 9
10    public BridgeContextFactory getWrapped() {
11        return wrappedBridgeContextFactory;
12    }
13
14    @Override
15    public BridgeContext getBridgeContext(BridgeConfig bridgeConfig, BridgeRequestScope bridgeRequestScope,
16        PortletConfig portletConfig, PortletContext portletContext, PortletRequest portletRequest,
17        PortletResponse portletResponse, Bridge.PortletPhase portletPhase, PortletContainer portletContainer,
18        IncongruityContext incongruityContext) {
19
20        BridgeContext wrappedBridgeContext = wrappedBridgeContextFactory.getBridgeContext(bridgeConfig, bridgeRequestScope, portletConfig,
21            portletContext, portletRequest, portletResponse, portletPhase, portletContainer, incongruityContext);
22
23        BridgeContext bridgeContext = new BridgeContextCustomImpl(wrappedBridgeContext);
24
25        return bridgeContext;
26    }
27}


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

 1<faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:bridge="http://www.liferay.com/xml/ns/liferay-faces-bridge-2.0-extension"
 2    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
 3    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">
 4    <factory>
 5        <factory-extension>
 6            <bridge:bridge-context-factory>com.mycompany.myproject.BridgeContextFactoryCustomImpl</bridge:bridge-context-factory>
 7        </factory-extension>
 8    </factory>
 9</faces-config>


After you rebuild and re-deploy your portlet WAR, the settings should take effect.
Aieie Brazorf
RE: Multiple primefaces portlet instances in liferay
19 dicembre 2012 1.34
Risposta

Aieie Brazorf

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 17 dicembre 2012

Messaggi recenti

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:

1
2@Override
3    public String getResponseNamespace() {
4        String id="BridgePanel_"+String.valueOf(System.currentTimeMillis());
5        return id;
6    }


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
Aieie Brazorf
RE: Multiple primefaces portlet instances in liferay
19 dicembre 2012 2.59
Risposta

Aieie Brazorf

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 17 dicembre 2012

Messaggi recenti

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
Neil Griffin
RE: Multiple primefaces portlet instances in liferay
20 dicembre 2012 11.35
Risposta

Neil Griffin

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2179

Data di Iscrizione: 26 luglio 2005

Messaggi recenti

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"?
Neil Griffin
RE: Multiple primefaces portlet instances in liferay
20 dicembre 2012 11.47
Risposta

Neil Griffin

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2179

Data di Iscrizione: 26 luglio 2005

Messaggi recenti

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.
Aieie Brazorf
RE: Multiple primefaces portlet instances in liferay
21 dicembre 2012 0.22
Risposta

Aieie Brazorf

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 17 dicembre 2012

Messaggi recenti

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.
Aieie Brazorf
RE: Multiple primefaces portlet instances in liferay
21 dicembre 2012 2.49
Risposta

Aieie Brazorf

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 17 dicembre 2012

Messaggi recenti

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.
Neil Griffin
RE: Multiple primefaces portlet instances in liferay
21 dicembre 2012 4.42
Risposta

Neil Griffin

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2179

Data di Iscrizione: 26 luglio 2005

Messaggi recenti

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).
Neil Griffin
RE: Multiple primefaces portlet instances in liferay
21 dicembre 2012 4.47
Risposta

Neil Griffin

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2179

Data di Iscrizione: 26 luglio 2005

Messaggi recenti

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.
Neil Griffin
RE: Multiple primefaces portlet instances in liferay
21 dicembre 2012 13.04
Risposta

Neil Griffin

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2179

Data di Iscrizione: 26 luglio 2005

Messaggi recenti

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:

1    public BridgeContextCustomImpl(BridgeContext bridgeContext) {
2        this.wrappedBridgeContext = bridgeContext;
3        [b]BridgeContext.setCurrentInstance(this);[/b]
4    }
Aieie Brazorf
RE: Multiple primefaces portlet instances in liferay
27 dicembre 2012 0.48
Risposta

Aieie Brazorf

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 17 dicembre 2012

Messaggi recenti

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!
Neil Griffin
RE: Multiple primefaces portlet instances in liferay
27 dicembre 2012 3.56
Risposta

Neil Griffin

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2179

Data di Iscrizione: 26 luglio 2005

Messaggi recenti

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
Aieie Brazorf
RE: Multiple primefaces portlet instances in liferay
2 gennaio 2013 3.56
Risposta

Aieie Brazorf

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 17 dicembre 2012

Messaggi recenti

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.
Neil Griffin
RE: Multiple primefaces portlet instances in liferay
7 gennaio 2013 12.54
Risposta

Neil Griffin

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2179

Data di Iscrizione: 26 luglio 2005

Messaggi recenti

Hi Aieie,

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

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


Best Regards,

Neil
Aieie Brazorf
RE: Multiple primefaces portlet instances in liferay
8 gennaio 2013 8.06
Risposta

Aieie Brazorf

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 17 dicembre 2012

Messaggi recenti

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
Steven Behne
RE: Multiple primefaces portlet instances in liferay
9 gennaio 2013 6.12
Risposta

Steven Behne

Punteggio: New Member

Messaggi: 4

Data di Iscrizione: 17 ottobre 2012

Messaggi recenti

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
Neil Griffin
RE: Multiple primefaces portlet instances in liferay
9 gennaio 2013 8.20
Risposta

Neil Griffin

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2179

Data di Iscrizione: 26 luglio 2005

Messaggi recenti

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:

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


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

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


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

1import com.liferay.portal.util.PortalUtil;
2...
3FacesContext facesContext = FacesContext.getCurrentInstance();
4ExternalContext externalContext = facesContext.getExternalContext();
5PortletRequest portletRequest = (PortletRequest) externalContext.getRequest();
6String url = PortalUtil.getPortalURL(portletRequest);
Neil Griffin
RE: Multiple primefaces portlet instances in liferay
9 gennaio 2013 8.26
Risposta

Neil Griffin

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2179

Data di Iscrizione: 26 luglio 2005

Messaggi recenti

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:
1LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
2ThemeDisplay themeDisplay = liferayFacesContext.getThemeDisplay();
3PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();


Otherwise, you can do something like this:

1FacesContext facesContext = FacesContext.getCurrentInstance();
2ExternalContext externalContext = facesContext.getExternalContext();
3ThemeDisplay themeDisplay = (ThemeDisplay) externalContext.getRequestMap().get(WebKeys.THEME_DISPLAY);
4PortletDisplay 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.
Aieie Brazorf
RE: Multiple primefaces portlet instances in liferay
14 gennaio 2013 4.47
Risposta

Aieie Brazorf

Punteggio: New Member

Messaggi: 12

Data di Iscrizione: 17 dicembre 2012

Messaggi recenti

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.
Neil Griffin
RE: Multiple primefaces portlet instances in liferay
14 gennaio 2013 12.18
Risposta

Neil Griffin

LIFERAY STAFF

Punteggio: Liferay Legend

Messaggi: 2179

Data di Iscrizione: 26 luglio 2005

Messaggi recenti

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 [url=http://javaserverfaces.java.net/nonav/docs/2.0/javadocs/javax/faces/component/UIViewRoot.html#getViewMap()]ViewScope attribute.

Neil