org.jboss.jsfunit.context
Class JSFUnitFacesContext

java.lang.Object
  extended by javax.faces.context.FacesContext
      extended by org.jboss.jsfunit.context.JSFUnitFacesContext
All Implemented Interfaces:
Serializable, EventListener, javax.servlet.http.HttpSessionBindingListener

public class JSFUnitFacesContext
extends javax.faces.context.FacesContext
implements javax.servlet.http.HttpSessionBindingListener, Serializable

This class is a wrapper for the "real" FacesContext.

Since:
1.0
Author:
Stan Silvert
See Also:
Serialized Form

Field Summary
static String SESSION_KEY
           
 
Constructor Summary
JSFUnitFacesContext(javax.faces.context.FacesContext delegate)
           
 
Method Summary
 void addMessage(String clientId, javax.faces.application.FacesMessage facesMessage)
           
static void cleanUpOldFacesContext()
          This static method will attempt to clean up any FacesContext that is associated with the current thread.
 javax.faces.application.Application getApplication()
           
 Map<Object,Object> getAttributes()
           
 Iterator getClientIdsWithMessages()
           
 javax.faces.event.PhaseId getCurrentPhaseId()
           
 javax.el.ELContext getELContext()
           
 javax.faces.context.ExceptionHandler getExceptionHandler()
           
 javax.faces.context.ExternalContext getExternalContext()
           
 javax.faces.application.FacesMessage.Severity getMaximumSeverity()
           
 List<javax.faces.application.FacesMessage> getMessageList()
           
 List<javax.faces.application.FacesMessage> getMessageList(String clientId)
           
 Iterator getMessages()
           
 Iterator getMessages(String clientId)
           
 javax.faces.context.PartialViewContext getPartialViewContext()
           
 javax.faces.render.RenderKit getRenderKit()
           
 boolean getRenderResponse()
           
 boolean getResponseComplete()
           
 javax.faces.context.ResponseStream getResponseStream()
           
 javax.faces.context.ResponseWriter getResponseWriter()
           
 javax.faces.component.UIViewRoot getViewRoot()
           
 boolean isJSFRequestDone()
           
 boolean isPostback()
           
 boolean isProcessingEvents()
           
 boolean isProjectStage(javax.faces.application.ProjectStage projectStage)
           
 boolean isValidationFailed()
           
 void release()
          This is called when the JSF lifecycle is over.
 void renderResponse()
           
 void responseComplete()
           
 void setCurrentPhaseId(javax.faces.event.PhaseId phaseId)
           
 void setExceptionHandler(javax.faces.context.ExceptionHandler exceptionHandler)
           
 void setInstanceToJSFUnitThread()
          This allows the FacesContextBridge to associate the JSFUnitFacesContext with the thread running the tests.
 void setProcessingEvents(boolean processingEvents)
           
 void setResponseStream(javax.faces.context.ResponseStream responseStream)
           
 void setResponseWriter(javax.faces.context.ResponseWriter responseWriter)
           
 void setViewRoot(javax.faces.component.UIViewRoot uIViewRoot)
           
 void validationFailed()
           
 void valueBound(javax.servlet.http.HttpSessionBindingEvent httpSessionBindingEvent)
           
 void valueUnbound(javax.servlet.http.HttpSessionBindingEvent httpSessionBindingEvent)
          Attempt to clean up the previous FacesContext.
 
Methods inherited from class javax.faces.context.FacesContext
getCurrentInstance, setCurrentInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SESSION_KEY

public static final String SESSION_KEY
Constructor Detail

JSFUnitFacesContext

public JSFUnitFacesContext(javax.faces.context.FacesContext delegate)
Method Detail

isProjectStage

public boolean isProjectStage(javax.faces.application.ProjectStage projectStage)
Overrides:
isProjectStage in class javax.faces.context.FacesContext

getMessages

public Iterator getMessages(String clientId)
Specified by:
getMessages in class javax.faces.context.FacesContext

addMessage

public void addMessage(String clientId,
                       javax.faces.application.FacesMessage facesMessage)
Specified by:
addMessage in class javax.faces.context.FacesContext

setResponseWriter

public void setResponseWriter(javax.faces.context.ResponseWriter responseWriter)
Specified by:
setResponseWriter in class javax.faces.context.FacesContext

setResponseStream

public void setResponseStream(javax.faces.context.ResponseStream responseStream)
Specified by:
setResponseStream in class javax.faces.context.FacesContext

setViewRoot

public void setViewRoot(javax.faces.component.UIViewRoot uIViewRoot)
Specified by:
setViewRoot in class javax.faces.context.FacesContext

responseComplete

public void responseComplete()
Specified by:
responseComplete in class javax.faces.context.FacesContext

renderResponse

public void renderResponse()
Specified by:
renderResponse in class javax.faces.context.FacesContext

