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.
Don't use AjaxModalDialogs inside of a repetition. That will create a set of identical dialogs and will likely cause then to display the wrong data. Instead, declare the dialogs outside of the repetition. Then INSIDE the repetition use an AjaxModalDialogOpener for the link to open the dialog. The action method of the AjaxModalDialogOpener should cache the current item from the repetition in an instance variable. The AjaxModalDialog should then look at that instance variable to determine what data it should show.
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();
AjaxModalDialogOpener
,
Modalbox Page,
Google Group,
Serialized FormName | Description |
---|---|
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, default is value of property er.ajax.modaldialog.slideDownDuration=0.5 |
slideUpDuration | Modalbox hiding slide up effect in seconds, default is value of property er.ajax.modaldialog.slideUpDuration=0.5 |
resizeDuration | Modalbox resize duration in seconds, default is value of property er.ajax.modaldialog.resizeDuration=0.25 |
movable | Modalbox is movable, default is value of property er.ajax.modaldialog.movable=false |
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). |
com.webobjects.appserver.WOComponent._EventLoggingEnabler, com.webobjects.appserver.WOComponent.Event
com.webobjects.foundation.NSKeyValueCodingAdditions.DefaultImplementation, com.webobjects.foundation.NSKeyValueCodingAdditions.Utility
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.MapImplementation, com.webobjects.foundation.NSKeyValueCoding.Null<T>, com.webobjects.foundation.NSKeyValueCoding.UnknownKeyException, com.webobjects.foundation.NSKeyValueCoding.ValueAccessor
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
Modifier and Type | Field and Description |
---|---|
static String |
Close
JavaScript to execute on the client to close the modal dialog
|
static String |
Close_ElementID_Suffix
Element ID suffix indicating an C Dialog action.
|
static String |
Open_ElementID_Suffix
Element ID suffix indicating an Open Dialog action.
|
_Extension, _IsEventLoggingEnabled, _keyAssociations
Constructor and Description |
---|
AjaxModalDialog(com.webobjects.appserver.WOContext context) |
Modifier and Type | Method and Description |
---|---|
protected 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 String |
closeDialogURL(com.webobjects.appserver.WOContext context) |
protected NSMutableDictionary<String,String> |
createModalBoxOptions() |
protected String |
cssFileFrameworkName() |
protected 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.
|
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,
String id)
Call this method to have a JavaScript response returned that opens the modal dialog.
|
static void |
open(com.webobjects.appserver.WOContext context,
String id,
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 String |
openDialogFunctionName(String id)
Returns the JavaScript function name for the function to open the AjaxModalDialog with
the specified ID.
|
protected 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) |
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.
|
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,
String title)
Call this method to have a JavaScript response returned that updates the contents of the modal dialog.
|
static void |
update(com.webobjects.appserver.WOContext context,
com.webobjects.appserver.WOComponent newContent,
String title)
Call this method to have a JavaScript response returned that updates the contents of the modal dialog.
|
addScriptResourceInHead, addScriptResourceInHead, addStylesheetResourceInHead, addStylesheetResourceInHead, appendTagAttributeToResponse, booleanValueForBinding, safeElementID, valueForBinding, valueForBinding, valueForBinding
__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, setVariableValueForName, takeValueForKey, takeValueForKeyPath, template, templateWithHTMLString, templateWithHTMLString, templateWithHTMLString, templateWithName, toString, unableToSetNullForKey, validateTakeValueForKeyPath, validateValueForKey, validationFailedWithException, valueForBinding, valueForBooleanBinding, valueForIntegerBinding, valueForKey, valueForKeyPath, valueForNSArrayBindings, valueForNSDictionaryBindings, valueForNumberBinding, valueForStringBinding, variableValueForName, variableWithName
public static final String Close
public static final String Open_ElementID_Suffix
public static final String Close_ElementID_Suffix
public AjaxModalDialog(com.webobjects.appserver.WOContext context)
public boolean synchronizesVariablesWithBindings()
synchronizesVariablesWithBindings
in class com.webobjects.appserver.WOComponent
public boolean isOpen()
public void setOpen(boolean open)
public static void open(com.webobjects.appserver.WOContext context, String id)
context
- the current WOContextid
- the HTML ID of the AjaxModalDialog to openpublic static void open(com.webobjects.appserver.WOContext context, String id, String title)
context
- the current WOContextid
- the HTML ID of the AjaxModalDialog to opentitle
- the title for the AjaxModalDialogpublic static String openDialogFunctionName(String id)
id
- the HTML ID of the AjaxModalDialog to openpublic static void close(com.webobjects.appserver.WOContext context)
context
- the current WOContextpublic static void update(com.webobjects.appserver.WOContext context, String title)
context
- the current WOContexttitle
- optional new title for the updated dialogpublic static void update(com.webobjects.appserver.WOContext context, com.webobjects.appserver.WOComponent newContent, String title)
context
- the current WOContextnewContent
- the new content for the updated dialogtitle
- optional new title for the updated dialogpublic void setCurrentDialogInPageIfNecessary(com.webobjects.appserver.WOActionResults results, com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
public static AjaxModalDialog _currentDialog(com.webobjects.appserver.WOContext context)
context
- the current WOContextRuntimeException
- if no AjaxModalDialog is currently being processedpublic static AjaxModalDialog currentDialog(com.webobjects.appserver.WOContext context)
context
- the current WOContextRuntimeException
- if no AjaxModalDialog is currently being processedpublic static boolean isInDialog(com.webobjects.appserver.WOContext context)
context
- the current WOContextpublic void awake()
awake
in class com.webobjects.appserver.WOComponent
WOComponent.awake()
public void takeValuesFromRequest(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
takeValuesFromRequest
in class com.webobjects.appserver.WOComponent
WOComponent.takeValuesFromRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)
public com.webobjects.appserver.WOActionResults invokeAction(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
invokeAction
in class AjaxComponent
request
- the requestcontext
- context of the transactionclose(WOContext)
,
update(WOContext, String)
,
WOComponent.takeValuesFromRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)
protected boolean shouldHandleRequest(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
shouldHandleRequest
in class AjaxComponent
true
if this request is for this componentAjaxComponent.shouldHandleRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)
public com.webobjects.appserver.WOActionResults handleRequest(com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
handleRequest
in interface IAjaxElement
handleRequest
in class AjaxComponent
request
- the requestcontext
- the contextAjaxComponent.handleRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)
public void appendToResponse(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
appendToResponse
in class AjaxComponent
response
- the HTTP response that an application returns to a Web server to complete a cycle of the request-response loopcontext
- context of a transactionAjaxComponent.appendToResponse(com.webobjects.appserver.WOResponse, com.webobjects.appserver.WOContext)
protected void appendOpenModalDialogFunction(com.webobjects.appserver.WOResponse response, com.webobjects.appserver.WOContext context)
response
- WOResponse to append tocontext
- WOContext of responseopenDialogFunctionName(String)
public void sleep()
sleep
in class com.webobjects.appserver.WOComponent
WOComponent.sleep()
public void openDialog()
public void closeDialog()
! AjaxRequestHandler.AjaxRequestHandlerKey.equals(context().request().requestHandlerKey())
protected String _containerID(com.webobjects.appserver.WOContext context)
AjaxComponent
_containerID
in class AjaxComponent
context
- the current contextAjaxComponent._containerID(com.webobjects.appserver.WOContext)
public String id()
public String templateName()
protected NSMutableDictionary<String,String> createModalBoxOptions()
protected void addRequiredWebResources(com.webobjects.appserver.WOResponse response)
AjaxComponent
addRequiredWebResources
in class AjaxComponent
response
- the response to write toAjaxComponent.addRequiredWebResources(com.webobjects.appserver.WOResponse)
protected String cssFileName()
protected String cssFileFrameworkName()
protected void pushDialog()
popDialog()
protected void popDialog()
pushDialog()
protected void pushActionResultsIntoContext(com.webobjects.appserver.WOContext context)
context
- WOContext to push _actionResults intopopActionResultsFromContext(WOContext)
protected void popActionResultsFromContext(com.webobjects.appserver.WOContext context)
context
- WOContext to restore previous component inpushActionResultsIntoContext(WOContext)
protected String openDialogURL(com.webobjects.appserver.WOContext context)
context
- WOContext to create URL inprotected String closeDialogURL(com.webobjects.appserver.WOContext context)
context
- WOContext to create URL inCopyright © 2002 – 2020 Project Wonder.