use of javax.faces.event.PhaseId in project liferay-faces-bridge-impl by liferay.
the class IPCPhaseListener method afterPhase.
@Override
public void afterPhase(PhaseEvent phaseEvent) {
FacesContext facesContext = phaseEvent.getFacesContext();
PhaseId phaseId = phaseEvent.getPhaseId();
if (phaseId == PhaseId.RESTORE_VIEW) {
// Sections 5.2.4, 5.2.5, 5.2.6, and 5.2.7 require that there be a phase listener registered that processes
// incoming Public Render Parameters. This is to happen for all phases of the Portlet 2.0 lifecycle. The
// phase listener is to execute after the RESTORE_VIEW phase of the JSF lifecycle completes, in accordance
// with Section 5.3.2.
processIncomingPublicRenderParameters(facesContext);
// Section 5.2.5 and 6.4 of the JSR 329 Spec require that the phase listener short-circuit the JSF lifecycle
// after the RESTORE_VIEW phase completes during the EVENT_PHASE of the Portlet 2.0 lifecycle.
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if (portletPhase == Bridge.PortletPhase.EVENT_PHASE) {
facesContext.renderResponse();
}
} else if (phaseId == PhaseId.INVOKE_APPLICATION) {
// Sections 5.2.4 and 5.3.3 require that there be a phase listener registered that processes outgoing Public
// Render Parameters during the ACTION_PHASE and RENDER_PHASE of the Portlet 2.0 lifecycle. It is
// appropriate to do this after the INVOKE_APPLICATION phase of the JSF lifecycle because that's where a JSF
// backing bean action (or action listener) would have been called in order to populate the model.
Bridge.PortletPhase portletPhase = BridgeUtil.getPortletRequestPhase(facesContext);
if ((portletPhase == Bridge.PortletPhase.ACTION_PHASE) || (portletPhase == Bridge.PortletPhase.EVENT_PHASE)) {
processOutgoingPublicRenderParameters(facesContext);
}
}
}
use of javax.faces.event.PhaseId in project liferay-faces-bridge-impl by liferay.
the class Tests method beforePhase.
@Override
public void beforePhase(PhaseEvent phaseEvent) {
FacesContext facesContext = phaseEvent.getFacesContext();
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
String testname = (String) requestMap.get(Constants.TEST_NAME);
PhaseId phase = phaseEvent.getPhaseId();
if ((!testname.equals("processPRPInRestoreViewPhaseTest")) || (!Boolean.TRUE.equals((Boolean) externalContext.getSessionMap().get("tck.processPRPInRestoreViewPhaseTest.modelPRPSet"))))
return;
// Marked as true so command link name would change.
externalContext.getSessionMap().put("com.liferay.faces.bridge.tck.testCompleted", Boolean.TRUE);
// verify not set in RestoreView
if (phase == PhaseId.RESTORE_VIEW) {
if (requestMap.get("modelPRP") == null) {
externalContext.getRequestMap().put("tck.notSetBeforeRestoreView", Boolean.TRUE);
}
} else {
if (requestMap.get("modelPRP") != null) {
externalContext.getRequestMap().put("tck.setAfterRestoreView", Boolean.TRUE);
}
}
}
use of javax.faces.event.PhaseId in project liferay-faces-bridge-impl by liferay.
the class Tests method eventPhaseListenerTest.
// Test is SingleRequest -- Render/Action
// Test #5.33 --
@BridgeTest(test = "eventPhaseListenerTest")
public String eventPhaseListenerTest(TestBean testBean) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ExternalContext externalContext = facesContext.getExternalContext();
Map<String, Object> requestMap = externalContext.getRequestMap();
if (BridgeUtil.getPortletRequestPhase(facesContext) == Bridge.PortletPhase.ACTION_PHASE) {
StateAwareResponse stateAwareResponse = (StateAwareResponse) externalContext.getResponse();
stateAwareResponse.setEvent(new QName(Constants.EVENT_QNAME, Constants.EVENT_NAME), testBean.getTestName());
// action Navigation result
return "eventPhaseListenerTest";
} else {
testBean.setTestComplete(true);
// Phase Listener (below) has set these attributes
PhaseId lastBeforePhaseId = (PhaseId) requestMap.get("org.apache.portlet.faces.tck.lastBeforePhase");
PhaseId lastAfterPhaseId = (PhaseId) requestMap.get("org.apache.portlet.faces.tck.lastAfterPhase");
if ((lastBeforePhaseId == null) || (lastAfterPhaseId == null)) {
testBean.setTestResult(false, "Event incorrectly didn't invoke either or both the RESTORE_VIEW before/after listener. Its also possible the event wasn't received.");
return Constants.TEST_FAILED;
} else if ((lastBeforePhaseId == PhaseId.RESTORE_VIEW) && (lastAfterPhaseId == PhaseId.RESTORE_VIEW)) {
testBean.setTestResult(true, "Event properly invoked the RESTORE_VIEW phase including calling its before/after listeners and didnt' execute any other action phases.");
return Constants.TEST_SUCCESS;
} else {
testBean.setTestResult(false, "Event incorrectly executed an action phase/listener post RESTORE_VIEW: lastBeforePhase: " + lastBeforePhaseId.toString() + " lastAfterPhase: " + lastAfterPhaseId.toString());
return Constants.TEST_FAILED;
}
}
}
use of javax.faces.event.PhaseId in project liferay-faces-bridge-impl by liferay.
the class Tests method afterPhase.
@Override
public void afterPhase(PhaseEvent phaseEvent) {
PhaseId phase = phaseEvent.getPhaseId();
// Do nothing if in render phase
if (phase == PhaseId.RENDER_RESPONSE) {
return;
}
FacesContext facesContext = phaseEvent.getFacesContext();
Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
String testname = (String) requestMap.get(Constants.TEST_NAME);
Bridge.PortletPhase portletPhase = (Bridge.PortletPhase) requestMap.get(Bridge.PORTLET_LIFECYCLE_PHASE);
if (testname.equals("headerPhaseListenerTest") && (Bridge.PortletPhase.HEADER_PHASE.equals(portletPhase))) {
requestMap.put("org.apache.portlet.faces.tck.lastAfterPhase", phase);
} else if (testname.equals("eventPhaseListenerTest") && (portletPhase.equals(Bridge.PortletPhase.EVENT_PHASE))) {
requestMap.put("org.apache.portlet.faces.tck.lastAfterPhase", phase);
}
if ((Bridge.PortletPhase.HEADER_PHASE.equals(portletPhase) && (testname.equals("facesContextReleasedRenderTest") || testname.equals("portletPhaseRemovedRenderTest"))) || (portletPhase.equals(Bridge.PortletPhase.RESOURCE_PHASE) && (testname.equals("facesContextReleasedResourceTest") || testname.equals("portletPhaseRemovedResourceTest")))) {
// prematurely prevent render from happening as the Portlet needs to write to the response once it verifies
// that the corresponding elements were cleaned up
facesContext.responseComplete();
}
}
use of javax.faces.event.PhaseId in project org.openntf.domino by OpenNTF.
the class PhaseListener method afterPhase.
/*
* (non-Javadoc)
*
* @see javax.faces.event.PhaseListener#afterPhase(javax.faces.event.PhaseEvent)
*/
@Override
public void afterPhase(final PhaseEvent arg0) {
PhaseId curId = arg0.getPhaseId();
if (PhaseId.APPLY_REQUEST_VALUES.equals(curId)) {
doAfterApplyRequest(arg0);
} else if (PhaseId.INVOKE_APPLICATION.equals(curId)) {
doAfterInvokeApplication(arg0);
} else if (PhaseId.PROCESS_VALIDATIONS.equals(curId)) {
doAfterProcessValidations(arg0);
} else if (PhaseId.RENDER_RESPONSE.equals(curId)) {
doAfterRenderResponse(arg0);
} else if (PhaseId.RESTORE_VIEW.equals(curId)) {
doAfterRestoreView(arg0);
} else if (PhaseId.UPDATE_MODEL_VALUES.equals(curId)) {
doAfterUpdateModel(arg0);
}
doAfterEveryPhase(arg0);
}
Aggregations