Project Wonder 5.0.0.8658

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:
WOActionResults, NSKeyValueCoding, NSKeyValueCoding.ErrorHandling, NSKeyValueCodingAdditions, NSValidation, IAjaxElement, Serializable, 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 links shown to open the dialog can some from three sources:

The contents for the modal dialog can some from three 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());
NOTE: this does not work if you use the action binding. You must manage your own updating if you use this binding.

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();

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
See Also:
Modalbox Page, Google Group, Serialized Form
Bindings
action returns 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.
           
open if true, the container is rendered already opened, the default is false
           
showOpener if false, no HTML is generated for the link, button etch to open this dialog, it can only be opened from custom JavaScript (see below). The default is true
           
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 opened, 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
           
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.
           
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.
           
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
WOComponent._EventLoggingEnabler, WOComponent.Event
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSKeyValueCodingAdditions
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility
 
Nested classes/interfaces inherited from interface com.webobjects.foundation.NSValidation
NSValidation._MethodBinding, NSValidation._ValidationBinding, NSValidation.DefaultImplementation, NSValidation.Utility, NSValidation.ValidationException
 
Field Summary
static String Close
          JavaScript to execute on the client to close the modal dialog
 
Fields inherited from class er.ajax.AjaxComponent
log
 
Fields inherited from class com.webobjects.appserver.WOComponent
_Extension, _IsEventLoggingEnabled, _keyAssociations, MINUSONE
 
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.NSValidation
_CLASS
 
Constructor Summary
AjaxModalDialog(WOContext context)
           
 
Method Summary
protected  String _containerID(WOContext context)
           
protected  void addRequiredWebResources(WOResponse response)
          Override this method to append the needed scripts for this component.
protected  void appendOpenModalDialogFunction(WOResponse response, WOContext context)
          Appends function body to open the modal dialog window.
 void appendToResponse(WOResponse response, WOContext context)
          This has two modes.
 void awake()
          Start of R-R loop.
static void close(WOContext context)
          Call this method to have a JavaScript response returned that closes the modal dialog.
 void closeDialog()
          Calls the method bound to onClose (if any), and marks the dialog state as closed.
protected  NSMutableDictionary createModalBoxOptions()
           
 WOActionResults handleRequest(WORequest request, WOContext context)
          Handles the open and close dialog actions.
 String id()
           
 WOActionResults invokeAction(WORequest request, WOContext context)
          Only handle this phase if the modal box is open or it is our action (opening the box).
 boolean isOpen()
           
static void open(WOContext context, String id)
          Call this method to have a JavaScript response returned that closes the modal dialog.
 void openDialog()
          Calls the method bound to onOpen (if any), and marks the dialog state as open.
static String openDialogFunctionName(String id)
          Returns the JavaScript function name for the function to open the AjaxModalDialog with the specified ID.
 void setOpen(boolean open)
           
static void setTitle(WOContext context, String title)
          Call this method to have a JavaScript response returned that updates the title of the modal dialog.
 void sleep()
          End of R-R loop.
 boolean synchronizesVariablesWithBindings()
           
 void takeValuesFromRequest(WORequest request, WOContext context)
          Only handle this phase if the modal box is open.
 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(WOContext context)
          Call this method to have a JavaScript response returned that updates the contents of the modal dialog.
 String updateContainerID()
          Returns the ID of the AjaxUpdateContainer that wraps the in-line contents of this 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
__valueForBinding, _associationWithName, _awakeInContext, _childTemplate, _cleanUpStatelessComponent, _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, templateWithHTMLString, templateWithName, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, validationFailedWithException, valueForBinding, valueForBooleanBinding, valueForIntegerBinding, valueForKey, valueForKeyPath, valueForNSArrayBindings, valueForNSDictionaryBindings, valueForNumberBinding, valueForStringBinding
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

Close

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

See Also:
Constant Field Values
Constructor Detail

AjaxModalDialog

public AjaxModalDialog(WOContext context)
Method Detail

synchronizesVariablesWithBindings

public boolean synchronizesVariablesWithBindings()
Overrides:
synchronizesVariablesWithBindings in class WOComponent

isOpen

public boolean isOpen()

setOpen

public void setOpen(boolean open)

open

public static void open(WOContext context,
                        String id)
Call this method to have a JavaScript response returned that closes the modal dialog.

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

openDialogFunctionName

public static String openDialogFunctionName(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(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(WOContext context)
Call this method to have a JavaScript response returned that updates the contents of the modal dialog. Note that this does not work with the action binding. You need to manage your own AjaxUpdateContainer if you use an action method for the contents of the dialog.

Parameters:
context - the current WOContext

setTitle

public static void setTitle(WOContext context,
                            String title)
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

awake

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

Overrides:
awake in class WOComponent
See Also:
WOComponent.awake()

takeValuesFromRequest

public void takeValuesFromRequest(WORequest request,
                                  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 WOComponent
See Also:
WOComponent.takeValuesFromRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)

invokeAction

public WOActionResults invokeAction(WORequest request,
                                    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)

handleRequest

public WOActionResults handleRequest(WORequest request,
                                     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(WOResponse response,
                             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(WOResponse response,
                                             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 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()
Calls the method bound to onClose (if any), and marks the dialog state as closed.


_containerID

protected String _containerID(WOContext context)
Overrides:
_containerID in class AjaxComponent
Returns:
id()
See Also:
AjaxComponent._containerID(com.webobjects.appserver.WOContext)

id

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

updateContainerID

public String updateContainerID()
Returns the ID of the AjaxUpdateContainer that wraps the in-line contents of this dialog.

Returns:
id() + "Updater"

templateName

public 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 NSMutableDictionary createModalBoxOptions()
Returns:
binding values converted into Ajax options for ModalBox

addRequiredWebResources

protected void addRequiredWebResources(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)

Last updated: Fri, Nov 21, 2008 • 04:36 AM EST

Copyright © 2002 – 2007 Project Wonder.