Hi!
I'm a starter with PortleFaces.
I have 2 questions. Because code is common to both questions I've posted it in one thread.
I created my first JSF portlet for Liferay with PortletFaces.
I've created request scoped managed bean
here's my faces-config.xml fragment
1
2 <application>
3 <view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler>
4 </application>
5 <lifecycle>
6 <phase-listener>org.edorasframework.extfaces.lifecycle.DebugPhaseListener</phase-listener>
7 </lifecycle>
8 <managed-bean>
9 <managed-bean-name>SearchBean</managed-bean-name>
10 <managed-bean-class>dumbuzz.SearchBean</managed-bean-class>
11 <managed-bean-scope>request</managed-bean-scope>
12 </managed-bean>
Here's my bean's code:
1
2public class SearchBean {
3
4 private String searchString;;
5 private final PortletFacesContext portletFacesContext = PortletFacesContext.getInstance();
6
7 public SearchBean {
8 searchString = "test string";
9 portletFacesContext.addGlobalInfoMessage("test message");
10 }
11
12 public String getSearchString() {
13 return this.searchString;
14 }
15}
Also I created faceletbased-portlet view with view.xhtml.
Related fragment of view::
1
2<ui:composition xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets">
3 <h:outputText value="#{liferay.user.screenName}"/><br/>
4 <h:outputText value="#{SearchBean.searchString}"/>
5 <h:messages id="messages" globalOnly="true"/>
6</ui:composition>
I deployed portlet to Liferay, create new page "JSF" and put my portlet on this portal page - /web/guets/jsf.
It became a single portlet on this page.
1) So here's my first problem:
1
2When I try to render this portlet in Liferay I see this debug messages in my Tomcat log:
324.12.2009 12:27:24 org.edorasframework.extfaces.el.ExtELResolver.resolveVariable
4DEBUG: Unable to resolve variable [liferay] value=null
524.12.2009 12:27:24 org.edorasframework.portletfaces.el.PortletELResolver.resolveVariable
6DEBUG: Unable to resolve variable [liferay] value=null
724.12.2009 12:27:24 org.edorasframework.extfaces.lifecycle.DebugPhaseListener.beforePhase
8DEBUG: Before phase: RENDER_RESPONSE 6
924.12.2009 12:27:24 org.edorasframework.extfaces.el.ExtELResolver.resolveVariable
10DEBUG: Unable to resolve variable [SearchBean] value=null
1124.12.2009 12:27:24 org.edorasframework.portletfaces.el.PortletELResolver.resolveVariable
12DEBUG: Unable to resolve variable [SearchBean] value=null
1324.12.2009 12:27:24 org.edorasframework.extfaces.lifecycle.DebugPhaseListener.afterPhase
14DEBUG: After phase: RENDER_RESPONSE 6
Though I see values of my outputText fields rendered correctly. I see correct searchString value - "test string" and correct liferay-user screenName.
That means, that variables resolved correctly, but why these messages appear?
my web.xml fragement related to el
1
2<context-param>
3 <param-name>com.sun.faces.expressionFactory</param-name>
4 <param-value>org.jboss.el.ExpressionFactoryImpl</param-value>
5</context-param>
2) My second problem:
In my SearchBean I simply add FacesMessage with severity INFO in constructor as you see higher in SearchBean constructor code:
When I start new browser session and surf to /web/guest/jsf portal page I see my info message. It's ok.
But when I refresh my browser or simply go away from portlet page with this portlet and return back to this page I see my message incrementing
(for example, after 3 refreshes of a page I see 3 messages "test message").
In debugger I see, that FacesMessages don't erase from FacesContext and each time my bean constructor is executed new message is adding to FacesContext messages list.
Why? I thought, that FacesContext messages live in request, but why they don't erase between requests