Author: craigmcc Date: Tue Jan 23 20:36:48 2007 New Revision: 499254 URL: http://svn.apache.org/viewvc?view=rev&rev=499254 Log: Add a convenience method to return the currently active DialogContext instance for this request, if there is one.
SHALE-396 Modified: shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/DialogContextManager.java shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/base/AbstractDialogContextManager.java Modified: shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/DialogContextManager.java URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/DialogContextManager.java?view=diff&rev=499254&r1=499253&r2=499254 ============================================================================== --- shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/DialogContextManager.java (original) +++ shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/DialogContextManager.java Tue Jan 23 20:36:48 2007 @@ -97,6 +97,17 @@ /** + * <p>Return the currently active [EMAIL PROTECTED] DialogContext} instance for the + * current request, if there is one; otherwise, return <code>null</code>.</p> + * + * @param context <code>FacesContext</code> for the current request + * + * @since 1.1.0 + */ + public DialogContext getActiveDialogContext(FacesContext context); + + + /** * <p>Remove the specified [EMAIL PROTECTED] DialogContext} instance from the set of * active instances for the current user.</p> * Modified: shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/base/AbstractDialogContextManager.java URL: http://svn.apache.org/viewvc/shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/base/AbstractDialogContextManager.java?view=diff&rev=499254&r1=499253&r2=499254 ============================================================================== --- shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/base/AbstractDialogContextManager.java (original) +++ shale/framework/trunk/shale-dialog/src/main/java/org/apache/shale/dialog/base/AbstractDialogContextManager.java Tue Jan 23 20:36:48 2007 @@ -84,6 +84,30 @@ } + // ------------------------------------------------- Default Implementations + + + /** + * <p>Return the currently active [EMAIL PROTECTED] DialogContext} instance for the + * current request, if there is one; otherwise, return <code>null</code>.</p> + * + * @param context <code>FacesContext</code> for the current request + * + * @since 1.1.0 + */ + public DialogContext getActiveDialogContext(FacesContext context) { + + DialogContext dcontext = (DialogContext) + context.getExternalContext().getRequestMap().get(Constants.CONTEXT_BEAN); + if ((dcontext != null) && dcontext.isActive()) { + return dcontext; + } else { + return null; + } + + } + + // --------------------------------------------------- Listener Registration