看源代码:
responseComplete:
- /**
- * <p>Signal the JavaServer Faces implementation that the HTTP response
- * for this request has already been generated (such as an HTTP redirect),
- * and that the request processing lifecycle should be terminated as soon
- * as the current phase is completed.</p>
- *
- * @throws IllegalStateException if this method is called after
- * this instance has been released
- */
- public abstract void responseComplete();
renderResponse:
- /**
- * <p>Signal the JavaServer faces implementation that, as soon as the
- * current phase of the request processing lifecycle has been completed,
- * control should be passed to the <em>Render Response</em> phase,
- * bypassing any phases that have not been executed yet.</p>
- *
- * @throws IllegalStateException if this method is called after
- * this instance has been released
- */
- public abstract void renderResponse();
responseComplete和renderResponse的关系有点象break和continue的关系,responseComplete指示当前的response已经产生,JSF应该在当前阶段执行完成后立刻整个生命周期,break的概念。renderResponse则是指示当前阶段执行结束后直接跳到Render Response阶段,继续生命周期,因此是continue的概念。
下面是LifeCycle的execute和render方法,更加证实了这些:
com.sun.faces.lifecycle.LifecycleImpl
- // Execute the phases up to but not including Render Response
- public void execute(FacesContext context) throws FacesException {
- if (context == null) {
- throw new NullPointerException
- (MessageUtils.getExceptionMessageString
- (MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, "context"));
- }
- if (LOGGER.isLoggable(Level.FINE)) {
- LOGGER.fine("execute(" + context + ")");
- }
- for (int i = 1, len = phases.length -1 ; i < len; i++) { // Skip ANY_PHASE placeholder
- if (context.getRenderResponse() ||
- context.getResponseComplete()) {
- break;
- }
- phases[i].doPhase(context, this, listeners.listIterator());
- }
- }
- // Execute the Render Response phase
- public void render(FacesContext context) throws FacesException {
- if (context == null) {
- throw new NullPointerException
- (MessageUtils.getExceptionMessageString
- (MessageUtils.NULL_PARAMETERS_ERROR_MESSAGE_ID, "context"));
- }
- if (LOGGER.isLoggable(Level.FINE)) {
- LOGGER.fine("render(" + context + ")");
- }
- if (!context.getResponseComplete()) {
- response.doPhase(context, this, listeners.listIterator());
- }
- }