Oracle Apex Event when page gets changed with custom attributes in plugin - oracle-apex

I am currently trying to develop a plugin in oracle apex. This plugin consists of attributes which have SQL queries. I want to pass this SQL queries into the child component. In this case the child component is a dialog window.
I can pass different values like numbers or strings easily as page items with the url approach. However using this approach is not very scalable because of the URL restriction of maximum 2000 characters.
e.g. with APEX_UTIL.PREPARE_URL
Therefore I thought of storing SQL-Queries in the database and then query it in the dialog.
And here is the problem: How can I store the SQL Queries when the plugin is configured?
I do not like to have the logic in the render call, because this way everytime the plugin gets rendered it makes some unnecessary database requests.
Is there something like an event when the page gets saved with the plugin? Or a possibility to have some PL/SQL code after the page gets changed which can access the plugin attributes?

Related

DJango-tables2 how do I refresh/update the table on the webpage without hitting refresh button

I followed the DJango-tables2 official tutorial and was able to create data set in the terminal using:
Person.objects.bulk_create([Person(name='Jieter'), Person(name='Bradley')])
However, the new data in the table on the website doesn't show up until I hit the refresh button. My question is how the table can be updated/refreshed without any human interaction on the webpage.
What I'm trying to achieve is to update the table on the webpage without human interaction as soon as new data comes in. I'm relatively new to this, any suggestions would be greatly appreciated.
Thank you.
To avoid refreshing the page you would need to get new data using an Ajax request, this table use template rendering meaning it is not meant to work like you want to use it.
Usually, to do what you want to do, you need a front end JavaScript component like Datatables.net, FancyGrid ... and make requests to server using Ajax to get new data.

Django - Is it possible to show loader until a start page is loaded?

My view function takes a long time until returning a template. So, I'd like to show something to a user while running the function.
Is it possible to show loader until a start page is loaded?
What's important is the loader should be shown when loading the first page after first visit of a user?
Thank you for reading my question.
You would have to fetch the page using JS. You could use something like Intercooler or PJAX which provides HTML attributes that show a spinning animation while loading the content via AJAX.
A better solution would be to make your page faster. There are several things you should consider:
Check that all Model fields that you are using for filtering or sorting have set db_index=True unless the tables are small (few hundred entries) or the fields are already unique or foreign/primary keys. Also check that your DB does sorting and merging in RAM not on disk (== the DB has enough RAM resources and has also the correct configuration to use it).
Sometimes, if you show a list of model instances you end up making separate DB requests per row if you access related models in your template. Again, check which statements your DB executes and have a look at Django's select_related, prefetch_related, values and values_list methods that can dramatically increase lookup performance. Make sure your template context contains all necessary data and only the necessary data (e.g. pageing, how much, or maybe you should consider a search index like SOLR or Elastic which can be integrated nicely via Django Haystack).
Load everything except heavy data at once in your main view, which also includes JS. The JS then uses AJAX to load the rest from a second Django view which returns an HTML snippet that your JS simply adds to the DOM.
It really depends on how comfortable you are with JS and how much you want to stick to HTML to make as much use of Django as possible (thinking of Django Forms for example). But first, tune your DB setup (disclaimer: I have written that article).
it's better to make a request with javascript to your Django endpoint, until you get a response back from your server you should show your loader, and when you get the response back successfully you should make display: none for loader and mak display: block for your loaded content
Create a function in views.py and send JsonResponse. URL example: http://localhost:8000/somedata
Render any other HTMLlet's say it's index.html. URL example: http://localhost:8000/home
That index.html file need to have some JavaScript, let's say main.js
In main.js make a request to http://localhost:8000/somedata and fetch data. Use async javascript that way you can easily track fetched data or not

Django Statelessness

I was reading some blogs and came up to the conclusion that django is an MVT architecture which do not maintain state. I am working on application that have maps visualization. When the user selects a variable from the drop down, a request is sent to the backend database and on the screen, it generates the heat-map of that specific variable.
what I want to achieve is that if I go some other tab and do some other changes like change the layer of map or select some another variable, the state of old heat map should be maintained regardless if I want to clear it. I do not know how to maintain state in django can anyone help me in this?
You can leverage the Django's sessions mechanism. You'll need an AJAX request that POSTs the current tab state to Django, so your backend code can restore it on page reload.

