AjaxModalDialog Class Reference

Inherits er::ajax::AjaxComponent.

Collaboration diagram for AjaxModalDialog:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 AjaxModalDialog (WOContext context)
void appendToResponse (WOResponse response, WOContext context)
void awake ()
void closeDialog ()
WOActionResults handleRequest (WORequest request, WOContext context)
String id ()
WOActionResults invokeAction (WORequest request, WOContext context)
boolean isOpen ()
void openDialog ()
void setCurrentDialogInPageIfNecessary (WOActionResults results, WORequest request, WOContext context)
void setOpen (boolean open)
void sleep ()
boolean synchronizesVariablesWithBindings ()
void takeValuesFromRequest (WORequest request, WOContext context)
String templateName ()

Static Public Member Functions

static AjaxModalDialog _currentDialog (WOContext context)
static void close (WOContext context)
static AjaxModalDialog currentDialog (WOContext context)
static boolean isInDialog (WOContext context)
static void open (WOContext context, String id, String title)
static void open (WOContext context, String id)
static String openDialogFunctionName (String id)
static void setTitle (WOContext context, String title)
static void update (WOContext context)
static void update (WOContext context, String title)

Static Public Attributes

static final String Close = "AMD.close();"
static final String Close_ElementID_Suffix = ".close"
static final Logger logger = Logger.getLogger(AjaxModalDialog.class)
static final String Open_ElementID_Suffix = ".open"

Protected Member Functions

String _containerID (WOContext context)
void addRequiredWebResources (WOResponse response)
void appendOpenModalDialogFunction (WOResponse response, WOContext context)
String closeDialogURL (WOContext context)
NSMutableDictionary createModalBoxOptions ()
String cssFileFrameworkName ()
String cssFileName ()
String openDialogURL (WOContext context)
void popActionResultsFromContext (WOContext context)
void popDialog ()
void pushActionResultsIntoContext (WOContext context)
void pushDialog ()
boolean shouldHandleRequest (WORequest request, WOContext context)

Private Attributes

WOComponent _actionResults
boolean _open
String ajaxComponentActionUrl
boolean hasWarnedOnNesting = false
AjaxModalDialog outerDialog
WOComponent previousComponent


Detailed Description

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_<ID>(): openAMD_MyDialogId();

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).

See also:
AjaxModalDialogOpener

Modalbox Page

Google Group

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

Constructor & Destructor Documentation

AjaxModalDialog ( WOContext  context  ) 


Member Function Documentation

String _containerID ( WOContext  context  )  [protected]

See also:
er.ajax.AjaxComponent._containerID(com.webobjects.appserver.WOContext)
Returns:
id()

Reimplemented from AjaxComponent.

static AjaxModalDialog _currentDialog ( WOContext  context  )  [static]

Parameters:
context the current WOContext
Returns:
the AjaxModalDialog currently being processed
Exceptions:
RuntimeException if no AjaxModalDialog is currently being processed

void addRequiredWebResources ( WOResponse  response  )  [protected, virtual]

See also:
er.ajax.AjaxComponent.addRequiredWebResources(com.webobjects.appserver.WOResponse)

Implements AjaxComponent.

void appendOpenModalDialogFunction ( WOResponse  response,
WOContext  context 
) [protected]

Appends function body to open the modal dialog window.

See also:
AjaxModalDialog.openDialogFunctionName(String)
Parameters:
response WOResponse to append to
context WOContext of response

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).

See also:
er.ajax.AjaxComponent.appendToResponse(com.webobjects.appserver.WOResponse, com.webobjects.appserver.WOContext)

Reimplemented from AjaxComponent.

void awake (  ) 

Start of R-R loop. awakes the components from action if action is bound.

See also:
com.webobjects.appserver.WOComponent.awake()

static void close ( WOContext  context  )  [static]

Call this method to have a JavaScript response returned that closes the modal dialog.

Parameters:
context the current WOContext

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

String closeDialogURL ( WOContext  context  )  [protected]

Parameters:
context WOContext to create URL in
Returns:
URL to invoke when the dialog is closed

NSMutableDictionary createModalBoxOptions (  )  [protected]

