Thursday, February 19, 2009

Using CGI Environment Variable in APEX

If you execute the following in SQL Workshop of APEX you will get a list of the variables that are available for use.

begin
OWA_UTIL.PRINT_CGI_ENV;
end;

This will return:

PLSQL_GATEWAY = WebDb

GATEWAY_IVERSION = 2

SERVER_SOFTWARE = Oracle Embedded PL/SQL Gateway/11.1.0.6.0

GATEWAY_INTERFACE = CGI/1.1

SERVER_PORT = 8080

SERVER_NAME = XDB HTTP Server

REQUEST_METHOD = POST

PATH_INFO = /wwv_flow.show

SCRIPT_NAME = /apex

REMOTE_HOST =

REMOTE_ADDR = 10.26.0.97

SERVER_PROTOCOL = HTTP/1.1

REQUEST_PROTOCOL = HTTP

REMOTE_USER = ANONYMOUS

ORACLE_SSO_USER =

HTTP_CONTENT_LENGTH = 285

HTTP_CONTENT_TYPE = application/x-www-form-urlencoded; charset=UTF-8

HTTP_USER_AGENT = Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6 (.NET CLR 3.5.30729)

HTTP_HOST = sparrow.hidinc.com:8080

HTTP_ACCEPT = text/html

HTTP_ACCEPT_ENCODING = gzip

HTTP_ACCEPT_LANGUAGE = en-us

HTTP_ACCEPT_CHARSET = ISO-8859-1

HTTP_REFERER = http://sparrow.hidinc.com:8080/apex/f?p=4500:1003:3536261107957055::NO:::

WEB_AUTHENT_PREFIX =

DAD_NAME = apex

DOC_ACCESS_PATH = docs

DOCUMENT_TABLE = wwv_flow_file_objects$

PATH_ALIAS =

REQUEST_CHARSET = AL32UTF8

REQUEST_IANA_CHARSET = UTF-8

SCRIPT_PREFIX =

HTTP_COOKIE = WWV_CUSTOM-F_4752219103344869_117=336B3BAFD41DE0F0; WWV_CUSTOM-F_4752219103344869_113=C7DAB25C26BF73CF; WWV_CUSTOM-F_988309881576256_1000=6F199DA1AEF14FB0; WWV_CUSTOM-F_4752219103344869_114=C544CAFF903CDE0F; oracle.uix=0^^GMT-6:00; activity_ask_expert=1|9500346262672; ORA_WWV_USER=336B3BAFD41DE0F0; ORA_WWV_REMEMBER_UN=BRIAN.BURDITT:BRIAN_TEST; ORA_WWV_ATTRIBUTE_PAGE=4301%2C%23HEAD; LOGIN_USERNAME_COOKIE=brian.burditt; ORA_WWV_R1=%23ALL; ORA_WWV_R2=%23ALL; ORA_WWV_R3=%23ALL


This can now be used with owa_util.get_cgi_env() for validations on these items.

Wednesday, February 18, 2009

Issues with APEX/AJAX/Extjs

TOPICS

APEX

AJAX

Application Process / On Demand

Ext.tree.AsyncTreeNode

Ext.tree.TreeLoader

Ext.tree.TreePanel


Application Process / On Demand
---------------------------------------

DECLARE v_Return CLOB;  l_nStartPostion NUMBER(22,0) := 1;  l_nEndPostion   NUMBER(22,0);  l_vcBuffer      VARCHAR2(32767);  l_TotalLength   NUMBER(22,0);
BEGIN --set up owa_util.mime_header('text/html', FALSE ); htp.p('Cache-Control: no-cache'); htp.p('Pragma: no-cache'); owa_util.http_header_close;
--Get JSON string --[{"text":"My folder","id":"10","cls":".folder","leaf":false},{"text":"another folder","id":"11","cls":".folder","leaf":false}]
v_Return:= PKG_REPORT_REPOSITORY.PFUNC_GET_NODE_CHILDREN(wwv_flow.g_x01);
--What is the total length of the JSON string l_TotalLength := dbms_lob.getlength(v_Return); --Set the end postion l_nEndPostion:= 30000;
--cycle until we are at the end WHILE l_nEndPostion <= l_TotalLength LOOP l_vcBuffer := dbms_lob.substr (v_Return ,l_nEndPostion-l_nStartPostion + 1 ,l_nStartPostion ); --send the output htp.p(l_vcBuffer ); --reset the start and end l_nStartPostion := l_nEndPostion +1 ; l_nEndPostion := l_nEndPostion +30000; END LOOP; l_vcBuffer := dbms_lob.substr(v_Return,l_TotalLength-l_nStartPostion +1,l_nStartPostion ); htp.p(l_vcBuffer);
END;


Ext.tree.TreeLoader

------------------------------
// Create user extensions namespace (Ext.hid)//Ext.hid.TreeLoader.jsExt.namespace('Ext.hid'); /** * Ext.hid.TreeLoader Extension Class * * @author Daniel Moody * @version 1.0 * * @class Ext.hid.TreeLoader * @extends Ext.tree.TreeLoader * @constructor * @param {Object} config Configuration options */Ext.hid.TreeLoader = function(config) { // call parent constructor Ext.hid.TreeLoader.superclass.constructor.call(this, config);}; // end of Ext.hid.TreeLoader constructor
// extendExt.extend(Ext.hid.TreeLoader, Ext.tree.TreeLoader,{ nodeParamName:"node",
getParams:function(D){var A=[],C=this.baseParams;for(var B in C){if(typeof C[B]!="function"){A.push(encodeURIComponent(B),"=",encodeURIComponent(C[B]),"&");}}A.push(this.nodeParamName + "=",encodeURIComponent(D.id));return A.join("");}
}); // end of extend // end of file

Ext application
----------------------------

.

.

.
var u = (window.location.href.indexOf("?") > 0) ? window.location.href.substring(0,window.location.href.indexOf("?")) : window.location.href;var baseURL = u.substring(0,u.lastIndexOf("/"));baseURL = baseURL + '/wwv_flow.show?p_flow_id=' + Ext.getDom('pFlowId').value + '&p_flow_step_id=0&p_instance=' + Ext.getDom('pInstance').value + '&p_request=APPLICATION_PROCESS=GET_NODE_CHILDREN'; myTreeLoader = new Ext.hid.TreeLoader( {dataUrl:baseURL,nodeParamName: 'x01'} );
myRoot = new Ext.tree.AsyncTreeNode({ id:'0', text:'Report Repository', split:true}); myTree = new Ext.tree.TreePanel({ id:'im-tree', width:200, split: true, region: 'west', title: 'Folders', loader: myTreeLoader, rootVisible:true, lines:true, autoScroll:true, root: myRoot});