Project Wonder 5.0

er.ajax
Class AjaxModalDialog

java.lang.Object
  extended by com.webobjects.appserver.WOElement
      extended by com.webobjects.appserver.WOComponent
          extended by er.ajax.AjaxComponent
              extended by er.ajax.AjaxModalDialog
All Implemented Interfaces:
com.webobjects.appserver.WOActionResults, com.webobjects.foundation.NSKeyValueCoding, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCodingAdditions, com.webobjects.foundation.NSValidation, IAjaxElement, java.io.Serializable, java.lang.Cloneable

public class AjaxModalDialog
extends AjaxComponent

AjaxModalDialog is a modal dialog window based on ModalBox (see below for link). It differs from AjaxModalContainer in that it handles submitting forms and updating the container contents. It also looks more like an OS X modal dialog if you consider that to be a benefit.

The AjaxModalDialog is not rendered where it is located in your page. Because of this, it should not be physically nested in a form if it uses form input (needs a form), as it will be rendered outside of the form. If you want to have such a dialog, place the AjaxModalDialog outside of the form and use an AjaxModalDialogOpener in the form.

The links shown to open the dialog can come from two sources:

The contents for the modal dialog can come from four sources:

To cause the dialog to be closed in an Ajax action method, use this: AjaxModalDialog.close(context());

To cause the contents of the dialog to be updated in an Ajax action method, use this: AjaxModalDialog.update(context());

The modal dialog is opened by calling a JavaScript function. While this is normally done from an onclick handler, you can call it directly. The function name is openAMD_(): openAMD_MyDialogId();

See Also:
AjaxModalDialogOpener, Modalbox Page, Google Group, Serialized Form
Author:
chill TODO handle href to static content TODO make dialog draggable TODO lock dialog open unless closed by content TODO add transitioning to other contents without closing dialog
Bindings
action action method returning the contents of the dialog box
           
pageName name of WOComponent for the contents of the dialog box
           
label the text for the link that opens the dialog box
           
title Title to be displayed in the ModalBox window header, also used as title attribute of link opening dialog
           
linkTitle Title to be used as title attribute of link opening dialog, title is used if this is not present
           
width integer Width in pixels, use -1 for auto-width
           
height integer Height in pixels, use -1 for auto-height. When set Modalbox will operate in 'fixed-height' mode.
           
centerVertically optional, if true the dialog is centered vertically on the page instead of appearing at the top
           
open if true, the container is rendered already opened, the default is false
           
showOpener if false, no HTML is generated for the link, button etc. to open this dialog, it can only be opened from custom JavaScript (see below). The default is true
           
enabled if false, nothing is rendered for this component. This can be used instead of wrapping this in a WOConditional. The default is true.
           
ignoreNesting optional, if true and this dialog is nested inside another, no warning will be output
           
onOpen server side method that runs before the dialog is opened, the return value is discarded
           
onClose server side method that runs before the dialog is closed, the return value is discarded. This will be executed if the page is reloaded, but not if the user navigates elsewhere.
           
closeUpdateContainerID the update container to refresh when onClose is called
           
onCloseBeforeUpdate if the given function returns true, the update container named in closeUpdateContainerID is updated. This is to allow conditional updating, e.g. not updating when the dialog is simply dismissed.
           
clickOnReturnId optional, ID of clickable HTML element to click when the Return key is pressed. This is ignored if a clickable element has the focus
           
clickOnEscId optional, ID of clickable HTML element to click when the Esc key is pressed. This is ignored if a clickable element has the focus but overrides the locked setting
           
id HTML id for the link activating the modal dialog
           
class CSS class for the link activating the modal dialog
           
style CSS style for the link activating the modal dialog
           
overlayClose true | false Close modal box by clicking on overlay. Default is true.
           
locked if true, suppresses the close window link, prevents Esc key and overlay from closing dialog. Default is false, true implies overlayClose false. If clickOnEscId is bound, this allows Esc to do something regardless of the locked binding
           
