operation based on alert box - flex3

is it any possible to create operation based on the alert box(like yes or no option)?
Thank's in advance...

Are you just trying to fire off a function based on the users decision? If so there is a closeHandler as part of the Alert.show constructor that you can tell it what function to run when the alert box closes.
Alert.show("My Message", "Alert Box Title", (Alert.YES | Alert.NO), null, alertCloseHandler);
private function alertCloseHandler(event:CloseEvent){
if(event.detail == Alert.YES){
//code if they clicked yes
}
}

Related

Vue: Why is my dialog not showing up when the right condition is set?

EDIT: I answered my own question. I don't know how to mark this as resolved, since SO doesn't allow me to vote my own answer right now. Thanks everyone.
I am trying to create a confirmation box (asking to remove a layout) in which the user has to press confirm or cancel - confirm means 'yes, remove the layout and close the confirmation box', cancel means 'just close the box'.
The confirmation box opens when a user presses RemoveButton - this means that RemoveButton doesn't do the job of "removing" until confirm is pressed. Clicking the RemoveButton should make the dialog to show up.
The problem is the my dialog is not showing up. I ran Chrome dev tool and made sure that setShowRemoveLayoutDialog(true) is working, but removeLayoutDialog is not opening. Even when I set a dev tool breakpoint on public removeLayout(layoutName: string), the dev tool could never reach it.
Can anyone tell me what I am doing wrong?
(We don't have to talk about CSS here since it is already built by my other teammates)
(I cannot do .confirm(confirm message) because it will trigger a no-alert error for lint. So I have to insert it into template and make a div or element for that).
Thank you!
This is my Vue/html template:
<RemoveButton #press="setShowRemoveLayoutDialog(true)">
<removeLayoutDialog v-if="showRemoveLayoutDialog"
:layout-name="props.node.name"
#confirm="removeLayout"
#cancel="setShowRemoveLayoutDialog(false)"/>
</RemoveButton>
This is my <script>:
#Component({
removeLayoutDialog,
...
})
export default class ThisClass {
...
public showRemoveLayoutDialog = false;
public removeLayout(layoutName: string) {
this.doRemoveLayout(layoutName);
this.showRemoveLayoutDialog = false;
}
public setShowRemoveLayoutDialog(isShown: boolean) {
this.showRemoveLayoutDialog = isShown;
}
}
I realized that having the dialog inside the button was the problem.
Instead of having <button ... <dialog></dialog> </button>, having <button><dialog> solved the problem.

saveAs is not a function

I have a button in acrobat form with below script in the Mouse Down.
try
{
app.saveAs("/c/temp/11.pdf");
}
catch(err)
{
app.alert(err.message);
}
when I click on the button I get message box says
app.saveAs is not a function.
What is wrong?
You want doc.saveAs() See tutorial: https://acrobatusers.com/tutorials/how-save-pdf-acrobat-javascript

IBM Worklight 6.2 - adding text input in WL.SimpleDialog

I know by adding WL.SimpleDialog.show i can show a native style dialog/alert box with buttons. But is it possible to show the same with a textbox and yes and no buttons.
You cannot achieve that with WL.SimpleDialog. However, if by "textbox" you mean a dialog with an input field in it, better known as a Prompt, then you could follow my example in the following question: IBM Worklight 6.1 - How to display a prompt dialog?
The code in your case could be like this:
navigator.notification.prompt(
'Replace me', // message
onPrompt, // callback to invoke
'myPrompt', // title
['Yes','No'], // buttonLabels
'My default text' // defaultText
);
}
function onPrompt() {
alert("prompted");
}

How to switch back to main window after handling alert in Selenium Web Driver

I have to write a selenium automation test script , where test has to create a template that fills up Generalize data in form and enter specific details manually(trying to wait here till manual entry is finished) and then click on SAVE button. However if some of mandatory field is left the system shows JavaScript's validation alert. I am handling this alert by using
Alert alert = driver.switchTo().alert();
alert.accept();
After this I want to get back to main page and wait for several minutes to write the description for missing fields and now click on SAVE button.
How can I achive this in Selenium web driver?
when you deal with alerts firstly you have to check whether alert is present. I would use this approach:
public boolean isAlertPresent() {
boolean presentFlag = false;
try {
// Check the presence of alert
Alert alert = driver.switchTo().alert();
// Alert present; set the flag
presentFlag = true;
// if present consume the alert
alert.accept();
} catch (NoAlertPresentException ex) {
// Alert not present
ex.printStackTrace();
}
return presentFlag;
for more in click here, Also do not forget about debug step by step to get to know on what step alert appears/not appears. Hope this helps you.
You can go to the alert window from parent window using switchTo() method:
<html>
Alert alrt = driver.switchTo().alert(); // Switching the control to Alert window
alrt.accept(); // to accept Yes to delete the task
//alrt.dismiss();
// to dismiss the action - once you click on YES, of course you don't have option to dismiss
</html>
Now, answering to your question -
once you select any option from the Alert window (say - YES/NO), the control automatically comes back to the parent or main window. And you know what, the same follows in Hidden divs too.The switching back to parent window comes into picture when it is a question of HTML Pop ups.
Hope this helps.
After Accepting Alert box. we want to Switch to main window by geting the window handle details.
//Stores the handle details
String windowHandle=driver.getWindowHandles();
//Alert portion
Alert alert = driver.switchTo().alert();
alert.accept();
//After switching back to main window..
driver.navigate.windows(windowHandle);
//It takes to the main window....
You can give a try on the following code:
driver.navigate.back();

how to prevent window from closing on ESC extjs 4

I am stuck with one problem with one problem in stop the window from closing using ESC button.
The window gets closed as soon as I click the ESC button from my keyboard. I want the window should not close, instead it should prompt a message box asking 'YOU REALLY WANTS TO close' with two button yes or cancel
If person click yes button the the window should destroy and else the window should be as it is.
but don't know why the window is getting close on ESC press.
I am prompting message as the user click the esc button using below code
listeners: {
show : function(win) {
Ext.create('Ext.util.KeyNav', win.getEl(), {
"esc" : function(e){
alert('hi.. closing');
win.hide();
},
scope: win
});
}
}
now I want the message box to be appeared and based on the person answer things to be happend.
any help ??
There is very convenient onEsc function in window's config. Use it this way:
onEsc: function() {
var me = this;
Ext.Msg.confirm(
'Closing confirmation',
'YOU REALLY WANTS TO close',
function(btn) {
if (btn === 'yes')
me.hide();
}
);
},
Here is live example.
Try using the beforeclose event.