How to close window in apex builder on clicking a button - oracle-apex

I have an apex page where I have a button "SAVE & CLOSE" . On click of that button, I first want to save the data and then close the page.
I have a PLSQL code at point "Processing" to save the data.
I have then created a Branch at Point = "After Processing" and Type ="PLSQL Procedure" and written below code to close the window.
Begin
htp.p('<script type="text/javascript" >');
htp.p('window.close();');
htp.p('</script>');
end;
I have added the button's name in server side condition : When button Pressed.
But this doesn't work. When I click on apply, it doesn't close the window. It gives me an error :
"Error: SyntaxError: Unexpected token < in JSON at position 0 "
Can you please help me resolve this error and tell how can I close the window in button click.
Thanks,
Abha

You can use only APEX components and not write a single line of code :)
Set action for your button to "Submit page" - so all items will be submitted to use their values in processing. Image below will help you.
Now, for processing your pl/sql code use process in processing(left side on the picture).
Here you can create a new process and set type to "Close dialog" this process will automatically close the window. Without any javascript etc.. Apex is processing from top to bottom, so if you make this process last, it will always close the window after all processes are done.
You can as well set process server side condition, so it will not trigger every time.
Be careful with javascript - some web browsers are processing them in different way.
Hope it will help. Have a nice day !

Hi I got it working with other method :
Instead of type : PLSQL Procedure" select Type = "Page or URL Redirect"
and give
javascript:window.close()
in the Target.
This works.

What I did was make the page Modal. Then I added a Button called btnClosePage with a Dynamic Action (True Event) that calls "Close Dialog". I am working in Oracle Apex 20.2.

Related

How can I Close a popup window, after execute Update SQL. (Oracle APEX 21.1)

I created a pop-up page. That pop-up window has a radio button, a text box, and an execute button. I want to work that page working like... when pressing the button, run a update SQL with the values of the radio button and text box, and close itself.
I tried that answer in the following link. But the pop-up page just reloaded and the page stayed open. How to close popup window in Oracle-apex?
If possible, I would like to validate the value of the text box. If it was an incorrect value then break the process with a message. If path that validation, run a update SQL and close the pop-up window.
Thank you for your kindness for read this confusing question.
You should be using a "Close Dialog" process type after your Save Process.
Make sure that you also set the server side condition accordingly so that the dialog only closes after your save process.
I GOT RESOLVED IT!
Not use any close method, redirect util is fine work like this APEX_UTIL.REDIRECT_URL (APEX_PAGE.GET_URL(p_page => 7));
Thank you to all ppl for look this page :)

How know the modal dialog closed?

I am using APEX 21.1. I have a page with interactive report. It's default link opens a modal dialog page. And I added two columns of type Link to it's query. For example,
select deptno, dname, loc, 'Open Examination Dialog' as examination_dialog, 'Open followup dialog' as followup_dialog from dept;
I need to open a page in a new tab and send it parameters when examination dialog is closed. And do the same but with different parameters when followup dialog is closed. So, I need to know which dialog is closed and based on that execute a javaScript dynamic action with code like
apex.navigation.openInNewWindow();
I tried setting static id's for examination dialog column and followup dialog and created 2 dynamic actions of type "dialog closed" and set the columns' static id's as the jQuery selector which called the dialog page. But nothing happens.
Can I know which dialog is closed and execute a dynamic action based on that?
Here is a simulation...
ws=ESLAM_WS
un= forhelp
pwd=Forhelppwd$
app=TEST2_FOR_ME
pages= 2 and 6
The IR in page 2 has a column(Link) called "open dialog". It should open page 6 which is a modal. Page 2 has a "Dialog Closed" dynamic action that should display an alert when the dialog is closed. But the dynamic action does not fire. There should be another column that opens another modal dialog which when closing too, I need to execute another dynamic action, for example, another alert.
Create 2 dynamic actions, one for each dialog page. Add this javascript expression as client side condition for the dynamic action (In addition to the standard On Dialog Closed) that should fire when page 6 is closed:
this.data && this.data.dialogPageId && this.data.dialogPageId == 6
Do the same for the 2nd dynamic action but the appropriate value for this.data.dialogPageId
In the dynamic action javascript, the this refers to the triggeringelement. Best way to look into this yourself is to execute javascript in a dynamic action true action (just for developing)
console.log(this);
You'll notice that there is an attribute dialogPageId in the data with the value of the closed window. So this condition will yield true if the dynamic action was fired on close of that specific page.

on-screen calculation with DA

when
:p1_radio_button_1
:p1_radio_button_2
:p1_radio_button_3
change,
dynamic actions fired to set values on
:p1_score_1
:p1_score_2
:p1_score_3
with simple math such as (:p1_lov_1's return value) * (a constant from global page) /100
and these changes on :p1_score_x fires another DA to do some other simple calculations.
eventually I am expecting a weighted_score to be calculated.
**
mechanically, it works. but when I click radio buttons a couple of times one after another, calculation goes crazy.
I believe my approach is wrong. What would you suggest? Should I submit the page after each radio button clicks?
Thanks in advance.
APEX version 18.x
browser Firefox
OS windows
I think chained dynamic actions are not the best idea. I changed the behaviour a little:
placed a dummyButton
hide realButton on page load
redirected dummyButton to page inline dialog saying to end user "please click calcButton"
show realButton when calcButton clicked
hide dummyButton when calcButton clicked
hide realButton & show dummyButton if anything changes on radioButtons
I wasn't sure if I should delete the post or reply it. admins; please delete if it somehow against the community rules.
thank you very much

asp repeater itemcommand not working on second click

I have a repeater which I bind the data using Bind method from the database. There is a Asp:Button with an onclientclick and onclick event. In OnClientClick I open a new window and onclick I am adding the data to the database. This works perfectly on the first Page load. After first click on any of the buttons in the repeater, the click events stops working on subsequent clicks.
I have spending hours on finding a solution for the same, can any one guide me where i am going wrong what needs to be done.
P.S: My application is AJAX Enabled , using WCF and JQUERY
Thanks & Regards,
Phani...
Never Mind I got it solved my self. For others who are trying to solve the same issue, here is the solution:
The code below opens up a new window with out popup blocker blocking the window
OnClientClick of the button write Javascript like below to open a new window and refresh the parent window (I have to do this as the ItemCommand event was not firing until the page is refreshed)
OnClientClick = "target='_blank'; setTimeout("location.reload(true);", timeout);
Phani...

Appcelerator. Options dialog is opening several times when refreshing table

Titanium SDK version: 1.7.0.RC1
iPhone SDK version: 4.2
I am developing an iOS app in Appcelerator. I am retrieving tweets from twitter and inserting them into a table. For each row/tweet I am also extracting the containing links for that individual tweet/row and the user can select them from an options dialog which is opened when the row is clicked.
The problem is that if I reload the page and click the row, two dialogs are open upon each other. If I click three times, three dialogs is opened and so on. How can I make sure that the dialog only opens once?
This is my code: http://pastie.org/2004091
Thankful for all help!
I had a similar problem. Especially on the iPhone 3G as this runs slowly and you're more tempted to tap things more than once. The way I got around it is to either remove the event listener from within the event listener itself. Or you set a variable and test for its value in the event listener. So, if you set a variable call 'clicked' to false. When the listener is first check for 'clicked' = false, if it is set it to true so next time the code is not executed.