method get | post. Method of passing variables to a server. Default is 'get'.
           
params {} Collection of parameters to pass on AJAX request. Should be URL-encoded. See PassingFormValues for details.
           
loadingString string The message to show during loading. Default is "Please wait. Loading...".
           
closeString Defines title attribute for close window link. Default is "Close window".
           
closeValue Defines the string for close link in the header. Default is '×'
           
overlayOpacity Overlay opacity. Must be between 0-1. Default is .65.
           
overlayDuration Overlay fade in/out duration in seconds.
           
slideDownDuration Modalbox appear slide down effect in seconds.
           
slideUpDuration Modalbox hiding slide up effect in seconds.
           
resizeDuration Modalbox resize duration in seconds.
           
inactiveFade true | false, Toggles Modalbox window fade on inactive state.
           
transitions true | false, Toggles transition effects. Transitions are enabled by default.
           
autoFocusing true | false, Toggles auto-focusing for form elements. Disable it for long text pages. Add the class MB_notFocusable to any inputs you want excluded from focusing.
           
beforeLoad client side method, fires right before loading contents into the ModalBox. If the callback function returns false, content loading will skipped. This can be used for redirecting user to another MB-page for authorization purposes for example.
           
afterLoad client side method, fires after loading content into the ModalBox (i.e. after showing or updating existing window).
           
beforeHide client side method, fires right before removing elements from the DOM. Might be useful to get form values before hiding modalbox.
           
afterHide client side method, fires after hiding ModalBox from the screen.
           
afterResize client side method, fires after calling resize method.
           
onShow client side method, fires on first appearing of ModalBox before the contents are being loaded.
           
onUpdate client side method, fires on updating the content of ModalBox (on call of Modalbox.show method from active ModalBox instance).
           

Nested Class Summary
 
Nested classes/interfaces inherited from class com.webobjects.appserver.WOComponent
com.webobjects.appserver.WOComponent._EventLoggingEnabler, com.webobjects.appserver.WOComponent.Event
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
com.webobjects.foundation.NSKeyValueCodingAdditions.DefaultImplementation, com.webobjects.foundation.NSKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCoding
com.webobjects.foundation.NSKeyValueCoding._BooleanFieldBinding, com.webobjects.foundation.NSKeyValueCoding._BooleanMethodBinding, com.webobjects.foundation.NSKeyValueCoding._FieldBinding, com.webobjects.foundation.NSKeyValueCoding._ForwardingBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBinding, com.webobjects.foundation.NSKeyValueCoding._KeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding._MethodBinding, com.webobjects.foundation.NSKeyValueCoding._NumberFieldBinding, com.webobjects.foundation.NSKeyValueCoding._NumberMethodBinding, com.webobjects.foundation.NSKeyValueCoding._ReflectionKeyBindingCreation, com.webobjects.foundation.NSKeyValueCoding.ErrorHandling, com.webobjects.foundation.NSKeyValueCoding.Null, com.webobjects.foundation.NSKeyValueCoding.UnknownKeyException, com.webobjects.foundation.NSKeyValueCoding.ValueAccessor
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSValidation
com.webobjects.foundation.NSValidation._MethodBinding, com.webobjects.foundation.NSValidation._ValidationBinding, com.webobjects.foundation.NSValidation.DefaultImplementation, com.webobjects.foundation.NSValidation.Utility, com.webobjects.foundation.NSValidation.ValidationException
 
Field Summary
static java.lang.String Close
          JavaScript to execute on the client to close the modal dialog
static java.lang.String Close_ElementID_Suffix
          Element ID suffix indicating an C Dialog action.
static org.apache.log4j.Logger logger
           
static java.lang.String Open_ElementID_Suffix
          Element ID suffix indicating an Open Dialog action.
 
