Refresh a region's items during/after apexrefresh - oracle-apex

I have a Report region that I am refreshing via jQuery. I have the following code with the region footer to set up the refresh process:
<script type="text/javascript">
var refreshId = setInterval(function(){ apex.jQuery('##REGION_ID#').trigger('apexrefresh');
}, 5000);
</script>
This works correctly, and the report data is refreshed every 5 seconds. However, the region also contains an Item, whose source value is determined via a SQL Query. I want this value to refresh every time the report region data refreshes too, but the triggered refresh doesn't do this.
Looking closer, it seems the report region div does not contain the Item HTML, so the part of the DOM that gets swapped out during the refresh does not contain the item. The item appears inside a sibling table node called apex_layout_#REGION_ID#:
<div class="rc-content-main">
<table id="apex_layout_7017903473906209" class="formlayout" border="0" summary="">
<div id="report_7017903473906209_catch">
<script type="text/javascript">
</div>
I've tried doing an additional .trigger() call passing in the Item's ID instead of #REGION_ID# but confusingly this does the exact same refresh of the report data. I've also tried setting up a Dynamic Action to fire on "After Refresh" on the region that will refresh the Item, but this does something strange too - it fires repeated AJAX calls with no delay and doesn't change the item value.
Any help appreciated.

You can't refresh an item using the apexrefresh event. You are on the right track with the dynamic action: you will need to 'manually' retrieve a new value.
Could you elaborate on how you have set up your "after refresh"-triggered dynamic action for your item? Does it have a true action of "set value" with "sql statement"? Did you inspect the ajax calls? Any errors? Do the calls keep repeating? Also, check the session state (access through the "session" button on the developer bar on the bottom) of the items, and see if the value there has changed.

Related

APEX - double click on interactive gird

