Does anyone know to keep the state in an apex page when I go to another page and return?. It doesn't keep the values entered in the fields, it appears all empty. I appreciate anyone can help. Thanks
What is your ApEx version ?
By default, when you submit a page, item values are automatically set in session state, so you should find them again when you go back to the page.
Be aware that Firefox retain form element values on page refresh, so displayed values may not correspond to values that are really in session state... A solution is to set the «Form Auto Complete» attribute to "Off" in your page security attributes, or use $('#wwvFlowForm').attr('autocomplete','off'); on page load.
If you want to set a value into session state manually without submitting the page :
from PL/SQL, you can use APEX_UTIL.SET_SESSION_STATE (see documentation)
from JavaScript, you have to call a dummy application process, like :
setItemInSessionState: function(p_item, p_value) {
var l_get = new htmldb_Get(null,$('#pFlowId').val(),'APPLICATION_PROCESS=dummy',0);
l_get.add(p_item, p_value);
l_get.get();
}
Finally you can choose to maintain session state per session, or for a user across sessions, by changing «Maintain session state» attribute in the source tab of your item. And if your data is sensitive, you can set «Session State Protection» attribute to "Yes" for your item.
There are a lot of other solutions to keep item values between pages : passing values in the URL into hidden items, apex collections, basic database storage, cookies, etc.
If this does not answer your question, you might give more details.
Maybe you should use session in order to save the inputs and then when the client returns to that page, you will just put the data you have stored in the sessions.
Related
I am using Apex 18.2. and ORDS as a printing server.
I have a master-detail page for selling items with a form on a table as the master region and an IG as the detail, joined to each other through assigning the PK to the FK IG's column.
There is another page with a report that can be queried through number of page items to get the documents with items sold in the previously mentioned master-detail page.
Whenever a user creates a document and submit the page, I will need to send the data of that document directly to the printer.
I mentioned the report page because I thought redirecting to it and assigning the PK to the corresponding page item could be a suggestion. But I know that I can create a shared component> report query too. But I do not know how could I send the data directly to the printer in either way.
I do not know if the report type - IR, CR or IG would make a difference. That's why I just referred to "report". But I'd need to know how it could be done with all types of reports.
Here is how a real-world scenario would look like,
You enter a supermarket, buy some items, go to the cashier, pay for what you've bought and get a receipt. The receipt is printed when the cashier saves the invoice.
I know this is not how web apps work, but this is the task I am facing.
I can think of branching to the report page after the invoice is saved and setting the PK value to the corresponding page item in the "search criteria" region to get the corresponding data then execute "window.print()". But there will be two problems then. 1- criteria region would be printed too, unless I hide it with a dynamic action or else. 2- The "print dialog box" of the browser will be displayed.
APEX 20.1 added native support for PDF printing of Interactive Grid regions. See this video: https://www.youtube.com/watch?v=e1yIFcEdW_o
If you can't upgrade, or if that support isn't sufficient for your needs, I suggest taking a look at APEX Office Print: https://www.apexofficeprint.com/index.html
APEX Office Print(AOP) can provide you the right solution.
Please try out the solution posted in the below link.
http://dgielis.blogspot.com/2020/01/print-pdf-from-oracle-apex-to-local.html
Few more examples:
How to print to an IP printer:
https://www.apexofficeprint.com/ords/aop_web/r/aop_sample_app_web/5034?session=13740999314649
How to print directly to a zebra printer
https://www.apexofficeprint.com/ords/aop_web/r/aop_sample_app_web/zebra-printer?session=6208952429228
(OR)
https://dgielis.blogspot.com/2020/01/printing-to-local-zebra-printer-from.html
If you are redirected to the Home page,
-> Click on examples in the left side menu.
-> Click on Print(highlighted in yellow).
I've been designing a new app in ApEx 19.1 and one of the form/reports which I have created will not save a specific column when I click CREATE (SQL Insert action). Debug data shows that the data is in the session state when the CREATE request is being processed. I have verified that the value is not inserted with the other columns by querying the table in SQL Developer.
When I click to edit the item, the page item is blank and the value is not in the session state. I can then choose a value, and it saves correctly (SQL Update action).
I have several other 19.1 form/reports in the app which do not have this problem.
Details:
-ApEx 19.1
-Modal Form page on an Interactive Report
-New Form Region, not legacy DML setup
-DATETIME column type, Date Picker item type
-Required column, Value Required = Yes (and errors occur correctly if left blank)
-The biggest difference between this page and others is that rather than navigating directly from the report page to this form dialog on Create, there is a different modal dialog form that must be filled, and then the user navigates to the form in question.
All of the other fields insert data correctly to their corresponding columns, and I haven't changed any of the Source settings after creation, so I'm not sure what is causing the issue. I've even deleted the pages and rebuilt them with the same results.
The issue had nothing to do with ApEx, and everything to do with poor DB & app design.
There was an insert trigger on the table which inserted a value to the column in question from an application item which had not been set.
I'll definitely clear that up to avoid future confusion.
I am trying to set a default selected item in a semantic-ui-react dropdown. If I select an item from the dropdown, when I reopen the dropdown it opens on the correct item. However, this item is persisted, and when I refresh the page, the correct items are displayed on the dropdown, but it does not open on the correct item.
Please advise.
Matt, it sounds like you are only using the internal component state. Whatever your components initialize with, they will always start that same way. Your entire React application works this way. If you are expecting your data to be persistent, it needs to be stored somewhere. When you refresh you are starting over again. If the state of your application is not being put elsewhere, you lose that state every single time you refresh because the only copy of state is in your client browser.
Basically you currently only have a frontend application that is not storing data anywhere. Depending on your needs, you could do this in a lot of different ways. A REST API. A GraphQL API. One simple way to accomplish this if you are just creating a simple website would be to use a headless CMS. That will give you a database to store your application data. There are a lot of interesting ones out there that you can explore based on your needs.
I have an Apex application that is quite large. The need has come up to store detailed usage logs of this application. The information on APEX_WORKSPACE_ACTIVITY_LOG is not enough, because I need to know what queries each user runs on each page.
My first thought was to get the actual Oracle query logs (V$SQL and such), but they provide no information on the user (as far as the database is concerned, all queries are made by APEX_PUBLIC_USER). I have some information about the user on V$ACTIVE_SESSION_HISTORY, but that's incomplete because it stores samples of active sessions and their SQL queries at 1-second intervals, so I miss too many queries.
So now I'm off to implementing application level logging. The "right" way to fo this would be to go through all the pages in my application and create a logging process to store the relevant information for each one (username and some page items). But I wonder if there might be something simpler that does the trick.
If I understand correcly, "application processes" are run by every page in the application. So if I can get an application process to iterate over the list of page items, I can store them all in the database and be done with it. Something like
for item in page_items {
log(username, item_name, item, date)
}
Can this be done? Or maybe the information I need is on the database already and I don't see it?
You can query the metadata tables to get all items for a specific page and then use that to get their value.
select item_name, v(item_name) item_value
from apex_application_page_items
where application_id = :APP_ID
and page_id = :APP_PAGE_ID;
That will capture all items on the page. Don't forget that if you use items on Page 0 (Global Page) you may want to query that page too.
Additionally, you may want to capture application level items too.
select item_name, v(item_name) item_value
from apex_application_items
where application_id = :APP_ID;
What is a good approach to keeping accurate counts of how many times a page has been viewed?
I'm using Django. Specifically, I don't want refreshing the page to up the count.
As far as I'm aware, no browsers out there at the moment send any kind of message/header to the server saying whether the request was from a refresh or not.
The only way I can see to not count a user refreshing the page is to track the IPs and times that a user views a page, and then if the user last viewed the page less than 30 minutes ago, say, you would dismiss it as a refresh and not increment the page view count.
IMO most page refreshes should be counted as a page view anyway, as the only reason I have for refreshing is to see new data that might have been added, or the occasional accidental refresh/reloading after a browser crash (which the above method would dismiss).
You could give each user cookie, that expires at the end of the day, containing a unique number. If he reloads a page you can check wether she has been counted already that day.
You could create a table with unique visitors of the pages, e.g. VisitorIP + X-Forwarded-For content, User-Agent string along with a PageID of some sorts. If the data itself is irrelevant, you can create a md5/sha1 hash from these values (besides the PageID of course). Be warned however that this table will grow really fast.
I'd advise against setting cookies for that purpose. They have a limited size and with many visited pages by the user, you could reach that limit and make the solution unreliable. Also it makes it harder to cache such page on client-side (see Cacheability), since it becomes interactive content.
You can write a django middleware and catch request.url, then setup a table with url / accesses columns. Beware of transactions for concurrent update.
If you have load problems, you can use memcached with incr or add function and periodicaly update the database table to avoid transaction locks.