I have a portlet deployed in Liferay. My environment is:
Liferay Portal 5.2.3
JSF 1.2 - Mojarra
JBoss Portlet Bridge - portletbridge-api-1.0.0.jar, portletbridge-impl-1.0.0.jar
Primefaces 1.1
In my .xhtml I used two types of commandLink
h:commandLink and p:commandLink
h:commandLink calls an action where I have put my business logic. In this action when I get FacesContext.getCurrentInstance(), i can see that is instance of org.jboss.portletbridge.context.FacesContextImpl
p:commandLink calls an actionListener where I have put other business logic. In this case when I get FacesContext.getCurrentInstance() i can see that is instance of com.sun.faces.context.FacesContextImpl .
It seems that I lose portlet context with ajax partial submit (p:commandLInk). Is this the correct behavior or I miss some configuration?
My target is to retrieve also in the actionlistener che FacesContext instance provided by portletBridge.
Can anyone help me?
Thanks
the following snippet shows my code
Code: Select all
ui.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.prime.com.tr/ui"
>
...
<h:commandLink id="tab_gest_prenotazioni" action="#{scheduleController.redirectGestionePrenotazioniAction}">
<h:outputText value="Gestione prenotazioni" />
</h:commandLink>
...
formgestioneprenotazione.xhtml
...
<p:schedule id="item" value="#{scheduleController.prenotazioniCmd}"
locale="it"
editable="#{scheduleController.prenotazioniCmd.selectedNode eq 'salaRiunione'}"
widgetVar="myschedule" view="agendaWeek" draggable="false"
showWeekends="false"
eventSelectListener="#{scheduleController.onEventSelect}"
dateSelectListener="#{scheduleController.onDateSelect}"
eventMoveListener="#{scheduleController.onEventMove}"
eventResizeListener="#{scheduleController.onEventResize}"
onEventResizeUpdate="item, growl_messages" firstHour="9" minTime="9"
maxTime="23" slotMinutes="60" allDaySlot="false">
<p:scheduleEventDialog header="Prenotazione Riunione" id="dialogo"
widgetVar="eventDialog">
...
<p:commandButton value="Conferma prenotazione" actionListener="#{scheduleController.salvaPrenotazione}"
update="msgs, msg_title, msg_from, msg_to, msg_emailRichiedente, msg_nomeRichiedente, msg_txt_email, msg_txt_name, msg_emailTecnico, msg_nomeTecnico, pulsanti_panel" id="confermaPrenotazioneId" widgetVar="confermaPrenotazioneJs" rendered="#scheduleController.prenotazioniCmd.event.stato eq 'provvisorio'}" />
...
</p:scheduleEventDialog>
</p:schedule>
ScheduleController.java
public String redirectGestionePrenotazioniAction() {
// Get render request object that contains needed info
getThemeDisplay();
...
}
public void salvaPrenotazione(ActionEvent actionEvent) {
// Get render request object that contains needed info
getThemeDisplay();
...
}
private void getThemeDisplay(){
FacesContext facesContext = FacesContext.getCurrentInstance();
Map requestMap = facesContext.getExternalContext().getRequestMap();
System.out.println("requestMap.getClass: " + requestMap.getClass());
ThemeDisplay themeDisplay = (ThemeDisplay)requestMap.get(
WebKeys.THEME_DISPLAY);
System.out.println("themeDisplay: " + themeDisplay);
System.out.println("screenname: " + themeDisplay.getUser().getScreenName());
}
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>PrenotazioneSaleRiunioniJSF1.2</display-name>
<context-param>
<param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.portlet.faces.renderPolicy</param-name>
<param-value>ALWAYS_DELEGATE</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.validateXml</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>facelets.REFRESH_PERIOD</param-name>
<param-value>0</param-value>
</context-param>
<context-param>
<param-name>facelets.DEVELOPMENT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.xhtml</param-value>
</context-param>
<context-param>
<param-name>primefaces.skin</param-name>
<param-value>none</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring-beans.xml,classpath:hibernate-dao-spring-context.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>org.primefaces.resource.ResourceServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/primefaces_resource/*</url-pattern>
</servlet-mapping>
</web-app>