Oracle APEX Region auto refresh internal error - oracle

I am new to oracle apex. When trying to do the region auto refresh in APEX, as several docs suggested, I used the below method:
<script type="text/javascript">
setInterval("jQuery('#STATIC_REGION_ID').trigger('apexrefresh');", 5000);
</script>
Everything worked fine but after quite a long period time (maybe SSO timeout) there are pop-up windows said "internal error".
Can anyone give me a hand for this? Or how can i check the server log to see more details for this internal error?
Thanks so much!

The approach that I use, is to create a dynamic action to refresh the region (or classic report) which is fired by a custom event.
First we need to create de dynamic action, and defined it like this:
Here we're setting the conditions on which the dynamic action will be fired. In this case it will be fired by a custom event triggered from the document itself.
Then we define the action to be ejecuted in this case a refresh:
And finally we select the type of element to be refreshed, in this case a region and then from the drop down list select the actual region.
Once the dynamic action is created all we need to do is fire the event, in javascript this can be done with this code:
function callMe(){
$.event.trigger('theEvent'); /*Note that the event name is case sensitive*/
}
That will be all, I use this method to refresh mostly classic reports but it can be used in several situations. Given your description of the problem, it's possible that the 'apexrefresh' event does not handle all the nuances of refreshing a region (and the connections involved), that's why I'd recommend to let apex do it entirely with this method.

Related

Send notifications from one laravel app to another

I have two different Laravel 5.4 apps, a restaurant menu system to recieve and manage orders, and one website from where customer can place their orders. Both apps run on different server(localy), which means, in my (windows)system I can run only one app at a time(localhost:8000). Both are using the same database tables. My question is how can I notify the restaurant menu system when user places an order from the website i.e., adding new row to Orders table in db? I need a notification as well as auto generate new row in the table like here:
Restaurant Menu System . I have tried doing it with JQuery Ajax, but failed as there is nothing to trigger the ajax function in order page. Tried JQuery setInterval() from here but it seems like a very inefficient way and also gives an error of Uncaught SyntaxError: Invalid or unexpected token. I want to be as smooth as Facebook notifications. Is there any package or trick to do it?
The website looks just like any other ecommerce website with a cart and checkout system from where user can pay and place orders. Any leads is appreciated.
You have two options that I can think of.
One is a technique called comet which I believe Facebook uses or at least used at one point. It basically opens an ajax connection with your server and your server will occasionally check to see if there are any changes, in your case new orders, and when there is, will respond to the request appropriately. A very basic version of what that might look like is...
while (true) {
$order = Order::where('new', 1)->first();
if ($order !== null) {
$order->new = 0;
$order->save();
return $order;
}
sleep(5); // However long you want it to sleep for each time it checks
}
When you open up an ajax connection to this, it's just going to wait for the server to respond. When an order is made and the server finally does respond, your ajax function will get a response and you will need to do two things.
Show the order and do whatever other processing you want to do on it
Re-open the connection which will start the waiting process again
The disadvantage to this approach is it's still basically the setInterval approach except you've moved that logic to the server. It is more efficient this way because the biggest issue is it's just a single request instead of many so maybe not a big deal. The advantage is it's really easy.
The second way is a little bit more work I think but it would be even more efficient.
https://laravel.com/docs/5.4/broadcasting
You'd probably have to setup an event on your orders table so whenever anything is created there, it would use broadcasting to reach out to whatever javascript code you have setup to manage that.

Triggering Ajax event when an object changes its state

