communication between portlets over applicationScope
fuchs Sep 16, 2009 10:15 AMExcuse me, but I am a new Jboss Portal user.
jboss portal bundle 2.7.2
richfaces 3.3.1.GA
jsf-facelets 1.1.14
portletbridge 1.0.0.CR2
Now, I am trying to use the applicationScope.
Here is the code, which I am using from an example. It should use the applicationScope:
... private String chatMessage; public void setText(String text) { this.text=text; String username = "unknown user"; //String log = getText() != null ? getText() : ""; text = /*log +*/ "<b>" + username + ": </b> " + text + "<hr/>"; if (getRenderRequest() != null){ TextHolderIF hwif = (TextHolderIF)getRenderRequest().getAttribute ("javax.portlet.p./Kundenportal/Startseite /SmallChartPortletWindow?textHolder"); hwif.setText(text); } textHolder.setText(text); } public String getChatMessage() { return chatMessage; } public void setChatMessage(String chatMessage) { this.chatMessage = chatMessage; } public void sendMessage(ActionEvent actionEvent) { setText(chatMessage); this.chatMessage = ""; } private HttpSession getRenderRequest() { HttpServletRequestWrapper responseObject = (HttpServletRequestWrapper)FacesContext.getCurrentInstance(). getExternalContext().getRequest(); if (responseObject instanceof HttpServletRequestWrapper) { return responseObject.getSession(false); } return null; }
With the @PortletScope(PortletScope.ScopeType.APPLICATION_SCOPE) command, the portlets have the same applicationScope.
But the textHolder object is missing.
I am getting these Error Message from the Console:
14:40:17,295 ERROR [STDERR] 16.09.2009 14:40:17 javax.faces.event.MethodExpressionActionListener pro cessAction SCHWERWIEGEND: Received 'java.lang.ClassCastException' when invoking action listener '#{SmallChartBe an.sendMessage}' for component 'j_id32' 14:40:17,304 ERROR [STDERR] 16.09.2009 14:40:17 javax.faces.event.MethodExpressionActionListener pro cessAction SCHWERWIEGEND: java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot be c ast to javax.servlet.http.Http ServletRequestWrapper ... 14:40:17,418 ERROR [AjaxViewRoot] Error processing faces event for the component _jbpns_2fKundenport al_2fStartseite_2fSmallChartPo rtletWindowsnpbj:_viewRoot:j_id29:j_id32 javax.faces.event.AbortProcessingException: /SmallChart.xhtml @83,112 actionListener="#{SmallChartBean.sendMessage}": java.lang.Cl assCastException: org.apache.catalina.connector.RequestFacade cannot be cast to javax.servlet.http.H ttpServletRequestWrapper ... Caused by: java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot be cast to javax.servlet.http.HttpServ letRequestWrapper ... 14:40:17,583 ERROR [AjaxViewRoot] Error processing faces event for the component _jbpns_2fKundenport al_2fStartseite_2fSmallChartPo rtletWindowsnpbj:_viewRoot:j_id29:j_id32 javax.faces.event.AbortProcessingException: /SmallChart.xhtml @83,112 actionListener="#{SmallChartBean.sendMessage}": java.lang.Cl assCastException: org.apache.catalina.connector.RequestFacade cannot be cast to javax.servlet.http.H ttpServletRequestWrapper ... Caused by: java.lang.ClassCastException: org.apache.catalina.connector.RequestFacade cannot be cast to javax.servlet.http.HttpServ letRequestWrapper ... 14:55:11,540 ERROR [lifecycle] JSF1054: (Phase ID: RESTORE_VIEW 1, View ID: ) Exception thrown durin g phase execution: javax.faces .event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1777d1a] 14:55:11,553 ERROR [BaseXMLFilter] Exception in the filter chain javax.servlet.ServletException: viewId:/SmallChart.xhtml - View /SmallChart.xhtml could not be resto red. ... Caused by: javax.faces.application.ViewExpiredException: viewId:/SmallChart.xhtml - View /SmallChart .xhtml could not be restored. ... 14:55:11,665 ERROR [BaseXMLFilter] Exception in the filter chain javax.servlet.ServletException: viewId:/SmallChart.xhtml - View /SmallChart.xhtml could not be resto red. ... Caused by: javax.faces.application.ViewExpiredException: viewId:/SmallChart.xhtml - View /SmallChart .xhtml could not be restored. ... 14:55:11,736 ERROR [[FacesServlet]] Servlet.service() for servlet FacesServlet threw exception javax.faces.application.ViewExpiredException: viewId:/SmallChart.xhtml - View /SmallChart.xhtml coul d not be restored. ...
I am not sure what this means?
If I look at Code, it have to be a problem with the getRequest()-Methode.
Has someone an idea?