Below is my interactive grid. It shows data from v$sql_monitor view based on sql_id from list .
What I would like to do is to create double-click dynamic action on a record. This action would open new modal dialog and pass two parameters : 1. sql_id from list above 2.sql_exec_id from clicked record. Would you give me a few hints how to do it ? I guess a piece of Javascript code will be necessary :(
There are multiple options to do this - here is one way, by using javascript custom events. I created a sample with an IG on the EMP/DEPT sample dataset with page 88 as IG and page 90 as modal. The column ENAME is a link to page 90 that sets a column value and a page item in the link.
Page 88 has an IG and 2 page items:
P88_PAGE_ITEM (a value entered on the page like the list in your screenshot)
P88_ENAME (to hold the selected report column value
Page 90 has 2 page items: P90_PAGE_ITEM and P90_REPORT_COLUMN
Create IG on page 90 on table EMP
On column ENAME, add the following under "JavaScript Initialization Code"
function(config) {
config.defaultGridColumnOptions = {
cellTemplate: '<button type="button" class="t-Button t-Button--link my-ename-js" data-ename="&ENAME.">&ENAME.</button>'
};
return config;
}
This is a button of type "display as link", created with the universal theme button builder that has 2 extra attributes: a class my-ename-js and a data attribute "ename" data-ename="&ENAME."
Create a dynamic action to capture the click and set the page item:
Make sure to set the scope to "Dynamic". This is needed because the event listener needs to be added again after a dom change (a search or filter of the IG).
add a true action of type "Set Value" to set the value of P88_ENAME to the value of the selected row
add a second true action to trigger a custom javascript event:
Create a dynamic action of type "Event: Custom" to capture the custom event triggered in the previous DA.
add a true action of type "Submit Page". Note that "Show Processing" needs to be unchecked.
Almost there. One last thing is to create a branch to the modal page:
Create a branch (process point "After Processing") with server-side condition of "Request = Value" with value OPENMODAL and link attributes below:
And this should be the result:
Well, I modified a bit your scenario.
I added new SelectList P88_FILTER
and added dynamic action ON_CHANGE :
with action
I modified source if IG:
These changes allowes me to filter IG . In our case filter returns always only one record like below.
and now my problem begins. In your scenario clicking the link "ename" updates field P88_ENAME and opens modal dialog with proper values. After my modification neither P88_ENAME updates nor modal dialog opens :(

Not able to make the navbar items dynamic in ember

I have navbar component which I have placed in an application.hbs so that it should be visible always.But I want to change the title of the navbar with each page I visit ( say I am on index page it should say "Home" , if I am on profile page it should say profile,etc).Right now what is happening is navbar title always remains "Home" for all the page.This is happening because the navbar gets rendered onlu during the time it loads the page in browser and after that it doesn't change according to page.
application.hbs
{{top-navbar dp_url=model.profile.dp_url first_name=model.profile.first_name title=title}}
{{outlet}}
Here the I am computing the value of title depending upon which page the user is.
application.js(controller)
if (currentPage === "" || currentPage === "#"){
currentState.set('title',"Home")
}
else if(currentPage === "Userprofile"){
console.log('myStudio');
currentState.set('title',"UserProfile");
}
In here the currentpage has the current url of app and I am comparing it and deciding the value of title for navbar.
But the top-navbar title value gets calculated only for the first time when user load the app in browser and not when I move ffrom one route to another.
I have also tried the Ember.Evented but not able to solve it.
I don't know what Ember.js and Ember-data version are you using, currentState is deprecated since 2.1, anyway looks like you're using a private method intended for Ember internals and not meant to be used in an application.
A possible (but maybe unnecessary complicated) way to accomplish what you want is:
Create a model with the information you want to mutate in the navbar (e.g. navbar-data).
In the route where the navbar is rendered, create and return a record for it using a fixed numeric ID (e.g. store.createRecord('navbar-data', { id: 1, title: "index" })).
Pass the created record to the component (instead of just a string).
Whenever you want to change, peek the record with store.peekRecord('navbar-data', 1) and change the value you want to change in the navbar.
Of course, the record you use for that must not be saved with record.save().

Foundation Reveal Modal and HTML5 history API manipulation

I am trying to solve an issue with modals. What I want to do is allow the user to click the browser's back button to dismiss a modal and return to the original state of the page, this is: without modal. For such purpose I thought about using HTML 5 history API.
I started trying to append a querystring parameter to the URL, such as http://...page.html?show_modal=[yes|no] but I ended leaving this approach because I couldn't handle all the stuff involving popstate event, pageshow event, etc. I couldn't make it work and it overwhelmed me.
Then I tried with a more simple approach involving a hash appended to the URL, such as http://...page.html#modal, and the hashchange event. This approach is working better for me and I almost have it.
When the user clicks the button to show the modal, he or she can click the browser's back button and it will dismiss the modal. Furthermore, after that, the user can click the browser's forward button and it will show the modal again. Very nice! The user can also navigate directly to the URL with the hash to access directly this state of the page, as well as he or she can bookmark such state of the page. It's working pretty neat and I'm rather happy with the results.
The problem is that it is not working totally perfect. When the user dismiss the modal by clicking the background, the ESC key or the X in the upper right corner, the history starts to mess up. Try it: open the modal by clicking on the button, then click the background to dismiss it (look a the URL in the address bar, first problem here is that the hash isn't removed), then click your browser back button and you will see it isn't working correctly. You will end with a duplicate in your history and you have to click the back button twice in order to go to the previous page. This is not desirable from an UX viewpoint. Does anyone know a solution to this?
I provide my code in this CodePen and at the end of this question. I suggest trying it in your own machine and NOT IN Codepen, so you can view the hash in the URL, etc. Also, it doesn't work in Codepen Full mode, I don't know why.
Thanks!!
I am using Foundation 5.2.1
HTML
<div class="row">
<div class="small-12 columns">
<h1>Reveal Modal</h1>
<h2>Manipulation of the browser history for a better UX</h2>
<a class="button radius" href="#" data-reveal-id="sampleModal" id="button">Show Modal...</a>
</div>
</div>
<!-- ############# -->
<!-- MODAL -->
<!-- ############# -->
<div id="sampleModal" class="reveal-modal medium" data-reveal>
<h2>Hi!</h2>
<p>You may think you are on a new page now, but you aren't. Try to click your browser <kbd>Back</kbd> button to dismiss this modal and return to the the page you were viewing.</p>
<a class="close-reveal-modal">×</a>
</div>
JavaScript
function setModalHash(url, present) {
var a = $('<a>', { href:url } )[0]; // http://tutorialzine.com/2013/07/quick-tip-parse-urls/
var newHash = "";
if (present === true) {
newHash = "#modal";
}
// Build the resulting URL
result = a.protocol + "//" + a.hostname + ":" + a.port + a.pathname + a.search + newHash;
return result;
}
$("#button").on('click', function() {
history.pushState(null, null, setModalHash(document.URL, true));
});
$(window).on("hashchange load",function(e) {
// Handling also the load event allows navigation directly to http://host/path/to/file#modal and bookmarking it
if (document.location.hash == "#modal") {
$("#sampleModal").foundation("reveal","open");
}
else {
$("#sampleModal").foundation("reveal","close");
}
});
I've been messing with the history api/History.js in combination with session storage to maintain modal state, and open/close based upon user navigation. I've finally achieved about 90% of my goal, but history is implemented very poorly in Safari and iOS Safari so remove the features for these browsers.
Some of the problems you may be running into with the hash approach is that when you use the # with pushstate it actually doesn't push a new object into the history state. It sometimes seems to push history onto the stack and you could use history.back() to fire a popstate, but if you were to say refresh the page with your hashurl and do some sort of check for hash on page initiation, there doesn't seem to be a new history pushed onto the stack, and therefore on backwards navigation the user will leave the site rather than closing the modal.
Here is my implementation working for all browsers except for where it falls back to normal behavior is Safari:
http://dtothefp.github.io/hosted_modal_history_sample/
https://github.com/dtothefp/html5history_express_modal_toggle
Like I said I use History.js in combination with sessionstorage because annoyingly enough, in the popstate for closing the modal the history object is removed, which is exactly when I would need it. In all a very poorly implemented API.
I don't change the URL because this project does not have a backend, so if I change the URL with no hash, on page refresh the page would not be found. An alternate implementation would be a query string, which will properly update history when used in the pushstate, but ends up being bad UX because if the user closes the modal not using the backwards navigation (i.e. hitting the cancel button or clicking off), removing the query string would result in a page refresh.

Calling jQuery on Oracle Apex IRR partial page refresh

Based on another question I have asked:
How to Remove <a href> Link Tag for a Specific Value using Jquery
where I need to remove the a href tag if the value is 'N'.
All works fine on first load, but since I am using an Oracle ApEx Interactive Report (IRR) and perform a partial page refresh, the solution from my other thread doesn't fire again and so all my values that have a value of 'N' now have a link below it which is not want I want.
Within an IRR, is there a means of firing jQuery code, like on load when the report is partially refreshed, based on column filtering?
Sure is.
With dynamic action: After Refresh
Triggering region: select your IR region
True action: execute javascript code
$('a', this.triggeringElement).filter(function(){
return this.innerHTML === 'N';
}).replaceWith('N');
Or just javascript code
$("#ir_region_id").bind("apexafterrefresh", function(){
$('a', this).filter(function(){
return this.innerHTML === 'N';
}).replaceWith('N');
});
Although you might want to restrict your "a" selector to your actual link column. If you don't, every link in the IR region is selected. It's unnecessary.
$('td[headers="my_link_column"] a')

Add a dynamic action to a report when next button is pressed

How can i execute a dynamic action when i click in the button of a report to change to another page of vale ?
First, change the report template so that it assigns an ID to the next and previous buttons. For example:
Next Page Template:
-------------------
<a href="#LINK#" class="t20pagination" id="#REGION_STATIC_ID#next">
#PAGINATION_NEXT# ></a>
Previous Page Template:
-----------------------
<a href="#LINK#" class="t20pagination" id="#REGION_STATIC_ID#previous">
<#PAGINATION_PREVIOUS#</a>
Then give your report region a Static ID e.g. 'MYREP'. The next and previous links will then have IDs 'MYREPnext' and 'MYREPprevious'.
You can now create dynamic actions referencing those IDs as DOM objects or jQuery selectors.
Be sure to set the dynamic action's Event Scope to "live" so that the actions still work after the report has been refreshed due to pagination.