I have a small university project in which I have to show how certain algorithms work. Decided to use JSF for a simple webapp and save all the algorithm generated data into a database.
I thought to myself 'hey, it would be cool if I can show the user how the algorithm works step by step, nothing fancy, just plain formatted text that changes when the algorithm does its thing. An output text field with Ajax should get the work done!', but I can't quite get my head around a certain problem. Ajax triggers when a certain event occurs, like 'click' or 'keyup', but is there a way to make it trigger when an object in my ManagedBean class changes?
Don't know if I explained well enough, so here's an example of what I want to do:
An ArrayList in the ManagedBean is empty, the outputtext prints out nothing
After a certain amount of time, a new object is saved in the ArrayList, Ajax triggers and the outputtext prints out its onString()
After a certain amount of time again, the same object that was printed out before changes, Ajax triggers and the outputtext changes accordingly
I'm sorry if the problem isn't quite clear, tried describing it to the best of my ability.
What you describe isn't classic, client-triggered AJAX anymore but known as server-sent events (SSE). They're usually implemented using long-polling (periodic client requests that only get an answer if there's a server-side event).
Your favorite JSF toolkit probably supports it under the name "Push". Here's a Primefaces example.
However, for your simple use case I'd suggest using polling instead. See this example. The main difference is that your server side logic switches to keep a list of "to be displayed" strings/ids/objects. When your browser client polls the server (the listener method gets called), assign the first item to a String field in a backing bean and have your client re-render an area where this String is shown.
Note that you can do this in plain JSF-2, there's no need for Primefaces.

What is the most elegant way to name and event handle site with 100's of input boxes?

Basically so I’ve got this application style webpage with hundreds of input fields(Hidden across tab’s and accordians / fake dialog boxes etc…) , and I want as soon as the control has lost focus / the keystroke ‘enter / tab’ has been hit, (Rather than a submit) I want to using AJAX send a post back to the server to update that field.
Now when trying to figure out naming conventions / tags / classes etc I started going around a little bit in circles as to how to best name things to best utilise Jquery’s selector capabilities at the same time as being concise with event handling.
So my plan was to have a table in the backend db that has in it the table architecture of virtually the entire db, with a unique id and location descriptors (Table / fldName / data type etc…). I was thinking of using that unique id as the id assigned to each of the input elements in the html; and then setting up a single event listener on the whole wrapped set of input’s, that then
— references an array which basically has that dbFields info in it by the id’s
— check clientSide security
— data validation
— send the value with the id to the php
o php then does server side security checks ? data validation again.
o php sends to the relevant stored procedure to update the info
So my question is; is that an elegant way of referencing all the inputs in a way so I set up a generic listener that is called on any input update?
Any suggestions would be much appreciated..
the word/phrase you are seeking is "javascript MVC"
(likely) all are designed for event handling and ajax.
http://codebrief.com/2012/01/the-top-10-javascript-mvc-frameworks-reviewed/
i use backbone and its stunning. im sure you can abstract exactly the function you wish in many or all of these MVCs.

ExtJS 4 - How to check if all current ajax requests are completed and then perform an action?

I have a page which fires Ajax requests for validations at server side. I need to perform an action when all the ajax requests have finished loading or are completed.
For this, I am using Ext.Ajax.isLoading() in a recursive function in following way:
function chechValid(){
if(Ext.Ajax.isLoading()){
checkValid();
}else{
//Code for Action 1
}
}//EOF
checkValid();
//Code for Action 2
The problem is that when I do this, browsers give the following errors:
Mozill FF - too much recursions
IE - Stack overflow at line:18134
If this recursion is a heavy thing for the browsers, then how to perform a task when all the Ajax requests have finished loading?
Using delay is not what I want as, if delay is used then browser begins executing the other code (like 'Code for Action 2' as shared above) which is not what is expected.
The main aim is that the browser shouldn't execute anything unless all the Ajax requests are complete and once completed then it should perform a particular action.
Any suggestions/help on this one?
Thanks in Advance.
PS: Using ExtJs 4.0.7
(Updated)More Detail about the actual situation:-
Here is brief description of the situtaion being faced - There is a form, in which I need to perform server side validations on various fields. I am doing so by firing an ajax request on blur event. Depending upon the server response of validation Ajax fired on blur, fields are marked invalid and form submission is not allowed. (Avoiding 'change' event as that causes alot of overhead on server due to high number of Ajas requests and also leads to fluctuating effects on a field when response from various such Ajax requests are received).
Things are working fine except in one case - when user modifies the value of a field and instead of 'tab'bing out from the field she directly clicks at the save button. In such a case, though, the blur event gets fired but the processing of 'Save' doesn't wait for Ajax Validation response and submits the form. Thus, I somehow need to check if Ajax requests have finihed loading and the process the saving of form. requestComplete would unfortunately not serve the purpose here. And if try using the recursion, then of course, the browser is hung due to high usage of resources. Same case occurs if I try using a pause script work around ( as shared here - Javascript Sleep).
Any possible workaround for this one?
TIA
Your method will lead to infinite recursion.
A better way is to register a callback function in Ext.Ajax.requestcomplete, something like this (not tested):
Ext.Ajax.on('requestcomplete', function(conn, response, options) {
if (!Ext.Ajax.isLoading()) {
//your action...
}
}
};
Unless I am misunderstanding the issue couldn't you create a couple of globals. I know globals are bad, but in this case it will save you quite a bit of headache. One global would be "formReady" and initially set it to false, the other would be "ajaxActive" and set to false. You would also add an onSubmit method that would validate that "formReady" was true and if not alert the user that validation was occurring (or you could set a timeout for form submission again and have a second validation that checks to see if "ajaxActive" is true). When the AJAX call is made it would set the variable "ajaxActive" to true and once complete would set formReady to true. You could also potentially resubmit the form automatically if the response from the AJAX was that the form was good.
Ext.Ajax.request() returns a transaction object when you call it, which is unique and allows you to recognise and abort specific Ajax requests.
By just calling Ext.Ajax.isLoading() without a specified transaction object, it defaults to the last request, which is why you have to call it recursively at the moment.
If it were me, I'd create an array of these transaction objects as you fire them off, and pass each of those in as optional parameters to the Ext.Ajax.isLoading() function to check if a particular request has finished. If it has, you can remove that transaction object from the array, and only progress with the save when your array is empty.
This would get round your recursion problem, since you've always got a finite number of requests that you're waiting on.
if (Object.keys(Ext.Ajax.requests).length === 0) console.log("No active requests");

Oracle Forms 10 auto save form data

He is there a function or setting which automaticly save's the form's data when a user forgot to press save? Like Word has?
You need to code it yourself.
For example, you could add a COMMIT_FORM call to a form-level KEY-EXIT trigger. You might have to check what's in your WHEN-WINDOW-CLOSED trigger as well.
No there isn't. You may be able to do something using TIMERs, but I wouldn't recommend it really. Whereas Word is handling a single user's changes to a single document, Oracle is handling potentially many users' concurrent changes to many tables. If your form auto-saves and the user didn't want those changes saved, you can't just "undo" the changes.
Let try a jquery which is sisyphus jquery.
http://coding.smashingmagazine.com/2011/12/05/sisyphus-js-client-side-drafts-and-more/
https://github.com/dnoonan/sisyphus-rails

Resources