Bulk Creation Of Items In Sitecore

I am using Sitecore 8, Update 3.
I am attempting to bulk create a couple thousand items that use a custom template. All of these items are created under one specific parent item.
The custom template has two fields which are Path [Single-Line Text] and Target [General Link].
The source of the data is in an old SQL database.
Is there a way to do this?
The Sitecore marketplace module Data Importer is a option for you.
Create a custom importer with the sitecore api is also possible, to speed up, you can disable the index rebuild.
Since your data is already in SQL Serve, you should take a look at using the SSIS Components for Sitecore, it was designed for importing exactly this kind of data in bulk into Sitecore using ETL.
You can find more info in the blog post Creating your first project with SSIS Components for Sitecore and there is also some good additional into in the Migrating to Sitecore: Going from WordPress to Sitecore with SQL Server Integration Services (SSIS) post.
The Integration Services Components for Sitecore is available on the Sitecore Marketplace, and it is compatible with Sitecore XP8.
I'll also add, if you are creating anything more than 100 items below a single parent item then this is not recommended Sitecore practice unless the items sit within an Item Bucket. Make sure you account for this, or split your items up into smaller sub-folders (e.g. year/month folders for news article type items)
In these scenarios you normally end up writing code to call the api and create the items programmatically rather than doing a generic import.
If you need to create a large amount of items I would recommend writing a console app to do this. You could use the Sitecore Item Web api to create items outside of the Sitecore context or investigate the new Entity Service api in Sitecore, both will be capable of creating large amounts of Sitecore items.
http://mikerobbins.co.uk/2015/01/06/entityservice-sitecore-service-client/
https://sdn.sitecore.net/upload/sdn5/modules/sitecore%20item%20web%20api/sitecore_item_web_api_developer_guide_sc65-66-usletter.pdf
If these don't float your boat you could always write async code to create the Sitecore items and have that executed by an aspx page in a Sitecore instance - works well for one off tasks.
Example of Asynchronous page processing in ASP.net webforms (.NET 2.0)

Plone-like search box in Django?

Plone has a beautiful search box with a "Google suggest" like functionality for its site. It even indexes uploaded documents like PDFs. Does anyone know of a module that can provide this kind of functionality in a Django site?
Plone implements it's LiveSearch feature by maintaining a separate metadata table of indexed attributes (fields such as last modified, creator, title are copied from the content objects into this table). Content objects then send ObjectAdded/ObjectModified/ObjectRemoved events, and an event subscriber listens for these events and is responsible for updating the metadata table (in Django events are named signals). Then there is a Browser View exposed at a fixed URL that searches the metadata and returns the appropriate LiveSearch HTML, and finally each HTML page is sent the appropriate JavaScript to handle the autocomplete AJAX functionality to query this view and slot the resulting HTML results into the DOM.
If you want your LiveSearch to query multiple Models/Content Types, you are likely going to need to send your own events and have a subscriber handle them appropriately. This isn't necessary for a smaller data sets or lower traffic sites, where the performance penalty for doing multiple queries for a single search isn't a concern (or you only want to search a single content type) and you can just do several queries from your View.
As for the JavaScript side, you can roll-your-own or use an existing JavaScript library. This is usually called autocomplete in the JS library. There is YUI autocomplete and Scriptaculous autocomplete for starters, and likely lots more JavaScript autocomplete implementations out there. Plone uses KSS for it's JavaScript library, the KSS livesearch plugin is a good place to start if looking for example code to pluck from.
http://pypi.python.org/pypi/kss.plugin.livesearch
And a tutorial on using KSS with Django:
http://kssproject.org/docs/tutorial/kss-in-django-with-kss-django-application
KSS is quite nice since it cleanly separates behaviour from content on the client side (without needing to write JavaScript), but Scriptaculous is conceptually a little simpler and has somewhat better documentation (http://github.com/madrobby/scriptaculous/wikis/ajax-autocompleter).