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});

No comments: