org.apache.myfaces.extensions.cdi.jsf.impl.util
Class ConversationUtils

java.lang.Object
  extended by org.apache.myfaces.extensions.cdi.jsf.impl.util.ConversationUtils

@Typed
public abstract class ConversationUtils
extends Object

internal! utils


Field Summary
static String EXISTING_WINDOW_ID_SET_KEY
           
 
Method Summary
static void addWindowContextIdHolderComponent()
          Needed for server-side window-handler and client-side window handler for supporting postbacks
static boolean cacheWindowId(javax.faces.context.ExternalContext externalContext, String id, boolean allowUnknownWindowIds)
           
static boolean cleanupInactiveWindowContexts(EditableWindowContextManager windowContextManager)
          Allows to cleanup empty or inactive WindowContexts which saves memory
static Class<? extends Annotation> convertToScope(javax.enterprise.inject.spi.BeanManager beanManager, Class conversationGroupKey, Annotation... qualifiers)
          Maps the given conversation-group-key to a scope-annotation
static Class<?> convertToSubGroup(Class<?> conversationGroupKey)
           
static Class getConversationGroup(javax.enterprise.inject.spi.Bean<?> bean)
          Calculates the conversation-group for a given Bean.
static Set<String> getExistingWindowIdSet(javax.faces.context.ExternalContext externalContext)
          Exposes an unmodifiable representation of the active window-ids which have been generated and stored for the current user
static String getNewViewId()
          Exposes the next view-id.
static String getOldViewId()
          Exposes the prev. view-id.
static WindowContextIdHolderComponent getWindowContextIdHolderComponent(javax.faces.context.FacesContext facesContext)
          Resolves WindowContextIdHolderComponent which is responsible for storing the window-id in case of a server-side window-handler.
static org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.WindowContextManager getWindowContextManager()
          Resolves the current WindowContextManager
static WindowHandler getWindowHandler()
          Resolves the current WindowHandler
static boolean isWindowActive(EditableWindowContextManager windowContextManager, String windowId)
          alternative to getExistingWindowIdSet(javax.faces.context.ExternalContext) because it might be deactivated...
static void postRenderCleanup(javax.faces.context.FacesContext facesContext)
          Performs the cleanup of inactive and empty WindowContexts (if permitted) and resets caches
static boolean removeExistingWindowId(javax.faces.context.ExternalContext externalContext, String windowContextId)
          Allows to remove a window-id which has been created for a user(-session)
static String resolveWindowContextId(WindowHandler windowHandler, boolean requestParameterSupported, boolean allowUnknownWindowIds)
          Tries to resolve the window-id via WindowHandler, request-parameters, request-map, component
static void sendRedirect(javax.faces.context.ExternalContext externalContext, String url, WindowHandler windowHandler)
          Triggers a redirect via the ExternalContext or the current WindowHandler, resets caches and prevents FacesMessages
static void storeCreatedWindowContextId(javax.faces.context.ExternalContext externalContext, String windowContextId)
          Allows to store the given window-id as active window-id
static void storeCurrentViewIdAsNewViewId(javax.faces.context.FacesContext facesContext)
          Stores the view-id of the current FacesContext as next view-id e.g. after a navigation occurred
static void storeCurrentViewIdAsNewViewId(javax.faces.context.FacesContext facesContext, WindowContext windowContext)
          Stores the view-id of the current FacesContext as next view-id e.g. after a navigation occurred
static void storeCurrentViewIdAsOldViewId(javax.faces.context.FacesContext facesContext)
          Stores the view-id of the current FacesContext as prev. view-id e.g. before a navigation occurs
static void storeCurrentViewIdAsOldViewId(javax.faces.context.FacesContext facesContext, org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.WindowContextManager windowContextManager)
          Stores the view-id of the current FacesContext as prev. view-id e.g. before a navigation occurs
static void storeViewIdAsNewViewId(WindowContext windowContext, String newViewId)
          Stores the given view-id as next view-id e.g. after a navigation occurred
static void tryToRestoreTheWindowIdEagerly(javax.faces.context.FacesContext facesContext, EditableWindowContextManager windowContextManager, WindowHandler windowHandler, WindowContextConfig windowContextConfig)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXISTING_WINDOW_ID_SET_KEY

public static final String EXISTING_WINDOW_ID_SET_KEY
Method Detail

getConversationGroup

public static Class getConversationGroup(javax.enterprise.inject.spi.Bean<?> bean)
Calculates the conversation-group for a given Bean. Conversation-groups are only supported in combination with ConversationScoped

Parameters:
bean - current bean
Returns:
class which represents the conversation-group

resolveWindowContextId

public static String resolveWindowContextId(WindowHandler windowHandler,
                                            boolean requestParameterSupported,
                                            boolean allowUnknownWindowIds)
Tries to resolve the window-id via WindowHandler, request-parameters, request-map, component

Parameters:
windowHandler - current window-handler
requestParameterSupported - flag which indicates if it is allowed to restore the id from the request-params
allowUnknownWindowIds - flag which indicates if it is allowed to use id's which haven't been created for the current user
Returns:
restored window-id, null otherwise

cacheWindowId

public static boolean cacheWindowId(javax.faces.context.ExternalContext externalContext,
                                    String id,
                                    boolean allowUnknownWindowIds)
Parameters:
externalContext - externalContext
id - windowId
allowUnknownWindowIds - true to force the usage of the given id
Returns:
false if the id doesn't exist in the storage (e.g. in case of bookmarks)

storeCurrentViewIdAsOldViewId

