I have an apex page that has some search items filled by the user. One of these items is a check-box with 4 values used to search. For example, 4 check-boxes(but only 1 item) with the values A:B:C:D. I have 4 reports(one for each check-box value), that must be showed only in case of the corresponding check-box is marked. So, I put a SQL condition in each report, ex: for report 1, condition => :P324_MY_CHECKBOX like '%A%', for report 2, condition => :P324_MY_CHECKBOX like '%B%' ...
When user fill the form, he clicks on "Search" button that invokes a dynamic action. This DA sets the items on the session and refresh the 4 reports. The expected result would be to show only some regions, according to the selected check-boxes. The problem is that the condition doesn't work in this case of refresh. I can see in the apex session that the item P324_MY_CHECKBOX doesn't has the value "A" for example but the corresponding report is still showed.
Resuming, the condition of region doesn't work(is not re-evaluated) if I refresh the region in a Dynamic Action.
Has anyone had this kind of problem? Is there an expert or guru to help me?
Thank you for your attention!
Conditions are evaluated on render of the page while dynamic actions are javascript commands that operate on the rendered page.
Instead show all regions without conditions and control the hide/show using your dynamic action.
Related
I have a page where the users will be adding items to their list. In here, they have an 'add row' button which - just like the name - it adds a new row for the user to include another item.
In order to make a new row visible I have:
A display only item (which will become hidden later on) that gets increased by one when the user clicks on the 'add row' button (counter original value when the user first enter the page = 1)
Rows with a server side condition (row 2 will be shown if the counter is greater than 1...row 2 will be shown if the counter is greater than 3 and so on)
Sometimes it works perfectly....most of the times it doesn't.
Pic 1:
Counter now equals 2 (I clicked the add row button once which converted it from 1 to 2) and in theory row number 2 should be displayed now...but it isn't. Only the first one it's being shown:
Second row server side condition is:
:ROW_COUNTER > 1
Does anybody know how to fix this?
Thanks!
Im just gonna guess here and say that it shouldnt be working because you use server side condition for a dynamic change.
Server side conditions only trigger on page initialization and not when you change something dynamically by pressing a button. This should mean that your conditions wont be met until you either refresh or submit the page, depending on your ROW_COUNTER session settings.
--> https://www.foxinfotech.in/2020/02/oracle-apex-using-server-side-conditions.html
Try working with a Dynamic Action. You can execute PLSQL code there too.
I have a value of a field on page 1 that I need to pass to page 2 (modal dialog).
The field is changed on page 1. and I can see it's got updated on the page and when I print its value in debug messages.
When I'm clicking the button, with the action "Redirect to Page in application", the value on page 2 is the initial value of the field, and not the updated one, is this a bug?
what can I do?
I don't want to use dynamic action or things like "prepare_url" because of many reasons.
Thanks.
That is not how a link works. What you are seeing is not a bug, it is expected behaviour. The link is rendered when the page is rendered and will have the item values at render time and a calculated checksum (depends on settings) based on those values. It will not pick up any changes.
The "traditional" way to do this is the following. Assumptions: Need to navigate from page 1 to page 2 and set P2_ITEM on page 2 to value of P1_ITEM on page 1.
Create button (let's say button name is MYBUTTON) of type "Submit Page"
Under "Processing", create a branch to page 2.
For "Page or URL" pick page 2 and set P2_ITEM to value P1_ITEM.
For "Process point" pick "After Submit"
Under "Server Side Condition", select "MYBUTTON" under "When Button Pressed".
Since this is a branch your page has been submitted and all the changes you made to P1_ITEM will be picked up. The fact that page 2 is modal does not affect this, APEX will take care of that for you.
As an alternative to Koen Lostries excellent explanation, in some cases it is also possible to have the target page load the item from the source page.
Ensure that the item is being pushed to the session, for example by using a dynamic action with the items to submit option, but do nothing else in this dynamic action.
Then, when page 2 opens, simply add a pre-header-process, that makes something like :P2_ITEM := :P1_ITEM;
In my experience this approach is easier than doing a redirect in a dynamic action, as there is no declarative option for that and you often need hand-written javascript to do that.
I have a form which has 4 items:
A yes or no fill in
2 items if yes
1 item if no
I would like to create a dynamic action that would disable the field(s) that I do not need, enable the one(s) that I do need, and set the focus to the (first) enabled item. Additionally, it should be able to switch back and forth without a page refresh.
I tried making a couple of dynamic actions, but I noticed that it would only change once. For example, if I were to enter 'yes' into the first field, it would enable and disable the appropriate fields, but when I would switch the first field to 'no', nothing would changed.
Any help would be greatly appreciated. Thanks in advance.
It sounds like you need to fill in the Condition field (in the When sction) on the dynamic action and then include a True Action and a False Action.
For example:
Condition equal to 'Yes'
True Actions: Display 2 items
Hide 1 item
False Actions: Hide 2 items
Display 1 item
If this doesn't resolve your issue, you should try listing the values you have used for all the fields on your dynamic actions. Without seeing the values, it is difficult to troubleshoot.
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 am a relative APEX noob.
I'm running APEX 4.0 against a 10gR2 database.
I've written a query that takes a few inputs (two date fields, for start and end, and a text field for further filtering) and created a dynamic report out of it that works when I pull the input variables (:START_DATE, :END_DATE, :OFFICE) out of it or replace them with static values.
I want to create a form on a page that submits those values to the dynamic report page for use in the query to filter the results the user sees when he or she hits the report.
I'm not having much luck finding a good step-by-step example of this. I created a blank page with two Date Pickers and a LOV select dropdown, but am unsure how to best translate those values into the dynamic report.
Can somebody point me at the right documentation for this?
The following was developed using Apex 4.1 but apart from some cosmetic changes the principles should be the same.
The data comes from the standard scott.emp schema.
Overview
This is page 1, the user can enter an empno and\or a hiredate.
When submit is pressed the following report on a different page is displayed:
How it works
On page 1 I have created the three items shown. The text items are called them P1_EMPNO, and P1_HIREDATE. The action for the button is "Submit Page"
Still on page 1, create a branch with the following values:
This branch navigates to page 2 (which is yet to be developed) and sets the values of items on page 2 with the values from page 1.
Create a new page, in this example this will be referred to page 2.
On page 2 create a new interactive report using the following query:
select e.*
from emp e
Next create two text items in the same region as the report and call these :P2_EMPNO and :P2_HIREDATE. I have found it useful to show these items during development so you can see that the correct values are being passed through to the page. You can always set them as hidden once you happy with the report.
Finally amend the query used by the interactive report to use the values supplied by page 1
Run the application.
You want to reference your page items in your query, which means you'll have to submit your page before your query will pick up the session state of them. What I do when I provide a small parameter form, is to put a button up there as well (i.e. labeled 'Query'), which does a submit.
In your report you can then reference your items. If for example you have 2 items P1_DATE_START and P1_DATE_END, your query could look like:
SELECT firstname, lastname, job
FROM employees
WHERE employment_start BETWEEN to_date(:P1_DATE_START) AND to_date(:P1_DATE_END);