Mailing List webobjects-dev@wocommunity.org Message #146
From: Markus Ruggiero (rucotec) <webobjects-dev@wocommunity.org>
Subject: Re: [WO-DEV] Mixup of AjaxModalDialog and AjaxUpateContainer on underlying page
Date: Sat, 17 Apr 2021 10:07:36 +0200
To: WebObjects & WOnder Development <webobjects-dev@wocommunity.org>
Signed Data (Text SHA256)
Folks,

it was a bad night I had and an even worse dream - but as it sometimes happen I dreamed up the solution - and the keyword was WOContext!

Instead of calling pageWithName() to instantiate the HTML mail contents component (which instantiates it with the current WOContext) I now call ERXApplication.instantiatePage(). This creates a fake WOContext for the page and so its output will not make it into the current context’s response.

After fixing a small typo in the bindings of the update container everything is now fine.

Typo:
myUC : AjaxUpdateContainer { id = “REMOTE_REQUEST_UPDATE_CONTAINER_ID”; }
Of course there should not be double quotes as REMOTE_REQUEST_UPDATE_CONTAINER_ID is a final String constant in the Java file. Thus the update container was never found and so no update happened.

I trigger the update container with the AjaxModalDialog binding 
closeUpdateContainerID = REMOTE_REQUEST_UPDATE_CONTAINER_ID;

Sometimes a bad night’s sleep helps wonders (Wonder? where did I see that word that lately?)

---markus---


On 16 Apr 2021, at 17:51, Markus Ruggiero (rucotec) <webobjects-dev@wocommunity.org> wrote:

Folks,

I am fighting with the following issue:

AjaxTabbedPabelTab contains a list of items (WORepetition).
Any such item can have an AjaxModalDialogOpener to open an edit dialog for that particular item.
The edit dialog has a save button whose action in Java looks like the following

public WOActionResults resendRemoteRequest() {

// preparation and stuff

// compose and send out mail
EmailRequestingRemoteSignatureAndPayment mailComponent = pageWithName(EmailRequestingRemoteSignatureAndPayment.class);

mailComponent.setLink(url);
// more mailComponent.set(...)
try {
ERMailDeliveryHTML message = new ERMailDeliveryHTML();
message.setComponent(mailComponent);
message.setSubject("Please sign your contract with " + companyName);
message.setToAddress(availableEmailAddressesLoopvar.emailAddress());
message.setFromAddress(application().notificationSenderEmail());
message.sendMail();
}
catch (Exception ex) {
log.error("Error sending notification Email: " + ex.getMessage());
ex.printStackTrace();
dialogErrorMessage = "Failed to send Email";
AjaxModalDialog.update(context(), "ERROR - Could not send Email");
return null;
}

// everything is fine, let's save things
ec.saveChanges();

AjaxUpdateContainer.updateContainerID(REMOTE_REQUEST_UPDATE_CONTAINER_ID);
AjaxModalDialog.close(context());
return null;
}

Unfortunately I get very weird behavior...

Code written above returning both trigger for update and trigger to close dialog:
Dialog does not close and is dead in the water. No update happens, I have to manually reload the page in the browser. Then everything is fine.

Using updateContainerId binding on the AjaxSubmitButton that calls the above action and no call to trigger update from Java :
Dialog closes but the mail message text is pasted into the browser window! WHAT?! And no update happens (no data is reloaded)

No update container at all:
dialog closes properly, but nothing updates (of course)

What is going on here? How should I handle this stuff? I was thinking of returning a WORedirect, but how do I get the proper URL?

Thoroughly confused!
---markus---





Markus Ruggiero


rucotec GmbH                        web https://rucotec.ch
Steinenvorstadt 79                email markus.ruggiero@rucotec.ch
4051 Basel / Switzerland         mobile +41 79 508 4701








Content Unaltered as verified By:
<markus.ruggiero@rucotec.ch>
Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster