You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Umesh Kanitkar <fu...@hotmail.com> on 2006/02/14 05:41:12 UTC

afterPhase method in the PhaseListener gets called before rendering is complete

Hi,

I notice that afterPhase method in the PhaseListener included in this email 
is exceuted before the Rendering is completed. During rendering the JSF view 
acceces the model which in turn accecces the database. In order to access 
the database a new DB session is created, thus defeating the purpose of 
having a DBUtil.closeSession() in the afterPhase method.

Is this correct behaviour? Is it likely that something is wrong with my 
configuration?


-Umesh
(Code attached below)

-----------------------------------x-------------------------

package com.ebay.channel.phaselisteners;

import javax.faces.event.PhaseEvent;
import javax.faces.event.PhaseId;
import javax.faces.event.PhaseListener;

import com.ebay.db.DbUtil;

public class SessionClosePhaseListener implements PhaseListener {

	public void beforePhase(PhaseEvent event) {

	}

	public void afterPhase(PhaseEvent event) {

		DbUtil.closeSession();
	}

	public PhaseId getPhaseId() {

		return PhaseId.RENDER_RESPONSE;
	}

}



RE: afterPhase method in the PhaseListener gets called before rendering is complete

Posted by Umesh Kanitkar <fu...@hotmail.com>.
Clarification: There is a dataTable component in the JSF page. The 
getRowCount() method goes to the database to get the latest count of rows.

The snippet from JSF page is:

...
<h:dataTable id="channelData" value="#{findChannelBean.channelModel}" 
var="rowVar" first="0" rows="10" border="0" 
headerClass="findChannel_headerClass" columnClasses="findChannel_name, 
findChannel_description" width="600px" 
rendered="#{findChannelBean.showChannelDataTable}">
...

When my JSF page does not contain a dataTable session opening and closing 
work as expected.
Let me know if you need more info.

- Umesh

>From: "Umesh Kanitkar" <fu...@hotmail.com>
>Reply-To: "MyFaces Discussion" <us...@myfaces.apache.org>
>To: users@myfaces.apache.org
>Subject: afterPhase method in the PhaseListener gets called before 
>rendering is complete
>Date: Tue, 14 Feb 2006 04:41:12 +0000
>
>Hi,
>
>I notice that afterPhase method in the PhaseListener included in this email 
>is exceuted before the Rendering is completed. During rendering the JSF 
>view acceces the model which in turn accecces the database. In order to 
>access the database a new DB session is created, thus defeating the purpose 
>of having a DBUtil.closeSession() in the afterPhase method.
>
>Is this correct behaviour? Is it likely that something is wrong with my 
>configuration?
>
>
>-Umesh
>(Code attached below)
>
>-----------------------------------x-------------------------
>
>package com.ebay.channel.phaselisteners;
>
>import javax.faces.event.PhaseEvent;
>import javax.faces.event.PhaseId;
>import javax.faces.event.PhaseListener;
>
>import com.ebay.db.DbUtil;
>
>public class SessionClosePhaseListener implements PhaseListener {
>
>	public void beforePhase(PhaseEvent event) {
>
>	}
>
>	public void afterPhase(PhaseEvent event) {
>
>		DbUtil.closeSession();
>	}
>
>	public PhaseId getPhaseId() {
>
>		return PhaseId.RENDER_RESPONSE;
>	}
>
>}
>
>