Reply To: Problem with conversation scope using Prettyfaces and Apache Myfaces CODI

Splash Forums PrettyFaces Users Problem with conversation scope using Prettyfaces and Apache Myfaces CODI Reply To: Problem with conversation scope using Prettyfaces and Apache Myfaces CODI

#24603

sunnymoon
Participant

Meanwhile I think I’ve been able to workaround the problem with the following code

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

import org.apache.myfaces.extensions.cdi.core.api.Advanced;
import org.apache.myfaces.extensions.cdi.core.api.scope.conversation.WindowContext;
import org.apache.myfaces.extensions.cdi.jsf.api.listener.phase.JsfPhaseListener;
import org.apache.myfaces.extensions.cdi.jsf.impl.util.ConversationUtils;

import com.ocpsoft.pretty.PrettyContext;

@JsfPhaseListener
@Advanced
public class PrettyFacesToCODIViewAccessScopedAwarePhaseListener implements PhaseListener {

	/**
	 * 
	 */
	private static final long serialVersionUID = 121463399007913590L;

	@Override
	public void afterPhase(PhaseEvent event) {
		
	}

	@Override
	public void beforePhase(PhaseEvent event) {
		if(PrettyContext.getCurrentInstance()!=null && PrettyContext.getCurrentInstance().getCurrentViewId()!=null) {
			WindowContext windowContext = ConversationUtils.getWindowContextManager().getCurrentWindowContext();
			ConversationUtils.storeViewIdAsNewViewId(windowContext, PrettyContext.getCurrentInstance().getCurrentViewId());
		}
	}

	@Override
	public PhaseId getPhaseId() {
		return PhaseId.RESTORE_VIEW;
	}
	}

Regarding the other optimization I suggested I’m pretty sure that the PrettyPhaseListener class I’ve been debugging has an if checking for the Restore View phase only…