• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Calling AjaxModalDialog programmatically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Calling AjaxModalDialog programmatically


  • Subject: Re: Calling AjaxModalDialog programmatically
  • From: Roger Perryman <email@hidden>
  • Date: Tue, 25 Feb 2014 16:38:33 -0500


On Feb 25, 2014, at 12:57 AM, Chuck Hill wrote:

Hi Roger,


On 2/21/2014, 9:29 AM, "Roger Perryman" wrote:

Thanks Chuck. I'm using the first option but it is not quite working as desired although it is close.  open() is a static method so I placed the call inside a method on my page. Then I conditionally call open or do nothing as needed.

When I call it from a WOHyperlink or WOSubmitButton, I get the _javascript_ as plain text replacing the page contents. This is not a surprise so I changed to the Ajax equivalents. (that may have been part of the original problem) These launch the dialog properly. The action handlers for the dialog use AjaxModalDialog.close( context()) to dismiss the dialog. 

Yes, you can’t mix and match the normal controls and the Ajax ones.

I mentioned that mostly for other people finding this thread. The original page had elements that were not using Ajax so it didn't work until I changed them. Pretty obvious in hindsight.


The AlertPopup basically presents a message where you answer yes or no. The calling page should handle the flow once the dialog is dismissed. How do I accomplish this? The next page may require additional data that the AlertPop up shouldn't have to deal with. onClose discards the return results. I also tried onCloseBeforeUpdate but that didn't seem to get called. Is there a similar hook? I didn't see one in the source.

Not sure, but I think this is what you are looking for:

     * Ajax action method for closing the NotificationDialog about the purge being initiated.
     * Changes to Search mode and refreshes page.
     */
    public void searchAgain()
    {
        logger.info("Purge acknowleged");
        goToSearchMode();
        didPurge = false;
        AjaxUtils.redirectTo(context().page());
    }

Yes, I think this is what I am looking for.

Thanks Chuck

Chuck



I am showing the relevant code here.

Main Page:

alertDialog: AjaxModalDialog
{
id = "alertDialogID";
autoFocusing = false;
centerVertically = true;
locked = true;
transitions = false;
label = "Warning! Unsaved changes";// Text of link
title = "Warning! Unsaved changes";// Text of Dialog
closeValue = "x";
showOpener = true;// false may be OK since no direct link
width = 600;
height = 500;
action = alertHandler;
onOpen = onOpen;
onClose = onClose;
onCloseBeforeUpdate=onCloseBeforeUpdate;
}

public WOActionResults launchAlertDialog()
{
boolean isPageDirty = determineIfDirty();
if ( isPageDirty )
AjaxModalDialog.open( context(), "alertDialogID" );

returnnull;
}

public WOActionResults onOpen()
{
log.debug( "onOpen called" );
returnnull;// ignored
}

public WOActionResults onClose()
{
log.debug( "onClose called" );
return null;// ignored
}

public Boolean onCloseBeforeUpdate()
{
log.debug( "onCloseBeforeUpdate called" );
returntrue;
}

public WOActionResults alertHandler()
{
AlertPopup nextPage = pageWithName( AlertPopup.class );
nextPage.setAlertParent( this );
return nextPage;
}

public WOActionResults cancel()
{
WOComponent nextPage = null;
boolean isPageValid = false;

if ( !isPageValid )
launchAlertDialog();

else { * * * }

return nextPage;
}

/* NOTE: MUST use AjaxSubmitButton or AjaxHyperlink. WOSubmitButton or WOHyperlink wont work */
cancel: AjaxSubmitButton
{
value = "Cancel";
action = cancel;
}

AlertPopup page:

/* I used a Form but had similar results with AjaxHyperlink */
alertForm: ERXWOForm
{
id = "alertForm";
multipleSubmit = true;
embedded = true;
}

no: AjaxSubmitButton
{
action = noAction;
value = "No";
}

yes: AjaxSubmitButton
{
action = yesAction;
value = "Yes";
}

public WOActionResults yesAction()
{
_alertParent.takeValueForKey( Boolean.TRUE, "alertResult" );
AjaxModalDialog.close( context() );
return null;
}

public WOActionResults noAction()
{
_alertParent.takeValueForKey( Boolean.FALSE, "alertResult" );
AjaxModalDialog.close( context() );
returnnull;
}


On Feb 19, 2014, at 6:32 PM, Chuck Hill wrote:

One of these from Java:

/**
*Call thismethod tohave a _javascript_ responsereturned thatopens themodal dialog.
*The titleof the dialog will be what itwas when rendered.
*
*@param context the current WOContext
*@param id the HTMLID of the AjaxModalDialogto open
*/
publicstatic void open(WOContext context, String id) {
AjaxUtils._javascript_Response(openDialogFunctionName(id) + "();", context);
}

/**
*Call thismethod tohave a _javascript_ responsereturned thatopens themodal dialog.
*The titleof the dialog will be the passedtitle.  Thisis usefulif the script to
*open thisdialog wasrendered withoutthe titleor with an incorrect title.
*
*@param context the current WOContext
*@param id the HTMLID of the AjaxModalDialogto open
*@param title the title for the AjaxModalDialog
*/
publicstatic void open(WOContext context, String id, String title) {
AjaxUtils._javascript_Response(openDialogFunctionName(id) + "(" + AjaxValue._javascript_Escaped(title) + ");", context);
}


Chuck


On 2/19/2014, 3:19 PM, "Roger Perryman" wrote:

Hi.

What is the correct way to open an AjaxModalDialog programmatically after evaluating some criteria? I know that I can call it via _javascript_ using openAMD_<ID>(). But that isn't exactly what I'm looking for. Since I need to evaluate what they have done first, I guess I would need to update the page in order to trigger the action to open the dialog? It also closes the current window and processes the action binding. I want to be able to present a warning message when the user presses a button/hyperlink (such as cancel) and there are changes pending. They can then choose to return to the page or continue and discard any changes. I have other similar situations where the user should be alerted to the consequences of their actions and given a chance to correct, ignore or take another action.

Any help would be appreciated!

Thanks,

Roger



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Calling AjaxModalDialog programmatically (From: Roger Perryman <email@hidden>)
 >Re: Calling AjaxModalDialog programmatically (From: Chuck Hill <email@hidden>)
 >Re: Calling AjaxModalDialog programmatically (From: Roger Perryman <email@hidden>)
 >Re: Calling AjaxModalDialog programmatically (From: Chuck Hill <email@hidden>)

  • Prev by Date: Re: Ponder docs or examples
  • Next by Date: Re: Ponder docs or examples
  • Previous by thread: Re: Calling AjaxModalDialog programmatically
  • Next by thread: Re: Calling AjaxModalDialog programmatically
  • Index(es):
    • Date
    • Thread