public static void storeCurrentViewIdAsOldViewId(javax.faces.context.FacesContext facesContext)
Stores the view-id of the current FacesContext as prev. view-id e.g. before a navigation occurs

Parameters:
facesContext - current faces-context

storeCurrentViewIdAsOldViewId

public static void storeCurrentViewIdAsOldViewId(javax.faces.context.FacesContext facesContext,
                                                 org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.WindowContextManager windowContextManager)
Stores the view-id of the current FacesContext as prev. view-id e.g. before a navigation occurs

Parameters:
facesContext - current faces-context
windowContextManager - current window-context-manager

storeCurrentViewIdAsNewViewId

public static void storeCurrentViewIdAsNewViewId(javax.faces.context.FacesContext facesContext)
Stores the view-id of the current FacesContext as next view-id e.g. after a navigation occurred

Parameters:
facesContext - current faces-context

storeCurrentViewIdAsNewViewId

public static void storeCurrentViewIdAsNewViewId(javax.faces.context.FacesContext facesContext,
                                                 WindowContext windowContext)
Stores the view-id of the current FacesContext as next view-id e.g. after a navigation occurred

Parameters:
facesContext - current faces-context
windowContext - current window-context

storeViewIdAsNewViewId

public static void storeViewIdAsNewViewId(WindowContext windowContext,
                                          String newViewId)
Stores the given view-id as next view-id e.g. after a navigation occurred

Parameters:
windowContext - current window-context
newViewId - next view-id

getOldViewId

public static String getOldViewId()
Exposes the prev. view-id.

Returns:
prev. view-id

getNewViewId

public static String getNewViewId()
Exposes the next view-id.

Returns:
next view-id

getWindowContextIdHolderComponent

public static WindowContextIdHolderComponent getWindowContextIdHolderComponent(javax.faces.context.FacesContext facesContext)
Resolves WindowContextIdHolderComponent which is responsible for storing the window-id in case of a server-side window-handler.

Parameters:
facesContext - current faces-context
Returns:
window-id holder which has been found, null otherwise

addWindowContextIdHolderComponent

public static void addWindowContextIdHolderComponent()
Needed for server-side window-handler and client-side window handler for supporting postbacks


sendRedirect

public static void sendRedirect(javax.faces.context.ExternalContext externalContext,
                                String url,
                                WindowHandler windowHandler)
                         throws IOException
Triggers a redirect via the ExternalContext or the current WindowHandler, resets caches and prevents FacesMessages

Parameters:
externalContext - current external-context
url - target URL
windowHandler - current window-handler
Throws:
IOException - in case of a failed redirect

getWindowHandler

public static WindowHandler getWindowHandler()
Resolves the current WindowHandler

Returns:
current window-handler

getWindowContextManager

public static org.apache.myfaces.extensions.cdi.core.impl.scope.conversation.spi.WindowContextManager getWindowContextManager()
Resolves the current WindowContextManager

Returns:
current window-context-manager

removeExistingWindowId

public static boolean removeExistingWindowId(javax.faces.context.ExternalContext externalContext,
                                             String windowContextId)
Allows to remove a window-id which has been created for a user(-session)

Parameters:
externalContext - current external-context
windowContextId - window-id to remove
Returns:
true if it was a known window-id, false otherwise

getExistingWindowIdSet

public static Set<String> getExistingWindowIdSet(javax.faces.context.ExternalContext externalContext)
Exposes an unmodifiable representation of the active window-ids which have been generated and stored for the current user

Parameters:
externalContext - current external-context
Returns:
active window-ids

storeCreatedWindowContextId

public static void storeCreatedWindowContextId(javax.faces.context.ExternalContext externalContext,
                                               String windowContextId)
Allows to store the given window-id as active window-id

Parameters:
externalContext - current external-context
windowContextId - window-id

cleanupInactiveWindowContexts

public static boolean cleanupInactiveWindowContexts(EditableWindowContextManager windowContextManager)
Allows to cleanup empty or inactive WindowContexts which saves memory

Parameters:
windowContextManager - current window-context-manager
Returns:
true if 1-n instances were destroyed, false otherwise

convertToScope

public static Class<? extends Annotation> convertToScope(javax.enterprise.inject.spi.BeanManager beanManager,
                                                         Class conversationGroupKey,
                                                         Annotation... qualifiers)
Maps the given conversation-group-key to a scope-annotation

Parameters:
beanManager - current bean-manager
conversationGroupKey - current conversation-group key
qualifiers - current qualifiers
Returns:
annotation-class of the scope

isWindowActive

public static boolean isWindowActive(EditableWindowContextManager windowContextManager,
                                     String windowId)
alternative to getExistingWindowIdSet(javax.faces.context.ExternalContext) because it might be deactivated...

Parameters:
windowContextManager - current windowContextManager
windowId - windowId in question
Returns:
true if the window is known and active, false otherwise

postRenderCleanup

public static void postRenderCleanup(javax.faces.context.FacesContext facesContext)
Performs the cleanup of inactive and empty WindowContexts (if permitted) and resets caches

Parameters:
facesContext - current faces-context

tryToRestoreTheWindowIdEagerly

public static void tryToRestoreTheWindowIdEagerly(javax.faces.context.FacesContext facesContext,
                                                  EditableWindowContextManager windowContextManager,
                                                  WindowHandler windowHandler,
                                                  WindowContextConfig windowContextConfig)

convertToSubGroup

public static Class<?> convertToSubGroup(Class<?> conversationGroupKey)


Copyright © 2010-2012 The Apache Software Foundation. All Rights Reserved.