Returns:
binding values converted into Ajax options for ModalBox

String cssFileFrameworkName (  )  [protected]

Returns:
value for modalboxCSSFramework binding, or default of "Ajax"

String cssFileName (  )  [protected]

Returns:
value for modalboxCSS binding, or default of "modalbox.css"

static AjaxModalDialog currentDialog ( WOContext  context  )  [static]

Parameters:
context the current WOContext
Returns:
the AjaxModalDialog currently being processed
Exceptions:
RuntimeException if no AjaxModalDialog is currently being processed

WOActionResults handleRequest ( WORequest  request,
WOContext  context 
) [virtual]

Handles the open and close dialog actions.

See also:
er.ajax.AjaxComponent.handleRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)
Returns:
null or dialog contents

Implements AjaxComponent.

String id (  ) 

Returns:
the value bound to id or an manufactured string if id is not bound

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.

See also:
close(WOContext)

update(WOContext)

com.webobjects.appserver.WOComponent.takeValuesFromRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)

Reimplemented from AjaxComponent.

static boolean isInDialog ( WOContext  context  )  [static]

Parameters:
context the current WOContext
Returns:
true if an AjaxModalDialog currently being processed

boolean isOpen (  ) 

static void open ( WOContext  context,
String  id,
String  title 
) [static]

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

static void open ( WOContext  context,
String  id 
) [static]

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

void openDialog (  ) 

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

static String openDialogFunctionName ( String  id  )  [static]

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

String openDialogURL ( WOContext  context  )  [protected]

Parameters:
context WOContext to create URL in
Returns:
URL to invoke when the dialog is opened

void popActionResultsFromContext ( WOContext  context  )  [protected]

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)

void popDialog (  )  [protected]

Remove this dialog instance from the context, replacing the previous one if any.

See also:
pushDialog()

void pushActionResultsIntoContext ( WOContext  context  )  [protected]

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)

void pushDialog (  )  [protected]

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

void setCurrentDialogInPageIfNecessary ( WOActionResults  results,
WORequest  request,
WOContext  context 
)

void setOpen ( boolean  open  ) 

static void setTitle ( WOContext  context,
String  title 
) [static]

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

See also:
update(WOContext, String)
Parameters:
context the current WOContext
title the new title for the dialog window
Deprecated:
use update(WOContext, title) instead

boolean shouldHandleRequest ( WORequest  request,
WOContext  context 
) [protected]

Removes Open_ElementID_Suffix or Close_ElementID_Suffix before evaluating senderID.

See also:
er.ajax.AjaxComponent.shouldHandleRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)
Returns:
true if this request is for this component

Reimplemented from AjaxComponent.

void sleep (  ) 

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

See also:
com.webobjects.appserver.WOComponent.sleep()

boolean synchronizesVariablesWithBindings (  ) 

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.

See also:
com.webobjects.appserver.WOComponent.takeValuesFromRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)

String templateName (  ) 

Returns the ID of the AjaxUpdateContainer that wraps the in-line contents of this dialog.

Returns:
id() + "Updater" Returns the template name for the ERXWOComponentContent: null to show the dialog (default) contents and "link" to show the link contents

null or "link"

static void update ( WOContext  context  )  [static]

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

See also:
update(WOContext, String)
Parameters:
context the current WOContext
Deprecated:
use update(WOContext, null) instead

static void update ( WOContext  context,
String  title 
) [static]

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


Member Data Documentation

WOComponent _actionResults [private]

boolean _open [private]

final String Close = "AMD.close();" [static]

JavaScript to execute on the client to close the modal dialog

final String Close_ElementID_Suffix = ".close" [static]

Element ID suffix indicating an C Dialog action.

boolean hasWarnedOnNesting = false [private]

final Logger logger = Logger.getLogger(AjaxModalDialog.class) [static]

final String Open_ElementID_Suffix = ".open" [static]

Element ID suffix indicating an Open Dialog action.

WOComponent previousComponent [private]


The documentation for this class was generated from the following file:

Generated on Sat May 26 06:42:38 2012 for Project Wonder by  doxygen 1.5.8