Friday, January 15, 2010

extjs & jquery & Oracle Apex

To get the grid "dynamic" try somthing like (assuming that you use the jQuery adapter) this:

Ext.onReady(function() {
 jQuery("table.standardalternatingrowcolors",this).each(function(){
 var table = this;
 // create the data array
 var myData = new Array();
 jQuery('tr[td]',table).each(function(){
   var tr = new Array();
   jQuery('td', this).each(function(){  
     tr[tr.length] = jQuery(this).html();
   });
   myData[myData.length] = tr;
 });
 // create the metadata array
 var myHeaders = new Array;
 jQuery('tr[th]',table).each(function(){
   jQuery('th', this).each(function(){  
     var header = {};
     header["name"] = jQuery(this).attr('id');
     header["dataIndex"] = jQuery(this).attr('id');
     header["header"] = jQuery(this).html();
     header["sortable"] = true;
     header["width"] = 90;
     myHeaders[myHeaders.length] = header;
   });
 });
 
  var ds = new Ext.data.Store({
   proxy: new Ext.data.MemoryProxy(myData),
   reader: new Ext.data.ArrayReader({id: 0}, myHeaders)
  });
  ds.load();
 
  var colModel = new Ext.grid.ColumnModel(myHeaders);
  jQuery(table).attr(id,'x');
  var grid = new Ext.grid.GridPanel({el: 'grid-example', ds: ds, cm: colModel});
  grid.render();
  grid.getSelectionModel().selectFirstRow();
  jQuery(table).show();
 
 }); // replace each table on the page
 
});

FOP & JBoss & Oracle Apex

Add the missing Oracle XML Parser v2 (you may find them e.g. in JDeveloper/lib) libraries (lib/xmlparserv2.jar, lib/xml.jar) by opening the fop.war with your favorite zip program (e.g. rename fop.war to fop.zip) and saving the libraries WEB-INF/lib. Then copy the fop.war to the e.g. jboss\server\default\deploy directory. Maybe you have to restart your application server (dependent on your settings). Then try http://your-hostname:your-port/fop/apex_fop.jsp (e.g. http://127.0.0.1:8080/fop/apex_fop.jsp) to see if your work was successful.

Manage Service / Instance Settings / Report Printing
Print Server: Standard Support
Print Server Host Address: 127.0.0.1
Print Server Port:8080
Print Server Script: /fop/apex_fop.jsp

<%@ page import='java.io.*'%>
<%@ page import='org.xml.sax.InputSource'%>
<%@ page import='org.apache.fop.apps.Driver'%>
<%@ page import='org.apache.fop.apps.Options'%>
<%@ page import='oracle.xml.parser.v2.XMLDocument'%>
<%@ page import='oracle.xml.parser.v2.XSLProcessor'%>
<%@ page import='oracle.xml.parser.v2.XSLStylesheet'%>
<%@ page import='oracle.xml.parser.v2.DOMParser'%>
<%
// see http://xml.apache.org/fop/output.html for all output types
XMLDocument   v_doc;
XSLStylesheet v_xsl = null;
String        v_fop;
DOMParser     parser = new DOMParser();
XSLProcessor processor = new XSLProcessor();
String        v_encode = "UTF-8";
 
String p_xsl = request.getParameter("template");
String p_xml = request.getParameter("xml");
 
/* transform an XML source to XSLFO using an XSL transformation */
v_xsl = new XSLStylesheet(new java.io.StringReader(p_xsl),null);
parser.parse(new java.io.StringReader(p_xml));
v_doc = parser.getDocument();
ByteArrayOutputStream v_out = new ByteArrayOutputStream();
processor.processXSL(v_xsl, v_doc, v_out);
v_fop = new String(v_out.toByteArray(),v_encode);
 
/* The FOP process */
Driver driver = new Driver();
driver.setRenderer(Driver.RENDER_PDF);
 
driver.setInputSource(new InputSource(new StringReader(v_fop)));
 
ByteArrayOutputStream outBuffer = new ByteArrayOutputStream();
driver.setOutputStream(outBuffer);
 
driver.run();
 
OutputStream outStream = response.getOutputStream();
response.setContentType("application/pdf");
response.setContentLength(outBuffer.size());
outStream.write(outBuffer.toByteArray());
outStream.flush();
%>

jQuery autocomplete and Oracle Apex

Here you can find some code if you want to use the jquery.autocomplete.js without modification.
Download the autocomplete jQuery plugin and upload then to your "Shared Components"/"Cascading Style Sheets".
Also upload the basic jquery library there.

Download Links:
http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/
http://jquery.com/

Add the following to your Page HTML Header where you want to use the autocomplete list:







This looks complex, but the only thing your have to change is to change the name of the item where you want to have a autocomplete list

Tuesday, January 12, 2010

Paging with SQL mysql: startrow and maxrows
SELECT * FROM person ORDER BY LAST_NAME DESC LIMIT 11, 10
oracle: startrow and endrow
SELECT s.*
FROM (
 SELECT ROWNUM as COUNTER, x.*
 FROM (
  SELECT p.NAME, p.FIRST_NAME, p.LAST_NAME
  FROM person p
  ORDER BY p.LAST_NAME DESC
 ) x
) s
WHERE s.COUNTER BETWEEN 5 AND 8;