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). |
WOComponent._EventLoggingEnabler, WOComponent.Event
NSKeyValueCodingAdditions.DefaultImplementation, NSKeyValueCodingAdditions.Utility
NSKeyValueCoding._BooleanFieldBinding, NSKeyValueCoding._BooleanMethodBinding, NSKeyValueCoding._FieldBinding, NSKeyValueCoding._ForwardingBinding, NSKeyValueCoding._KeyBinding, NSKeyValueCoding._KeyBindingCreation, NSKeyValueCoding._MethodBinding, NSKeyValueCoding._NumberFieldBinding, NSKeyValueCoding._NumberMethodBinding, NSKeyValueCoding._ReflectionKeyBindingCreation, NSKeyValueCoding.ErrorHandling, NSKeyValueCoding.MapImplementation, NSKeyValueCoding.Null<T>, NSKeyValueCoding.UnknownKeyException, NSKeyValueCoding.ValueAccessor
NSValidation._MethodBinding, NSValidation._ValidationBinding, NSValidation.DefaultImplementation, NSValidation.Utility, 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
_CLASS
_CLASS, _KeyPathSeparatorChar, KeyPathSeparator
NullValue
_CLASS
Constructor and Description |
---|
AjaxModalDialog(WOContext context) |
Modifier and Type | Method and Description |
---|---|
protected String |
_containerID(WOContext context)
Returns the ID that represents this container for the purposes of Ajax updates.
|
static AjaxModalDialog |
_currentDialog(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()
If the dialog is open, calls the method bound to onClose (if any), and marks the dialog state as closed.
|
protected String |
closeDialogURL(WOContext context) |
protected NSMutableDictionary<String,String> |
createModalBoxOptions() |
protected String |
cssFileFrameworkName() |
protected String |
cssFileName() |
static AjaxModalDialog |
currentDialog(WOContext context) |
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).
|
static boolean |
isInDialog(WOContext context) |
boolean |
isOpen() |
static void |
open(WOContext context,
String id)
Call this method to have a JavaScript response returned that opens the modal dialog.
|
static void |
open(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(WOContext context) |
protected void |
popActionResultsFromContext(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(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(WOActionResults results,
WORequest request,
WOContext context) |
void |
setOpen(boolean open) |
protected boolean |
shouldHandleRequest(WORequest request,
WOContext context)
Removes Open_ElementID_Suffix or Close_ElementID_Suffix before evaluating senderID.
|
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,
String title)
Call this method to have a JavaScript response returned that updates the contents of the modal dialog.
|
static void |
update(WOContext context,
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(WOContext context)
public boolean synchronizesVariablesWithBindings()
synchronizesVariablesWithBindings
in class WOComponent
public boolean isOpen()
public void setOpen(boolean open)
public static void open(WOContext context, String id)
context
- the current WOContextid
- the HTML ID of the AjaxModalDialog to openpublic static void open(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(WOContext context)
context
- the current WOContextpublic static void update(WOContext context, String title)
context
- the current WOContexttitle
- optional new title for the updated dialogpublic static void update(WOContext context, WOComponent newContent, String title)
context
- the current WOContextnewContent
- the new content for the updated dialogtitle
- optional new title for the updated dialogpublic void setCurrentDialogInPageIfNecessary(WOActionResults results, WORequest request, WOContext context)
public static AjaxModalDialog _currentDialog(WOContext context)
context
- the current WOContextRuntimeException
- if no AjaxModalDialog is currently being processedpublic static AjaxModalDialog currentDialog(WOContext context)
context
- the current WOContextRuntimeException
- if no AjaxModalDialog is currently being processedpublic static boolean isInDialog(WOContext context)
context
- the current WOContextpublic void awake()
awake
in class WOComponent
WOComponent.awake()
public void takeValuesFromRequest(WORequest request, WOContext context)
public WOActionResults invokeAction(WORequest request, 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(WORequest request, WOContext context)
shouldHandleRequest
in class AjaxComponent
true
if this request is for this componentAjaxComponent.shouldHandleRequest(com.webobjects.appserver.WORequest, com.webobjects.appserver.WOContext)
public WOActionResults handleRequest(WORequest request, 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(WOResponse response, 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(WOResponse response, WOContext context)
response
- WOResponse to append tocontext
- WOContext of responseopenDialogFunctionName(String)
public void sleep()
sleep
in class WOComponent
WOComponent.sleep()
public void openDialog()
public void closeDialog()
! AjaxRequestHandler.AjaxRequestHandlerKey.equals(context().request().requestHandlerKey())
protected String _containerID(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(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(WOContext context)
context
- WOContext to push _actionResults intopopActionResultsFromContext(WOContext)
protected void popActionResultsFromContext(WOContext context)
context
- WOContext to restore previous component inpushActionResultsIntoContext(WOContext)
protected String openDialogURL(WOContext context)
context
- WOContext to create URL inCopyright © 2002 – 2024 Project Wonder.