This question follows off this previous question.
I have a main report with a column link, that when clicked, refreshes a secondary report with a dynamic action that a) executes JavaScript which calls AJAX to set the page items that the secondary report uses to construct a SQL statement and b) refreshes the report.
There is actually 2 tertiary reports as subregions in the secondary report, conditionally visible only when the REQUEST = a certain value.
I call AJAX to set page items without having to refresh the page using this method:
var get = new htmldb_Get(null,&APP_ID.,'APPLICATION_PROCESS=dummy',&APP_PAGE_ID.);
get.add('PX_ITEM', 'new value');
gReturn = get.get();
get = null;
I was hoping that there would be something as simple as the following to use AJAX to set the REQUEST for that page
get.add('PX_REQUEST', 'new value');
Thank you.
Related
I am trying to display a value of an item like that:
Some text &P5_ITEM.
It's works only when I refresh a page, without refreshing I can only see a previous value of an item.
I tried to submit a item value with dummy pl/sql
null;
Items to Submit &P5_ITEM.
but it didn't work
It's work only with a javacript
Location.reload()
But it is not a solution becouse it invokes reload after reload since dynamic action starts when page load.
I figure out how to fix that, instead of calculating value of an item in dynamic action fired when page load I passed value of the item in link attributies and it's working properly.
I have an Oracle APEX page that collects data via a classic report with apex_item dynamically generated items. Something like this:
select apex_item.radiogroup(qt.save_position, 1, qt.answer, null, null, null, null) col01
from xxpay_360_questions qt
where qt.questionnaire_id = 21
I then save the answers using a submit button that uses "Submit Page" and calls PL/SQL to insert/update the dynamically generated items from above. Something like this:
insert into xxpay_360_answers values (apex_application.g_user, APEX_APPLICATION.G_F01(1));
commit;
My question is how can I also do a transition to the next page of dynamically generated items (since I only have 50 apex variables to play with per page) when the submit button is clicked.
The submit button only has options for "Submit Page" and "Transition to Page" and not "Submit Page and then Transition to Page".
Is there a way of transitioning via PL/SQL as part of the submit code? Or is there an event that can transition after the page has been submitted?
Also how does this work with errors and the nice "Saved" fly over that apex has?
You need to create a Branch, on the after processing region:
Then you need to set as branch point: On Submit After Processing (After Computation, Validation and Processing) and the branch type as: Branch to page
Then specify the page number where your going to:
And finally you can set the branch to be fired only if one particular button is pressed and if one particular condition evaluates to true:
I think that would cover your needs.
But if you want to do it with PL/SQL you could do something like this:
Replace the page ID with the actual page Id to which you want to redirect the user.
BEGIN
IF(CONDITION)THEN
htp.init;
owa_util.redirect_url('f?p=&APP_ID.:10:&APP_SESSION.'); /*Replace 10 with actual Page Number*/
apex_application.stop_apex_engine;
ELSE
htp.init;
owa_util.redirect_url('f?p=&APP_ID.:20:&APP_SESSION.'); /*Replace 20 with actual Page Number*/
apex_application.stop_apex_engine;
END IF;
END;
Or you could use the APEX_UTIL.REDIRECT_URL procedure.
if you are using APEX 4.2 refer the APEX_UTIL reference from here.
You can use:
apex_util.redirect_url(
p_url => 'type your url here'
);
This effectively calls in the owa_util. redirect_url and automatically calls apex_application.stop_apex_engine.
I have two Main reports. Each report has a corresponding region with a Nonmain Classic report (so 4 reports total). Clicking on a link in each of the Main reports reveals details in its corresponding Nonmain report.
Currently, clicking on a Main report will reload the whole page, and all the PL/SQL and SQL has to refire from all 4 reports.
It would cut down on the SQL calls if only the nonmain report refreshed. I assume AJAX would be the best bet to accomplish this.
How would I go about doing such a task?
Thank you.
P.S., all four reports are determined by a PL/SQL function returning a SQL statement. All headings also are determined by a PL/SQL function returning a colon-delimited string.
With your previous questions in mind, your classic reports rely on the session state of some page items. You are setting the value of these items in your colunmn links.
If you want to cut out the submit of the page then you need a way for the anchor tags to not fire their default action and provide the value for page items to be set to a dynamic action.
You have to put this in the column link attributes:
onclick="return false;#" class="reportlink1"
You then need to pass on some data, and i suggest using data tags
data-value1="#COL1#:"
Create a dynamic action, firing on click and uses a jQuery selector .reportlink1
What needs to happen now is to provide the page items with their needed values
Add a true action to execute javascript:
var lValue1 = $(this.triggeringElement).data("value1");
$("P1_ITEM1").val(lValue1)
With the item value set, create another true action of type "Refresh" and set it to affect your secondary report.
The final step is then to set the "Page items to submit" on the secondary report. This will cause the report to submit the values of the set page items to the session and ensures that the sql will return the correct values when the region is refreshed.
For some reason, Tom's approach did not work for me; I assume it must be the idiosyncrasies of my page. If anyone stumbles upon this question, try Tom's method first, and if for some reason it doesn't work then try the following adaptation with AJAX in the dynamic action:
If your nonmain reports rely on the session state of some page items, and those items are set via column links from your main report, you must put this in the column link attributes to prevent the submission of the page and to pass the values using data tags:
onclick="return false;" class="reportlink1" data-value1="#COL01#" data-value2="#COL02#"
Create a dynamic action, firing on click and using a JQuery selector .reportlink1
Provide the page items with their needed values VIA AJAX. Add a true action to execute synchronous javascript:
var v1 = $(this.triggeringElement).data("value1");
var v2 = $(this.triggeringElement).data("value2");
var get = new htmldb_Get(null, &APP_ID., 'APPLICATION_PROCESS=dummy', &APP_PAGE_ID.);
get.add('PX_ITEM1' , v1)
get.add('PX_ITEM2', v2);
gReturn = get.get();
get = null;
With the item values set, create another true action of type "Refresh" and set it to affect the secondary report.
Unlike Tom's solution, DO NOT set the Page Items to Submit on the secondary report.
I have been tasked with re-creating an old PL/SQL Web Toolkit front end in Application Express (Apex).
I would like to display a popup after the page is submitted and after computations and validations.
The page can be submitted by clicking a button OR by hitting enter.
I have googled and got a modal popup working (called by javascript) but I can't seem to call it at the right point. I can call it on submit (before the validations etc.) but not after the validations.
I have tried creating a branch to URL at the correct processing point and then have the URL set to:
javascript:openForm();
But then I get a page will not display error.
Can anyone out there explain how I could do this?
Apex Version: 4.0.2
Oracle 10g
I suppose what you want to do is to perform the validations, have values submitted to session state, but not execute further processes.
However, when you submit the page it is sent to the server; and everything you see in the page processing region will sequentially fire. There is no way to halfway through the processes call a javascript function, since basically you are not on the clientside anymore.
What you can do is to create a branch after your validations to the same page. Redirect to it but provide a REQUEST value, for example OPENFORM.
Create a dynamic action, firing on page load, with a true action that executes javascript and opens up your modal page. Then set the condition on your dynamic action to Request = Expression 1, providing the request value to Expression 1 (OPENFORM).
(Note that this is the Conditions region, and not the 'Condition' field of the 'When' region)
This should cause the page to be submitted, validated, then re-loaded but with a request value, and the dynamic action firing, opening your modal page.
Just a point of interest:
If you have actual processes on this page though, then be careful with the Enter key. Buttons by default submit to session with the request value set to their name, and thus making it possible to conditionally execute processes or branches. The enter key does not submit with a request value set i believe. So if your branch is conditional, the enter key might simply skip over it.
I have some custom HTML that creates a table on my page with a bunch of images. For each image I would like to create a tag around it and call a process that has been defined in apex. How can I do this?
It seems that the only way to call processes is from a object that has been created by Oracle Apex such as a button item....
Two ways:
1) You can set up your link to submit the page with a request like this:
...
Then create a page process that runs when Request is equal to 'MYREQUEST'.
2) You can give your anchor an ID:
...
Then create a Dynamic Action that fires on the Click event for the jQuery selector '#myAnchor' and executes PL/SQL code.
Don't think you need the doSubmit Javascript function because if you go to the
report >> edit the column >> column link,
there is a Request field. You can put your request name there.
In page process condition type pick Request = Expression and put whatever you named the request.
I find javascript more flexible. For example you can implement confirmation dialog with customized text message like followings:
SELECT col1,
'submit' as link
FROM tab1
Regards,
Igor