APEX 3.2: Popup confirmation after page is submitted - oracle-apex

Working with APEX 3.2:
I want to show a confirmation popup on Page 2 when Page 1 has successfully been submitted.
Right now I can get the text from the 'Process Success Message' to appear on Page 2, but instead of the 'Process Success Message' text, I want an alert popup. Any idea how to do that?
NOTE: I don't want to put javascript on the 'Submit' button of Page 1, because if there is a validation error, the alert popup will appear anyway every time the 'Submit' button is clicked. I just want the popup to appear only if Page 1 has successfully submitted.

You could do this:
1) Edit the page template used by Page 2. Edit the Success Message subtemplate and put a span tag around the #SUCCESS_MESSAGE# placeholder like this:
<span id="successMessage">#SUCCESS_MESSAGE#</span>
2) Create some Javascript on Page 2 to run when the page is loaded that does this:
if ($x('successMessage')) alert ($x('successMessage').innerHTML);
The Success Message is only rendered if there is a success message to display, and so the alert will only happen when there is a success message to display also.
3) You could suppress the display of the success message on the page itself if you want by adding style="display:none" to the outer div of the Success Message subtemplate.
NB The template change will affect all pages that are based on it, not just Page 2, so you may need to take a copy of it first. You could include the Javascript in the page template so that you don't need to keep adding the same on load Javascript to each page.

Related

Oracle Apex How to display page item as url

I have a page item which stores URL.
How do i change its type to URL so that the link becomes clickable.
As of now, there is page subtype url, but setting it doesn't make any difference.
Apex 21.1
A text field is an html input element, that will display text only, you probably could write some javascript to open whatever is in the page item in an url but that is confusing functionality. What should happen if the user clicks in the input element ? Should it open the link or should the user be editing the value ?
This is a possibility.
Create a page item on your page, say P1_URL
Add the following in the "Post Text" attribute of the page item (style it to your own preference):
<span class="fa fa-external-link" aria-hidden="true"></span>
Add a dynamic action on change of the element P1_URL with a true action of "Execute Javascript Code" and the following code:
$("#myurl").attr("href", apex.item( "P13_URL" ).getValue())
Check "Fire on Initialization" for the true action.
That is all there is to it, now when you add something in the page item P1_URL and click the link, it will open the that url in a new window.
UPDATE: Technique for read only text field.
For a read only text field, the input element is hidden and an additional span element is rendered with an the page item name as id, suffixed by _DISPLAY. The trick is to grab the content of that span element and add an anchor with attributes. This can be done with an onload dynamic action:
Create a page item on your page, say P1_URL, set it to "Read-Only: Always"
Add a dynamic action on Page Load with a true action of "Execute Javascript Code" and the following code:
let itemVal = $("#P1_URL_DISPLAY").text()
$("#PP1_URL_DISPLAY").html(`<a href='${itemVal}' target='_blank'>${itemVal}</a>`)
Make sure that when you copy this, the quotes are exactly the same: the outer quotes are backticks, those are needed for the ES6 syntax.
Note: check the page documentation for the subtype url - it explains exactly what it does.

Having issues redirecting to another page on closing of modal dialog page

I have page 1 from which I open a modal dialog page - page 2. Now when I close the modal dialog, I want to be redirected to page 3. On page 2 I have a button that has a dynamic action defined where on button click two actions take pace: Page Submit (with an after submit branch out to page 3) and Close dialog. Once I click on the button, dialog closes but the user stays on page 1, not going to page 3.
If you have branch, you don't need to close dialog..
Another option is to travel through pages using PL/SQL-JS combination that redirects to URL after running code on server.
create a hidden, unprotected item called P2_TARGET
create a button with action defined by dynamic action,
add a dynamic action onClick for that button, with two true actions:
a. Execute PL/SQL code, submit P2_Item, return P2_TARGET
declare
js_code varchar(4000);
begin
js_code := REGEXP_REPLACE(
APEX_PAGE.GET_URL (
p_page => 3,
p_clear_cache => 3,
p_items => 'P3_Item',
p_values => :P2_Item
)
,'\,this\)'
,q'<,$('#p1Region'))>' -- jQuery of event source
);
apex_util.set_session_state('P2_TARGET', js_code);
end;
b. Execute Javascript code:
eval($v('P2_TARGET'));
and that's supposed to do the trick

Setting session variable on click

I've got a popup message with a close button at the top. If the user clicks the close button, they should never see the message again while on the site. If they don't click the close button, they will see it on the top of each page on the site.
When the user clicks the close button, I want to set request.session['promo'] to 0. On subsequent page loads on the site, if request.session['promo'] == 0, I will not show the popup message.
What is the best way of setting a session variable on click in django?
Thanks for the direction!
In HTML OnClick of button just call a function in views.py
Ex:
IN HTML :<Button onclick={% your_fucntion %}></button>
IN VIEWS.PY :
def your_fucntion(request):
request.session['promo'] == 'your_variable'
for getting variable :
promo = request.session['promo']

validation on button without refresh page on APEX5 5.0

Need your suggestions on handling the validation without submitting page in APEX 5.0. I have following items on my apex report page.
"Select list" item which contains some static values
date pickers ( start date and end date)
Submit button ( Once submit is clicked the report date is displayed )
Here I need to add a dynamic action or validation to the submit button so that if user clicks the submit button without selecting a value from the "Select List", an error message should be displayed to the user that he needs to select the item first from the "Select list" page item. With out any selection from the list , the processing should stop and a warning message should be displayed ( either it could be popup message or message can be marked on the select list page item ) .Point to be noted here that during the submit I do not want to refresh the page, just would like a quick error message to display.
Appreciate your help.
in a similar case i used dynamic actions
dynamic actions works on client side
in my case i am not enabling submit button until user changes the select list value
in my dynamic action my config is as below
Event=change
selection=items
item=selectlistID
and true action is
action=disable
button=submitbuttonname
in your case you can choose javascript as action and add your javascript code

Django: How do I position a page when using Django templates

I have a web page where the user enters some data and then clicks a submit button. I process the data and then use the same Django template to display the original data, the submit button, and the results. When I am using the Django template to display results, I would like the page to be automatically scrolled down to the part of the page where the results begin. This allows the user to scroll back up the page if she wants to change her original data and click submit again. Hopefully, there's some simple way of doing this that I can't see at the moment.
It should already work if you provide a fragment identifier in the action method of the form:
<form method="post" action="/your/url#results">
<!-- ... -->
</form>
and somewhere below the form, where you want to show the results:
<div id="results">
<!-- your results here -->
</div>
This should make the page jump to the <div> with ID results.
It is complete client site and does not involve Django, JavaScript or similar.
You need to wrap your data into something like this:
<div id="some-id">YOUR DATA TO BE DISPLAYED</div>
and if you make redirect in your view you need to redirect to url: /some-url/#some-id
if you don't make redirect you need to scroll to the bottom using javascript (but note that redirect is preffered way to use in view after saving data).