Fields inherited from class com.webobjects.appserver.WOComponent
_Extension, _IsEventLoggingEnabled, _keyAssociations
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding.ErrorHandling
_CLASS
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
_CLASS, _KeyPathSeparatorChar, KeyPathSeparator
 
Fields inherited from interface com.webobjects.foundation.NSKeyValueCoding
NullValue
 
Fields inherited from interface com.webobjects.foundation.NSValidation
_CLASS
 
Constructor Summary
AjaxModalDialog(com.webobjects.appserver.WOContext context)
           
 
Method Summary
protected  java.lang.String _containerID(com.webobjects.appserver.WOContext context)
          Returns the ID that represents this container for the purposes of Ajax updates.
static AjaxModalDialog _currentDialog(com.webobjects.appserver.WOContext context)
           
protected  void addRequiredWebResources(com.webobjects.appserver.WOResponse response)
          Override this method to append the needed scripts for this component.
protected  void appendOpenModalDialogFunction(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
          Appends function body to open the modal dialog window.
 void appendToResponse(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
          This has two modes.
 void awake()
          Start of R-R loop.
static void close(com.webobjects.appserver.WOContext context)
          Call this method to have a JavaScript response returned that closes the modal dialog.
 void closeDialog()
          If the dialog is open, calls the method bound to onClose (if any), and marks the dialog state as closed.
protected  java.lang.String closeDialogURL(com.webobjects.appserver.WOContext context)
           
protected  com.webobjects.foundation.NSMutableDictionary createModalBoxOptions()
           
protected  java.lang.String cssFileFrameworkName()
           
protected  java.lang.String cssFileName()
           
static AjaxModalDialog currentDialog(com.webobjects.appserver.WOContext context)
           
 com.webobjects.appserver.WOActionResults handleRequest(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
          Handles the open and close dialog actions.
 java.lang.String id()
           
 com.webobjects.appserver.WOActionResults invokeAction(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
          Only handle this phase if the modal box is open or it is our action (opening the box).
static boolean isInDialog(com.webobjects.appserver.WOContext context)
           
 boolean isOpen()
           
static void open(com.webobjects.appserver.WOContext context, java.lang.String id)
          Call this method to have a JavaScript response returned that opens the modal dialog.
static void open(com.webobjects.appserver.WOContext context, java.lang.String id, java.lang.String title)
          Call this method to have a JavaScript response returned that opens the modal dialog.
 void openDialog()
          Calls the method bound to onOpen (if any), and marks the dialog state as open.
static java.lang.String openDialogFunctionName(java.lang.String id)
          Returns the JavaScript function name for the function to open the AjaxModalDialog with the specified ID.
protected  java.lang.String openDialogURL(com.webobjects.appserver.WOContext context)
           
protected  void popActionResultsFromContext(com.webobjects.appserver.WOContext context)
          Sets the current component in context to the one there before pushActionResultsIntoContext was called.
protected  void popDialog()
          Remove this dialog instance from the context, replacing the previous one if any.
protected  void pushActionResultsIntoContext(com.webobjects.appserver.WOContext context)
          Make _actionResults (result of the action binding) the current component in context for WO processing.
protected  void pushDialog()
          Stash this dialog instance in the context so we can access it from the static methods.
 void setCurrentDialogInPageIfNecessary(com.webobjects.appserver.WOActionResults results, com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
           
 void setOpen(boolean open)
           
static void setTitle(com.webobjects.appserver.WOContext context, java.lang.String title)
          Deprecated. use update(WOContext, title) instead
protected  boolean shouldHandleRequest(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
          Removes Open_ElementID_Suffix or Close_ElementID_Suffix before evaluating senderID.
 void sleep()
          End of R-R loop.
 boolean synchronizesVariablesWithBindings()
           
 void takeValuesFromRequest(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
          Only handle this phase if the modal box is open.
 java.lang.String templateName()
          Returns the template name for the ERXWOComponentContent: null to show the dialog (default) contents and "link" to show the link contents
static void update(com.webobjects.appserver.WOContext context)
          Deprecated. use update(WOContext, null) instead
static void update(com.webobjects.appserver.WOContext context, java.lang.String title)
          Call this method to have a JavaScript response returned that updates the contents of the modal dialog.
 
Methods inherited from class er.ajax.AjaxComponent
addScriptResourceInHead, addScriptResourceInHead, addStylesheetResourceInHead, addStylesheetResourceInHead, appendTagAttributeToResponse, booleanValueForBinding, safeElementID, valueForBinding, valueForBinding, valueForBinding
 
Methods inherited from class com.webobjects.appserver.WOComponent
_associationWithName, _awakeInContext, _childTemplate, _componentDefinition, _componentUnroll, _isPage, _setContext, _setIsPage, _setParent, _setSubcomponent, _sleepInContext, _subcomponentForElementWithID, _templateNameForClass, _unroll, application, baseURL, bindingKeys, canAccessFieldsDirectly, canGetValueForBinding, canSetValueForBinding, clone, context, debugString, descriptionForResponse, ensureAwakeInContext, frameworkName, generateResponse, handleQueryWithUnboundKey, handleTakeValueForUnboundKey, hasBinding, hasSession, isCachingEnabled, isEventLoggingEnabled, isStateless, logString, name, pageWithName, parent, path, pathURL, performParentAction, pullValuesFromParent, pushValuesToParent, reset, session, set_componentUnroll, set_unroll, setCachingEnabled, setValueForBinding, takeValueForKey, takeValueForKeyPath, template, templateWithHTMLString, templateWithName, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, validationFailedWithException, valueForBinding, valueForKey, valueForKeyPath
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Close

public static final java.lang.String Close
JavaScript to execute on the client to close the modal dialog

See Also:
Constant Field Values

Open_ElementID_Suffix

public static final java.lang.String Open_ElementID_Suffix
Element ID suffix indicating an Open Dialog action.

See Also:
Constant Field Values

Close_ElementID_Suffix

public static final java.lang.String Close_ElementID_Suffix
Element ID suffix indicating an C Dialog action.

See Also:
Constant Field Values

logger

public static final org.apache.log4j.Logger logger
Constructor Detail

AjaxModalDialog

public AjaxModalDialog(com.webobjects.appserver.WOContext context)
Method Detail

synchronizesVariablesWithBindings

public boolean synchronizesVariablesWithBindings()
Overrides:
synchronizesVariablesWithBindings in class com.webobjects.appserver.WOComponent

isOpen

public boolean isOpen()

setOpen

public void setOpen(boolean open)

open

public static void open(com.webobjects.appserver.WOContext context,
                        java.lang.String id)
Call this method to have a JavaScript response returned that opens the modal dialog. The title of the dialog will be what it was when rendered.

Parameters:
context - the current WOContext
id - the HTML ID of the AjaxModalDialog to open

open

public static void open(com.webobjects.appserver.WOContext context,
                        java.lang.String id,
                        java.lang.String title)
Call this method to have a JavaScript response returned that opens the modal dialog. The title of the dialog will be the passed title. This is useful if the script to open this dialog was rendered without the title or with an incorrect title.

Parameters:
context - the current WOContext
id - the HTML ID of the AjaxModalDialog to open
title - the title for the AjaxModalDialog

openDialogFunctionName

public static java.lang.String openDialogFunctionName(java.lang.String id)
Returns the JavaScript function name for the function to open the AjaxModalDialog with the specified ID.

Parameters:
id - the HTML ID of the AjaxModalDialog to open
Returns:
JavaScript function name for the function to open the AjaxModalDialog

close

public static void close(com.webobjects.appserver.WOContext context)
Call this method to have a JavaScript response returned that closes the modal dialog.

Parameters:
context - the current WOContext

update

public static void update(com.webobjects.appserver.WOContext context,
                          java.lang.String title)
Call this method to have a JavaScript response returned that updates the contents of the modal dialog.

Parameters:
context - the current WOContext
title - optional new title for the updated dialog

update

public static void update(com.webobjects.appserver.WOContext context)
Deprecated. use update(WOContext, null) instead

Call this method to have a JavaScript response returned that updates the contents of the modal dialog without updating the title.

Parameters:
context - the current WOContext
See Also:
update(WOContext, String)

setTitle

public static void setTitle(com.webobjects.appserver.WOContext context,
                            java.lang.String title)
Deprecated. use update(WOContext, title) instead

Call this method to have a JavaScript response returned that updates the title of the modal dialog.

Parameters:
context - the current WOContext
title - the new title for the dialog window
See Also:
update(WOContext, String)

setCurrentDialogInPageIfNecessary

public void setCurrentDialogInPageIfNecessary(com.webobjects.appserver.WOActionResults results,
                                              com.webobjects.appserver.WORequest request,
                                              com.webobjects.appserver.WOContext context)

_currentDialog

public static AjaxModalDialog _currentDialog(com.webobjects.appserver.WOContext context)
Parameters:
context - the current WOContext
Returns:
the AjaxModalDialog currently being processed
Throws:
java.lang.RuntimeException - if no AjaxModalDialog is currently being processed

currentDialog

public static AjaxModalDialog currentDialog(com.webobjects.appserver.WOContext context)
Parameters:
context - the current WOContext
Returns:
the AjaxModalDialog currently being processed
Throws:
java.lang.RuntimeException - if no AjaxModalDialog is currently being processed

isInDialog

public static boolean isInDialog(com.webobjects.appserver.WOContext context)
Parameters:
context - the current WOContext
Returns:
true if an AjaxModalDialog currently being processed

awake

public void awake()
Start of R-R loop. awakes the components from action if action is bound.

Overrides:
awake in class com.webobjects.appserver.WOComponent
See Also:
WOComponent.awake()

takeValuesFromRequest

public void takeValuesFromRequest(com.webobjects.appserver.WORequest request,
                                  com.webobjects.appserver.WOContext context)
Only handle this phase if the modal box is open. Also includes result returned by action binding if bound.

Overrides:
takeValuesFromRequest in class com.webobjects.appserver.WOComponent
See Also:
WOComponent.takeValuesFromRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)

invokeAction

public com.webobjects.appserver.WOActionResults invokeAction(com.webobjects.appserver.WORequest request,
                                                             com.webobjects.appserver.WOContext context)
Only handle this phase if the modal box is open or it is our action (opening the box). Overridden to include result returned by action binding if bound.

Overrides:
invokeAction in class AjaxComponent
See Also:
close(WOContext), update(WOContext), WOComponent.takeValuesFromRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)

shouldHandleRequest

protected boolean shouldHandleRequest(com.webobjects.appserver.WORequest request,
                                      com.webobjects.appserver.WOContext context)
Removes Open_ElementID_Suffix or Close_ElementID_Suffix before evaluating senderID.

Overrides:
shouldHandleRequest in class AjaxComponent
Returns:
true if this request is for this component
See Also:
AjaxComponent.shouldHandleRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)

handleRequest

public com.webobjects.appserver.WOActionResults handleRequest(com.webobjects.appserver.WORequest request,
                                                              com.webobjects.appserver.WOContext context)
Handles the open and close dialog actions.

Specified by:
handleRequest in interface IAjaxElement
Specified by:
handleRequest in class AjaxComponent
Returns:
null or dialog contents
See Also:
AjaxComponent.handleRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)

appendToResponse

public void appendToResponse(com.webobjects.appserver.WOResponse response,
                             com.webobjects.appserver.WOContext context)
This has two modes. One is to generate the link that opens the dialog. The other is to return the contents of the dialog (the result returned by action binding is handled in handleRequest, not here).

Overrides:
appendToResponse in class AjaxComponent
See Also:
AjaxComponent.appendToResponse(com.webobjects.appserver.WOResponse, com.webobjects.appserver.WOContext)

appendOpenModalDialogFunction

protected void appendOpenModalDialogFunction(com.webobjects.appserver.WOResponse response,
                                             com.webobjects.appserver.WOContext context)
Appends function body to open the modal dialog window.

Parameters:
response - WOResponse to append to
context - WOContext of response
See Also:
AjaxModalDialog#openDialogFunctionName(String)

sleep

public void sleep()
End of R-R loop. Puts the components from action to sleep if action is bound.

Overrides:
sleep in class com.webobjects.appserver.WOComponent
See Also:
WOComponent.sleep()

openDialog

public void openDialog()
Calls the method bound to onOpen (if any), and marks the dialog state as open.


closeDialog

public void closeDialog()
If the dialog is open, calls the method bound to onClose (if any), and marks the dialog state as closed. This method can get called if the page gets reloaded so be careful modifying the response if ! AjaxRequestHandler.AjaxRequestHandlerKey.equals(context().request().requestHandlerKey())


_containerID

protected java.lang.String _containerID(com.webobjects.appserver.WOContext context)
Description copied from class: AjaxComponent
Returns the ID that represents this container for the purposes of Ajax updates. In common cases, this corresponds to your updateContainerID.

Overrides:
_containerID in class AjaxComponent
Parameters:
context - the current context
Returns:
id()
See Also:
AjaxComponent._containerID(com.webobjects.appserver.WOContext)

id

public java.lang.String id()
Returns:
the value bound to id or an manufactured string if id is not bound

templateName

public java.lang.String templateName()
Returns the template name for the ERXWOComponentContent: null to show the dialog (default) contents and "link" to show the link contents

Returns:
null or "link"

createModalBoxOptions

protected com.webobjects.foundation.NSMutableDictionary createModalBoxOptions()
Returns:
binding values converted into Ajax options for ModalBox

addRequiredWebResources

protected void addRequiredWebResources(com.webobjects.appserver.WOResponse response)
Description copied from class: AjaxComponent
Override this method to append the needed scripts for this component.

Specified by:
addRequiredWebResources in class AjaxComponent
See Also:
AjaxComponent.addRequiredWebResources(com.webobjects.appserver.WOResponse)

cssFileName

protected java.lang.String cssFileName()
Returns:
value for modalboxCSS binding, or default of "modalbox.css"

cssFileFrameworkName

protected java.lang.String cssFileFrameworkName()
Returns:
value for modalboxCSSFramework binding, or default of "Ajax"

pushDialog

protected void pushDialog()
Stash this dialog instance in the context so we can access it from the static methods. If there is one AMD nested in another (a rather dubious thing to do that we warn about but it may have its uses), we need to remember the outer one while processing this inner one

See Also:
AjaxModalDialog#popDialog()

popDialog

protected void popDialog()
Remove this dialog instance from the context, replacing the previous one if any.

See Also:
pushDialog()

pushActionResultsIntoContext

protected void pushActionResultsIntoContext(com.webobjects.appserver.WOContext context)
Make _actionResults (result of the action binding) the current component in context for WO processing. Remembers the current component so that it can be restored.

Parameters:
context - WOContext to push _actionResults into
See Also:
popActionResultsFromContext(WOContext)

popActionResultsFromContext

protected void popActionResultsFromContext(com.webobjects.appserver.WOContext context)
Sets the current component in context to the one there before pushActionResultsIntoContext was called.

Parameters:
context - WOContext to restore previous component in
See Also:
pushActionResultsIntoContext(WOContext)

openDialogURL

protected java.lang.String openDialogURL(com.webobjects.appserver.WOContext context)
Parameters:
context - WOContext to create URL in
Returns:
URL to invoke when the dialog is opened

closeDialogURL

protected java.lang.String closeDialogURL(com.webobjects.appserver.WOContext context)
Parameters:
context - WOContext to create URL in
Returns:
URL to invoke when the dialog is closed

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.