/**
 * 
 */
package org.ajax4jsf.portlet.lifecycle;

import javax.faces.context.FacesContext;
import javax.faces.event.PhaseId;
import javax.faces.lifecycle.Lifecycle;

/**
 * @author asmirnov
 *
 */
public class UpdateModelPhase extends LifecyclePhase {

	private final LifecyclePhase nextPhase;
	/**
	 * @param lifecycle
	 */
	public UpdateModelPhase(Lifecycle lifecycle) {
		super(lifecycle);
		nextPhase = new InvokeApplicationPhase(lifecycle);
	}

	/* (non-Javadoc)
	 * @see org.ajax4jsf.portlet.lifecycle.LifecyclePhase#executeNextPhase(javax.faces.context.FacesContext, javax.faces.event.PhaseListener[])
	 */
	protected void executeNextPhase(FacesContext context) {
		nextPhase.execute(context);

	}

	/* (non-Javadoc)
	 * @see org.ajax4jsf.portlet.lifecycle.LifecyclePhase#executePhase(javax.faces.context.FacesContext)
	 */
	public void executePhase(FacesContext context) {
		context.getViewRoot().processUpdates(context);
	}

	/* (non-Javadoc)
	 * @see org.ajax4jsf.portlet.lifecycle.LifecyclePhase#getPhaseId()
	 */
	protected PhaseId getPhaseId() {
		return PhaseId.UPDATE_MODEL_VALUES;
	}

}
