You are on page 1of 13

APEX

Karel van der Walt


MentalArrow

apex.widget.
(function() {
apex.widget.checkboxAndRadio( "#P13_IS_DOMESTIC",
"radio",
{"ajaxIdentifier":"2C66...F9B057",
"action":""}
);
}
)();
(function() {
apex.widget.selectList( "#P13_IS_BANK",
{"ajaxIdentifier":"2BB1201...8594406B",
"nullValue":""}
);
}
)();

http://www.jstree.com/
APEX aliases jstree in API with tree
$.jstree.reference('#tree7135102724225813').select_node('child_node_1');

Vs
$.tree.reference('#tree7135102724225813').select_node('child_node_1');
$('#tree7135102724225813').tree('select_node', 'child_node_1');
$('#tree7135102724225813').tree(true).select_node('child_node_1');

http://www.jstree.com/
$.tree.reference('#tree7135102724225813').search(opener.apex.item("P13_REG_28_CD").getValue());
$(".search")
$.tree.reference('#tree7135102724225813').select_branch($(".search")[0], false);
$.tree.reference('#tree7135102724225813').search('Gold');

http://www.jstree.com/
$("input:[value='Expand All']").click();
This solutions finds the HTML objects by the displayed value. Use it in a "Dynamic Action
> Page Load > Execute Javascript" process.
For example enabling all the plugins can be done this way:
"plugins" : [ "checkbox", "contextmenu", "dnd", "search", "sort", "state", "types",
"unique", "wholerow" ]

http://www.jstree.com/
$('#jstree_demo').jstree({
"core" : {
"animation" : 0,
"check_callback" : true,
"themes" : { "stripes" : true },
'data' : {
'url' : function (node) {
return node.id === '#' ? 'ajax_demo_roots.json' : 'ajax_demo_children.json';
},
'data' : function (node) {
return { 'id' : node.id };
} } },
"types" : {
"#" : {
"max_children" : 1,
"max_depth" : 4,
"valid_children" : ["root"]
},
"root" : {
"icon" : "/static/3.0.0-beta4/assets/images/tree_icon.png",
"valid_children" : ["default"]
},
"default" : {
"valid_children" : ["default","file"]
},
"file" : {
"icon" : "glyphicon glyphicon-file",
"valid_children" : []
}
},
"plugins" : [
"contextmenu", "dnd", "search, "state", "types", "wholerow ]
});

How to use the link column


Tree Attributes page, set the 'Selected Node Page Item' to a page or application item that you
wish to hold the selected node value e.g. P21_SELECTED_NODE
Then update the link parameter in your tree query to set this item to the VALUE parameter of
your query .e.g EMPNO. Now when you select a node, and return to the tree page, the
tree will expand to that last selected node.
select case when connect_by_isleaf = 1 then 0
when level = 1
then 1
else
-1
end as status,
level,
"ENAME" as title,
null as icon,
"EMPNO" as value, -- unique ID for each branch of the tree
"JOB" as tooltip,
'f?p=&APP_ID.:7:'||:APP_SESSION||'::::P7_EMPNO,P21_SELECTED_NODE:'||"EMPNO"||','||"EMPNO" as link
from "#OWNER#"."WWV_DEMO_EMP"
start with "MGR" is null
connect by prior "EMPNO" = "MGR"
order siblings by "ENAME

make sure that you have P7_EMPNO as a hidden item on your page.
In your region's header, add &P7_EMPNO. (with the & and the .) - this will be replaced by
Apex with the value from the P7_EMPNO field

How to use the link column

'f?p=&APP_ID.:1:&SESSION.::NO::P1_SYSTEM:'||"S_ID" link,

'f?p=&APP_ID.:1:&SESSION.::NO::P1_SYSTEM,P1_S_NAME,P1_FROM_TREE:'||
"S_ID"||','||"S_NAME"||',YES' AS link,

link to page 1 and overwrite the value of :P1_SYSTEM

Using several values to overwrite in page

'f?p=&APP_ID.:' ||"S_ID" || ':&SESSION.::NO::' AS link,

Link to a specified page via node value

How to use the link column

'javascript:change_page(' || "S_ID" || ')'


Go Edit Page > HTML Header

<script language="JavaScript" type="text/javascript">


function change_page(v_page) {
var v_url = 'f?p=&APP_ID.:' + v_page + ':&SESSION.::::';
window.location.href = v_url;
}
</script>