getApplication

public javax.faces.application.Application getApplication()
Specified by:
getApplication in class javax.faces.context.FacesContext

getClientIdsWithMessages

public Iterator getClientIdsWithMessages()
Specified by:
getClientIdsWithMessages in class javax.faces.context.FacesContext

getExternalContext

public javax.faces.context.ExternalContext getExternalContext()
Specified by:
getExternalContext in class javax.faces.context.FacesContext

getMaximumSeverity

public javax.faces.application.FacesMessage.Severity getMaximumSeverity()
Specified by:
getMaximumSeverity in class javax.faces.context.FacesContext

getMessages

public Iterator getMessages()
Specified by:
getMessages in class javax.faces.context.FacesContext

getRenderKit

public javax.faces.render.RenderKit getRenderKit()
Specified by:
getRenderKit in class javax.faces.context.FacesContext

getRenderResponse

public boolean getRenderResponse()
Specified by:
getRenderResponse in class javax.faces.context.FacesContext

getResponseComplete

public boolean getResponseComplete()
Specified by:
getResponseComplete in class javax.faces.context.FacesContext

getResponseStream

public javax.faces.context.ResponseStream getResponseStream()
Specified by:
getResponseStream in class javax.faces.context.FacesContext

getResponseWriter

public javax.faces.context.ResponseWriter getResponseWriter()
Specified by:
getResponseWriter in class javax.faces.context.FacesContext

getViewRoot

public javax.faces.component.UIViewRoot getViewRoot()
Specified by:
getViewRoot in class javax.faces.context.FacesContext

release

public void release()
This is called when the JSF lifecycle is over. After this is called, most operations will still delegate to the wrapped FacesContext, but the ExternalContext will be replaced with a JSFUnitExternalContext. This method does not call release() on the wrapped FacesContext. So, all of its state is retained for use by JSFUnit tests.

Specified by:
release in class javax.faces.context.FacesContext

getAttributes

public Map<Object,Object> getAttributes()
Overrides:
getAttributes in class javax.faces.context.FacesContext

getCurrentPhaseId

public javax.faces.event.PhaseId getCurrentPhaseId()
Overrides:
getCurrentPhaseId in class javax.faces.context.FacesContext

isPostback

public boolean isPostback()
Overrides:
isPostback in class javax.faces.context.FacesContext

setCurrentPhaseId

public void setCurrentPhaseId(javax.faces.event.PhaseId phaseId)
Overrides:
setCurrentPhaseId in class javax.faces.context.FacesContext

getExceptionHandler

public javax.faces.context.ExceptionHandler getExceptionHandler()
Overrides:
getExceptionHandler in class javax.faces.context.FacesContext

getMessageList

public List<javax.faces.application.FacesMessage> getMessageList()
Overrides:
getMessageList in class javax.faces.context.FacesContext

getMessageList

public List<javax.faces.application.FacesMessage> getMessageList(String clientId)
Overrides:
getMessageList in class javax.faces.context.FacesContext

getPartialViewContext

public javax.faces.context.PartialViewContext getPartialViewContext()
Overrides:
getPartialViewContext in class javax.faces.context.FacesContext

isProcessingEvents

public boolean isProcessingEvents()
Overrides:
isProcessingEvents in class javax.faces.context.FacesContext

isValidationFailed

public boolean isValidationFailed()
Overrides:
isValidationFailed in class javax.faces.context.FacesContext

setExceptionHandler

public void setExceptionHandler(javax.faces.context.ExceptionHandler exceptionHandler)
Overrides:
setExceptionHandler in class javax.faces.context.FacesContext

setProcessingEvents

public void setProcessingEvents(boolean processingEvents)
Overrides:
setProcessingEvents in class javax.faces.context.FacesContext

validationFailed

public void validationFailed()
Overrides:
validationFailed in class javax.faces.context.FacesContext

setInstanceToJSFUnitThread

public void setInstanceToJSFUnitThread()
This allows the FacesContextBridge to associate the JSFUnitFacesContext with the thread running the tests.


isJSFRequestDone

public boolean isJSFRequestDone()

getELContext

public javax.el.ELContext getELContext()
Overrides:
getELContext in class javax.faces.context.FacesContext

cleanUpOldFacesContext

public static void cleanUpOldFacesContext()
This static method will attempt to clean up any FacesContext that is associated with the current thread.


valueUnbound

public void valueUnbound(javax.servlet.http.HttpSessionBindingEvent httpSessionBindingEvent)
Attempt to clean up the previous FacesContext.

Specified by:
valueUnbound in interface javax.servlet.http.HttpSessionBindingListener

valueBound

public void valueBound(javax.servlet.http.HttpSessionBindingEvent httpSessionBindingEvent)
Specified by:
valueBound in interface javax.servlet.http.HttpSessionBindingListener


Copyright © 2007-2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.