Skip to content

Instantly share code, notes, and snippets.

View esaounkine's full-sized avatar

Ilya Saunkin esaounkine

View GitHub Profile
@esaounkine
esaounkine / gist:948000
Created April 29, 2011 07:44
Silent Jasper print sample
public void createReport(String[] jasperFileUrls, Map parameters, JRDataSource ds, String type,
String selectedPrinter) {
Vector jasperPrintList = new Vector(0);
for(String s : jasperFileUrls) {
try {
jasperPrintList.add(JasperFillManager.fillReport((JasperReport)JRLoader.loadObject(s), parameters, ds));
System.out.println("Added report: " + s + " to the printlist");
}
catch(JRException jre) {
System.err.println("Failed to add the report '" + s + "' due to exception: " +
@esaounkine
esaounkine / SilentPrint.java
Created April 29, 2011 07:50
Silent Print with Jasper class
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRPrintServiceExporter;
import net.sf.jasperreports.engine.export.JRPrintServiceExporterParameter;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
public class SilentPrint {
@esaounkine
esaounkine / gist:948006
Created April 29, 2011 07:53
Oracle database schema data removal
SET SERVEROUTPUT ON SIZE 1000000
BEGIN
FOR cur_rec IN
(SELECT object_name,
object_type
FROM user_objects
WHERE object_type IN ('TABLE', 'VIEW', 'PACKAGE', 'PROCEDURE', 'FUNCTION', 'SEQUENCE', 'TRIGGER')
)
LOOP
BEGIN
@esaounkine
esaounkine / gist:948008
Created April 29, 2011 07:56
Clear an iterator in ADF 10g - definition
<iterator id="City1Iterator" RangeSize="-1"
Binds="City1" Refresh="always"
DataControl="AppModuleDataControl"/>
@esaounkine
esaounkine / gist:948009
Created April 29, 2011 07:58
Clear an iterator in ADF 10g - backing bean
javax.faces.context.FacesContext ctx = javax.faces.context.FacesContext.getCurrentInstance();
javax.faces.el.ValueBinding bind = ctx.getApplication().createValueBinding("#{data}");
oracle.adf.model.BindingContext bindingContext = (oracle.adf.model.BindingContext) bind.getValue(ctx); //resolve binding context
oracle.adf.model.binding.DCDataControl dataControl = bindingContext.findDataControl("AppModuleDataControl");//find data control by name (defined in DataBindings.cpx) from BindingContext
/*
* finally get the View Object instance which the iterator is bound to (see the attribute Binds in the iterator definition in the pageDef)
* then invoke the magic method executeEmptyRowSet on it
*/
((AppModuleImpl) dataControl.getDataProvider()).getCity1().executeEmptyRowSet();
@esaounkine
esaounkine / install service.bat
Created April 29, 2011 08:02
Install OAS as a Windows Service
rem To install the service with name OAS:
set ORACLE_HOME=C:\product\10.1.3.1\OracleAS_1
set CP=%ORACLE_HOME%\j2ee\home\oc4j.jar;%ORACLE_HOME%\jlib\startupconsole.jar;%ORACLE_HOME%\opmn\lib\optic.jar;%ORACLE_HOME%\lib\xmlparserv2.jar
javaservice -install OAS %ORACLE_HOME%\jdk\jre\bin\client\jvm.dll -Djava.class.path=%CP% -DORACLE_HOME=%ORACLE_HOME% -start oracle.appserver.startupconsole.view.Runner -params start -stop oracle.appserver.startupconsole.view.Runner -params stop -current %ORACLE_HOME%\j2ee\home\ -description "Oracle Application Server Service"
(in case the memory settings are not met (they are supposed to be taken from %ORACLE_HOME%\opmn\config\opmn.xml) add these 2 parameters
-XX:MaxPermSize=256m -Xmx256m right after the Java dll path)
rem To uninstall the service with name OAS:
@esaounkine
esaounkine / gist:948016
Created April 29, 2011 08:05
add showPopupBehavior to an ADF Rich Faces table column - ADF
<af:panelGroupLayout halign="center" layout="horizontal">
<af:panelFormLayout rows="1">
<af:commandButton text="#{msg.ADD}" id="add"
actionListener="#{CorpinfoBean.onAddAction}"
disabled="#{not empty CorpinfoBean.dirtyRows}"/>
<af:commandButton text="#{msg.DELETE}" id="delete">
<af:showPopupBehavior popupId="confirmDelete"
triggerType="action" align="afterStart"/>
</af:commandButton>
<af:commandButton text="#{msg.COMMIT}" id="commit"
@esaounkine
esaounkine / gist:948020
Created April 29, 2011 08:07
add showPopupBehavior to an ADF Rich Faces table column - snippet
<table varstatus="rowStat" value="#{SchedulerBean.localCollectionModel}"
fetchsize="25" contentdelivery="immediate"
rows="#{SchedulerBean.localCollectionModel.rowCount}"
emptytext="#{msg.SCHED_EMPTY_TABLE}" rowselection="single" width="100%"
var="row" rowbandinginterval="0" binding="#{SchedulerBean.schedTable}"
id="schedTable">
<column headertext="#{msg.ACTIONS}" sortable="false"
inlinestyle="background-color:#{(not empty row[SchedulerBean.columns[6].label] and row[SchedulerBean.columns[6].label] eq 'RUNNING'? '#00ff00' :'')};"
width="#{set.ACTIONS_COLUMN_WIDTH}">
<panelformlayout rows="1">
@esaounkine
esaounkine / gist:948023
Created April 29, 2011 08:08
add showPopupBehavior to an ADF Rich Faces table column - snippet
<table varstatus="rowStat" value="#{SchedulerBean.localCollectionModel}"
fetchsize="25" contentdelivery="immediate"
rows="#{SchedulerBean.localCollectionModel.rowCount}"
emptytext="#{msg.SCHED_EMPTY_TABLE}" rowselection="single" width="100%"
var="row" rowbandinginterval="0" binding="#{SchedulerBean.schedTable}"
id="schedTable">
<column headertext="#{msg.ACTIONS}" sortable="false"
inlinestyle="background-color:#{(not empty row[SchedulerBean.columns[6].label] and row[SchedulerBean.columns[6].label] eq 'RUNNING'? '#00ff00' :'')};"
width="#{set.ACTIONS_COLUMN_WIDTH}">
<panelformlayout rows="1">
@esaounkine
esaounkine / gist:948025
Created April 29, 2011 08:09
add showPopupBehavior to an ADF Rich Faces table column - backing
public void onDeleteConfirmation(oracle.adf.view.rich.event.DialogEvent de) {
if(de.getOutcome().equals(oracle.adf.view.rich.event.DialogEvent.Outcome.ok)) {
deleteSelectedRow();
FacesContext.getCurrentInstance().getApplication().getNavigationHandler().handleNavigation(FacesContext.getCurrentInstance(), "", "scheduler");
}
}