'javascript:close_page(' || "S_ID" || ',''' || "S_NAME" || ''')' AS link,

use your tree as a pop up tree and want to give back a node
value to the parent page with submit and close the pop up
page automatically afterward
Go Edit Page > HTML Header

<script language="JavaScript" type="text/javascript">


// I also used a hidden item in the pop up page to fill with the parent
// page id &P101_WHEREFROM
function close_page(v_id,v_value) {
var v_page = 'P' + '&P100_WHEREFROM.' + '_S_ID';
var v_page_display = 'P' + '&P101_WHEREFROM.' + '_S_NAME';
var l_field_id = opener.document.getElementById(v_page);
l_field_id.value = v_id;
if(l_field_id.getAttribute('onchange') || l_field_id.onchange) {l_field_id.onchange()}
var l_field_value = opener.document.getElementById(v_page_display);
l_field_value.value = v_value;
if(l_field_value.getAttribute('onchange') || l_field_value.onchange) {l_field_value.onchange()}
close();
window.opener.doSubmit('POPUP_RELOAD');
}
</script>

APEX URL Syntax


http://apex.oracle.com/pls/apex/f?p=AppId:PageId:Session:Request:Debug:ClearCache:Params:ParamValues:PrinterFriendly

http:// the protocol, can be http or https

apex.oracle.com your domain/host/server, whatever you want to call it. Can also be localhost.

/pls indicates that you are using Oracle HTTP Server with mod_plsql. If you are using APEX Listener or Embedded PL/SQL Gateway this part
is obsolete/missing.

/apex the entry from your dads.conf file (this a file on your application-server or EPG where the target database is configured) in case of
EPG its just one entry pointing to localhost, in case of an OAS you can have multiple entries, each pointing to an other database

/f?p= procedure f is called and parameter p is set to the complete rest of the string. Remember: APEX uses mod_plsql. f is a public
procedure, this is the main entrypoint for APEX. Or you could say: f is APEX.

AppId the number or the Alias of the Application

:PageId the number or the Alias of the Page

:Session unique Session ID, can be 0 for Public Pages or empty (then APEX creates a new Session)

:Request a Request Keyword. This is basically free text, just a string you can specify to react in a process or region condition on. e.g. you
could pass the keyword CREATE and have a condition on the delete button of your page saying dontt display this button if request is
CREATE.
In other words: use the REQUEST to control the behaviour of your page.
When pressing a button, the button sets the REQUEST to the button-value (e.g. SAVE), so that you can control the processes in the page
processing (Submit) phase.

:Debug set to YES (uppercase!) switches on the Debug-Mode which renders debug-messages and timestamps in your Browser window. This
helps to detect wrong behaviour of your page or performance issues and everything else. Every other value then YES turns the Debug-Mode off

:ClearCache you can put a page id or a list of page ids here (comma-separated) to clear the cache for these pages (set session state to null,
). But there is more: RP resets the pagination of reports on the page(s), a collection name deletes the collection, APP clears all pages and
application-items, SESSION does the same as APP but for all applications the session-id has been used in.

:Parameters comma seperated list of page-item names. Good practice is to set only those page-items which are on the page you are going
to. Accepts page-items as well as application-items.

:ParamValues comma separated list of values. Each value is assigned to the corresponding Parameter provided in ParamNameList (first
value assigned to first parameter, second value assigned to second parameter, and so on).
The trick here is not having values which contain either a comma , or a colon :. Both would lead to side-effects and errors, as APEX gets
confused when parsing the URL. Using a comma works, if enclosed by slashes: e.g. \123,89\.

:PrinterFriendly set to YES (uppercase!) switches the page into PrinterFriendly-Mode, uses the Printerfriendly template to render the Page.
You can also hide regions or other elements in PrinterFriendly-Mode using the PRINTER_FRIENDLY variable in a condition.

When you post a page, you initiate Accept processing. Accept processing consists of
computations, validations, processes, and branches. The value of REQUESTis available
during each phase of the Accept processing. Once an application branches to a different
page then REQUEST is set to NULL.
The value of REQUEST is the name of the button the user clicks, or the name of the tab the
user selects. For example, suppose you have a button with a name of CHANGE, and a
label Apply Change. When a user clicks the button, the value of REQUEST is CHANGE.
Validations, processes, and branches have a When Button Pressed attribute. This attribute
displays as a select list and contains the names of buttons that exist on the current page.
If you make a selection from When Button Pressed, you associate the
button's REQUEST value with the validation, process, or branch.
When you use a button to submit a page, the REQUEST value is passed to the page. The
Accept processing logic evaluates each validation, process, and branch that uses a When
Button Pressed attribute to determine whether the component should run (or fire). When
one of these components runs, do not assume that a user actually clicked the associated
button and caused the page to be submitted. Keep in mind, that another button using the
same request value may have submitted the page. Similarly, JavaScript on the page can
also submit the page and pass in a request value.

Application Computations
Application Computations are units of logic that set
the value of a single page or application-level item
and are run at the same point across multiple
pages in an application. Like page-level
computation, application computations can be
based on static values, item values, PL/SQL, or
SQL.

apex.debug() vs apex_application.debug()
BTW, did you know that APEX 4.0 comes with a
simple JavaScript debugging/logging as well?
apex.debug('test message');
will write to console if debugging is enabled for
the current page. It can be used like on the
server with apex_application.debug.

You might also like