Resubmit form error - refresh

I made a JSF web application. It was generated in netbeans ide.
To prevent pages being unresponsive I've set pages to auto-refresh in a set time interval.
I have a list page like this
List of records
And I can create a record like this
create a record
Say, I have set auto-refresh to every 30 seconds. I create a new record and return to list page. After 30 seconds it will give me this error: "Resubmit form? To refresh this page, your browser needs to repeat any actions you've already taken. For example, if you've already entered info into a form, your info will be resubmitted to the site".
This only happens if I access from another computer. From localhost it just redirects to list page without error popping up.
It seems like when I click to load create page, this action is remembered and when list page is refreshed it refreshes the create page.

I fixed it by redirecting to index after submitting.
FacesContext.getCurrentInstance().getExternalContext().redirect("../../faces/index.xhtml");

Related

Interactive filters set on page load only show up after manual refresh

I am setting up dynamic filters for the IG using new APEX_IG package method add_filter. So from Page 1 I click oin the link to go to Page 2 where I have interactive grid. Through that link I set a couple of page items on page 2 and based on those items I create filters using APEX_IG.ADD_FILTER. So the setting of the filters has to be done on PAGE_LOAD.
On page load I use a DA that calls APEX_IG.ADD_FILTER if a specific page item is not null. When I open the page first time, I do not see the filters applied, they only show up after I manually refresh the page. I added a refresh action for the IG after executing ADD_FILTER but that does not do anything - in order to see the change I still have to manually refresh the page.
I cannot add any refresh action or submit page action under page load since that will refresh the page repeatedly. What is the best way to programmatically refresh the page after applying or removing the filters?
If the issue is just on page load, you could add the call to APEX_IG.ADD_FILTER in a pre-rendering page process instead of a dynamic action. This works fine for me. This blog also explains that a full page refresh is needed.

Oracle-Apex: Dynamically redirecting from login button

The scenario
I have implemented social authentication similarly to described by Dimitri Gielisin hist post "Facebook, Google and Custom Authentication in the same Oracle APEX 18.1 app" (http://dgielis.blogspot.com/2018/06/facebook-google-and-custom.html)
The pertinent point is that there is a button which has the request 'APEX_AUTHENICATION=FACEBOOK' which logs the user in and also hard codes the page that the user is taken to.
It works great. (However if I have a login menu item which directs back to the same page - the user name isn't updated on the page.)
The Issue
Default behaviour is for apex to redirect users to the login page when they attempt to access a page which is not publicly available.  After logging in the user is taken to the page hard coded page in the button (except for modal dialogues which just produce an invalid session error). 
I'd love it if they could sign in and then continue to the page they need to go to. Is there some not extremely cumbersome ways of doing that? I thought of trying to saving the page number I want the user to go to into an application item and then having the button redirecting based on the application item- but while I was saving the page number the dynamic redirect in the button is not working...and I feel like I'm fighting the apex framework...
Is there a better way? If not can a button reference an item for the page number? I was trying &APP_ITEM. but that didn't seem to work...
(I"m using Apex 20.1)

Apex Oracle : How to refresh Page Item?

I have a page Item on Apex 19.2
In page validation where i'm setting the value of the item : P1_MyItem. The value is set properly in session state. However it's not reflected immedialy in the html item. I still need to reload the page to get the right value in the item.
Is there any way to reflect it immediatly please ? (without reloading the page)
Thanks.
Cheers,
You need to ensure Items to Return lists any item that is updated within the PL/SQL, that you would also like updated within the web page once the dynamic action is completed.
As opposed to 'Items to Submit', which sends any information in pages items the browser is aware of to the database, before execution of the PL/SQL block.
Page processing now defaults to using Ajax. So, if a validation error occurs, the page is no longer re-rendered by default because the assumption is that validations will not change session state. If you want to see your changes, you'll need to locate the page property named Reload on Submit and set that to Always.
But, of course, that means the page will be re-rendered/re-loaded which is what you're trying to avoid.
Also, it's not possible to set the page property to Reload on Submit if you want to use an Interactive Grid on the same page. It requires the option Only for Success, so you have to refresh the page item somehow else.

Oracle APEX form on table, don't reset table pagination after changing values through the form

I have a form on top of a report, and when the user updates values in the report, the form pops up, they make edits, and then click "Apply Changes". There are many rows in the report and right now I have pagination set per every 15 pages. The report is set to enable partial refreshes so the data updates right after the user clicks "Apply Changes". However, if I am on any page other than the first page of the report, it resets the pagination and brings me back to the first page. Is there a way to update the report but stay on the page I'm making the edit for? That way the user can immediately see the change they made through the form.
I was able to solve the issue by using a Dialog Closed dynamic action executing the following javascript:
window.location.reload(false);
It refreshes the browser after the user makes edits, and the pagination does not reset. This is a workaround because the Refresh dynamic action resets pagination. Again this is in APEX 5.1.3.
Which Apex version do you use? I've just tried it on apex.oracle.com which runs Apex 20 and - no problem at all. Once I edit some value in a form, branch returns me to interactive report, to exactly the same page which I left.
Check branch's Behavior - it is set to redirect to page or URL, target is page where the interactive report is; check other properties for the target. Its action should be set to "None" (offered are: clear regions, reset regions, reset pagination which might be set in your branch properties).

how to pass login credentials between pages in oracle apex?

I am creating a banking application using oracle apex. once the user have logged in using his customer id in page 2, his account details table should be displayed in the next page. I've tried with
select acc_no, bal from acc_details where cust_id= :P2_USERNAME
but I'm getting 'NO DATA FOUND'.
is this the correct way to do this? I've tried to use branches too. That was also not working.
On your first page, under the "Behavior"(APEX 5)/"Action When Button Clicked"(APEX 4) attribute of your log in button set "Action" to "Redirect to page in this Application". Then set the Target page number. Under that, you'll see the 'Set Items' part. Fill up that part by setting the "Name"(APEX 5) / "Set these Items"(APEX 4) with :P2_USERNAME and then "Value"(APEX 5)/ "With these Values"(APEX 4) with :P1_USERNAME. Get rid of the "branches" that you've created before or disable them at least for now.
if your user login name and userid is same (like email address)
you may use
apex_authentication.get_login_username_cookie
for getting username/user id at each page
or you can create an application item in shared component and assign user id to this item as
:MY_APP_ITEM := 'Hello';
after login and call it from all pages
Have you tried using :APP_USER? If that didn't work you could try creating an Application item as a value container for your cust_id. Just go to Shared Components >> Application Items then create an item. This way you could reuse the value on the application item until your session expire or you clear its value.
Say you've created an Application Item named "G_CUST_ID", you want to store your cust_id's value to G_CUST_ID. Create a PL/SQL process on your log in page and write the code below:
apex_util.set_session_state('G_CUST_ID', :P2_USERNAME);
The value set on G_CUST_ID will reset automatically on session expire. Don't forget to reset the value manually on Log Out.
apex_util.set_session_state('G_CUST_ID', NULL);