[OFBiz] SVN: r6545 - in trunk/framework/webtools: . src/org/ofbiz/webtools src/org/ofbiz/webtools/print src/org/ofbiz/webtools/print/applet src/org/ofbiz/webtools/print/rmi webapp/webtools webapp/webtools/WEB-INF webapp/webtools/applet webapp/webtools/print widget
jaz@svn.ofbiz.org
jaz at svn.ofbiz.org
Mon Jan 23 00:37:10 CST 2006
Author: jaz
Date: 2006-01-23 00:36:52 -0600 (Mon, 23 Jan 2006)
New Revision: 6545
Added:
trunk/framework/webtools/src/org/ofbiz/webtools/print/
trunk/framework/webtools/src/org/ofbiz/webtools/print/applet/
trunk/framework/webtools/src/org/ofbiz/webtools/print/applet/PdfPrintApplet.java
trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/
trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintRemote.java
trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintRemoteImpl.java
trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintServer.java
trunk/framework/webtools/webapp/webtools/applet/
trunk/framework/webtools/webapp/webtools/applet/readme.txt
trunk/framework/webtools/webapp/webtools/print/
trunk/framework/webtools/webapp/webtools/print/printDone.ftl
trunk/framework/webtools/webapp/webtools/print/printStart.ftl
Modified:
trunk/framework/webtools/build.xml
trunk/framework/webtools/webapp/webtools/
trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml
trunk/framework/webtools/webapp/webtools/WEB-INF/web.xml
trunk/framework/webtools/widget/CommonScreens.xml
Log:
added RMI FOP Print Server and Printer Client applet; can now print any screenfop type reports; the applet remembers the printer settings (using cookies on the browser) to auto-print each time it is run. This code requires GPL libraray JPedal which can be obtained from jpedal.org. Place this library in the build path for building as well as in /webtools/webapp/webtools/applet for client downloading. The applet code will also be placed in this directory when built. The applet should be run from a non-secure page.
Invoke using the following:
<!-- as a link -->
<#assign defaultServerRoot = Static["org.ofbiz.webapp.control.RequestHandler"].getDefaultServerRootUrl(request, false)>
<#assign screen = "component://product/widget/facility/ShipmentScreens.xml#PackingSlip.fo?shipmentId=" + shipment.shipmentId>
<a href="javascript:popUpPrint('${defaultServerRoot}', '${screen}');" class="linktext">Print</a>
<!-- auto run -->
<script language="javascript">
<#assign defaultServerRoot = Static["org.ofbiz.webapp.control.RequestHandler"].getDefaultServerRootUrl(request, false)>
<#assign screen = "component://product/widget/facility/ShipmentScreens.xml#PackingSlip.fo?shipmentId=" + shipment.shipmentId>
popUpPrint('${defaultServerRoot}', '${screen}');
</script>
The applet can support multiple reports to print. The java script pop up window will need to be modified to support the additional screens. The event accepts the parameter 'screen' and looks for the array of parameters.
Modified: trunk/framework/webtools/build.xml
===================================================================
--- trunk/framework/webtools/build.xml 2006-01-23 06:26:22 UTC (rev 6544)
+++ trunk/framework/webtools/build.xml 2006-01-23 06:36:52 UTC (rev 6545)
@@ -44,6 +44,7 @@
<path id="local.class.path">
<!--<fileset dir="${lib.dir}" includes="*.jar"/>-->
<fileset dir="../../base/lib" includes="*.jar"/>
+ <fileset dir="../../base/lib/commons" includes="*.jar"/>
<fileset dir="../../base/build/lib" includes="*.jar"/>
<fileset dir="../entity/lib" includes="*.jar"/>
<fileset dir="../entity/build/lib" includes="*.jar"/>
@@ -52,6 +53,7 @@
<fileset dir="../service/build/lib" includes="*.jar"/>
<fileset dir="../minilang/build/lib" includes="*.jar"/>
<fileset dir="../webapp/build/lib" includes="*.jar"/>
+ <fileset dir="../widget/build/lib" includes="*.jar"/>
</path>
</target>
@@ -85,11 +87,20 @@
<!-- ================================================================== -->
<target name="classes" depends="prepare,classpath">
- <javac debug="on" source="1.4" deprecation="on" destdir="${build.dir}/classes">
+ <condition property="noapplet" value="PdfPrintApplet.java">
+ <not>
+ <and>
+ <available classname="org.jpedal.PdfDecoder" classpathref="local.class.path" property="jpedel.avail"/>
+ <available classname="netscape.javascript.JSObject" classpathref="local.class.path" property="jsobject.avail"/>
+ </and>
+ </not>
+ </condition>
+ <javac debug="on" source="1.4" deprecation="on" destdir="${build.dir}/classes">
<classpath>
<path refid="local.class.path"/>
</classpath>
<src path="${src.dir}"/>
+ <exclude name="**/${noapplet}"/>
</javac>
<!-- also put the DTDs in the jar file... -->
<copy todir="${build.dir}/classes">
@@ -98,10 +109,33 @@
</copy>
</target>
- <target name="jar" depends="classes">
- <jar jarfile="${build.dir}/lib/${name}.jar" basedir="${build.dir}/classes"/>
+ <target name="stubs" depends="classes">
+ <rmic base="${build.dir}/classes" classname="org.ofbiz.webtools.print.rmi.FopPrintRemoteImpl">
+ <classpath>
+ <path refid="local.class.path"/>
+ </classpath>
+ </rmic>
</target>
+ <target name="main-jar" depends="stubs">
+ <jar jarfile="${build.dir}/lib/${name}.jar" basedir="${build.dir}/classes">
+ <fileset dir="${build.dir}/classes" excludes="org/ofbiz/webtools/print/**"/>
+ </jar>
+ </target>
+
+ <target name="print-jar" depends="stubs">
+ <jar jarfile="${build.dir}/lib/${name}-print.jar">
+ <fileset dir="${build.dir}/classes" includes="org/ofbiz/webtools/print/**"/>
+ </jar>
+ <signjar sectionsonly="true" keystore="../../base/config/ofbizssl.jks" storepass="changeit" keypass="changeit"
+ storetype="jks" jar="${build.dir}/lib/${name}-print.jar" alias="ssl"/>
+ <copy todir="webapp/webtools/applet">
+ <fileset file="${build.dir}/lib/${name}-print.jar"/>
+ </copy>
+ </target>
+
+ <target name="jar" depends="main-jar, print-jar"/>
+
<!-- ================================================================== -->
<!-- Build JavaDoc -->
<!-- ================================================================== -->
Added: trunk/framework/webtools/src/org/ofbiz/webtools/print/applet/PdfPrintApplet.java
===================================================================
--- trunk/framework/webtools/src/org/ofbiz/webtools/print/applet/PdfPrintApplet.java 2006-01-23 06:26:22 UTC (rev 6544)
+++ trunk/framework/webtools/src/org/ofbiz/webtools/print/applet/PdfPrintApplet.java 2006-01-23 06:36:52 UTC (rev 6545)
@@ -0,0 +1,472 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2001-2006 The Open For Business Project - www.ofbiz.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+package org.ofbiz.webtools.print.applet;
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.print.PrinterJob;
+import java.net.MalformedURLException;
+import java.net.URLEncoder;
+import java.net.URL;
+import java.rmi.Naming;
+import java.rmi.NotBoundException;
+import java.rmi.RemoteException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+import javax.print.Doc;
+import javax.print.DocFlavor;
+import javax.print.DocPrintJob;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.SimpleDoc;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.standard.PageRanges;
+import javax.swing.*;
+
+import org.jpedal.PdfDecoder;
+import org.jpedal.exception.PdfException;
+
+import org.ofbiz.webtools.print.rmi.FopPrintRemote;
+
+/**
+ * PdfPrintApplet
+ *
+ * @author <a href="mailto:jaz at ofbiz.org">Andy Zeneski</a>
+ * @version $Rev$
+ * @since 3.5
+ */
+public class PdfPrintApplet extends Applet {
+
+ public static final String module = PdfPrintApplet.class.getName();
+
+ protected DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
+ protected FopPrintRemote remote = null;
+
+ protected float scale = (float) 0.5770202;
+ protected boolean ready = true;
+
+ protected Exception exception = null;
+ protected String serverUrl = null;
+ protected String rmiHost = null;
+ protected String rmiName = null;
+ protected int rmiPort = 1099;
+
+ protected List printing = null;
+ protected Map urlMap = null;
+ protected Map ctx = null;
+
+
+ public void init() {
+ printing = new ArrayList();
+ ctx = new HashMap();
+
+ this.serverUrl = this.getParameter("server-url");
+ this.rmiName = this.getParameter("rmi-name");
+ this.rmiHost = this.getParameter("rmi-host");
+ this.rmiPort = Integer.parseInt(this.getParameter("rmi-port"));
+ this.loadRemote();
+ this.loadScreens();
+ this.initPrint();
+ }
+
+ public void paint(Graphics g) {
+ if (ready && exception == null) {
+ System.out.println("Calling paint()");
+ this.removeAll();
+ this.displayPrinting(g);
+ } else if (exception != null) {
+ g.setFont(new Font("Arial", Font.PLAIN, 11));
+ g.drawString("Error: " + exception.getMessage(), 10, 12);
+ }
+ }
+
+ protected void loadScreens() {
+ urlMap = new HashMap();
+ for (int x = 1; x < 11; x++) {
+ String printer = this.getParameter("printer." + x);
+ String screen = this.getParameter("screen." + x);
+ if (screen != null && screen.length() > 0) {
+ this.setToPrint(screen, printer);
+ }
+ }
+ }
+
+ protected void initPrint() {
+ this.ready = true;
+
+ Iterator a = urlMap.keySet().iterator();
+ while (a.hasNext()) {
+ String urlStr = (String) a.next();
+ String printer = (String) urlMap.get(urlStr);
+
+ if (printer == null || printer.length() == 0) {
+ // show setup info for this URL
+ ready = false;
+ System.out.println("Creating printer selection UI");
+
+ Font textFont = new Font("Arial", Font.PLAIN, 11);
+
+ // title label
+ Label preLabel = new Label("Print - ");
+ preLabel.setFont(textFont);
+ this.add(preLabel);
+
+ final Label urlLabel = new Label(urlStr);
+ urlLabel.setFont(textFont);
+ this.add(urlLabel);
+
+ Label postLabel = new Label(" to:");
+ postLabel.setFont(textFont);
+ this.add(postLabel);
+
+ // printer selection
+ PrintService[] svcs = this.getPrintServices();
+ final Choice svc = new Choice();
+ for (int v = 0; v < svcs.length; v++) {
+ svc.add(svcs[v].getName());
+ System.out.println("added - " + svcs[v].getName());
+ }
+ svc.add("No Printer");
+ this.add(svc);
+
+ // set button
+ Button set = new Button("Set");
+ set.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ String printer = svc.getSelectedItem();
+ String screen = urlLabel.getText();
+
+ System.out.println(e.getActionCommand());
+ System.out.println(screen);
+ System.out.println(printer);
+
+ if ("No Printer".equals(svc.getSelectedItem())) {
+ printer = "_NA_";
+ }
+ setToPrint(screen, printer);
+ initPrint();
+ }
+ });
+ this.add(set);
+ }
+ }
+
+ if (ready) {
+ Iterator i = urlMap.keySet().iterator();
+ while (i.hasNext()) {
+ String screenStr = (String) i.next();
+ String printer = (String) urlMap.get(screenStr);
+ try {
+ this.print(printer, screenStr);
+ } catch (Exception e) {
+ e.printStackTrace();
+ exception = e;
+ repaint();
+ }
+ }
+ }
+ }
+
+ public void print(final String printerName, final String screen) throws Exception {
+ printing.add(screen);
+
+ if (!"_NA_".equals(printerName)) {
+ Thread worker = new Thread() {
+ public void run() {
+ try {
+ PdfDecoder decoder = openPdf(getScreenUri(screen), getParameters(screen));
+ if (decoder != null) {
+ DocPrintJob job = createPrinterJob(printerName, decoder);
+ Doc printDoc = createPrintDoc(decoder);
+ job.print(printDoc, new HashPrintRequestAttributeSet());
+ }
+ } catch (NullPointerException e) {
+ e.printStackTrace();
+ exception = e;
+ repaint();
+ } catch (Exception e) {
+ e.printStackTrace();
+ exception = e;
+ repaint();
+ }
+ printing.remove(screen);
+ repaint();
+ }
+ };
+ worker.start();
+ } else {
+ printing.remove(screen);
+ }
+ }
+
+ protected void sendComplete() throws Exception {
+ StringBuffer buf = new StringBuffer();
+ Iterator i = urlMap.keySet().iterator();
+ int count = 1;
+ while (i.hasNext()) {
+ String screen = (String) i.next();
+ String printer = (String) urlMap.get(screen);
+ if (buf.length() > 0) {
+ buf.append("&");
+ }
+
+ // first the screen
+ buf.append("screen.");
+ buf.append(count);
+ buf.append("=");
+ buf.append(URLEncoder.encode(this.getScreenUri(screen), "UTF-8"));
+
+ // then the printer
+ buf.append("&printer.");
+ buf.append(count);
+ buf.append("=");
+ buf.append(URLEncoder.encode(printer, "UTF-8"));
+ }
+
+ String path = "/webtools/control/printComplete?" + buf.toString();
+ URL url = new URL(serverUrl + path);
+ this.getAppletContext().showDocument(url);
+ }
+
+ protected void displayPrinting(Graphics g) {
+ System.out.println("URL Map contents: " + urlMap);
+ if (printing.size() > 0) {
+ int count = 1;
+ int y = 0;
+ Iterator i = printing.iterator();
+ while (i.hasNext()) {
+ String screen = (String) i.next();
+ System.out.println("Displaying settings for screen: " + screen);
+ g.setFont(new Font("Arial", Font.PLAIN, 11));
+ g.drawString("Spooling [" + count + "] : ", 10, (y+=12));
+ g.drawString(screen, 20, (y+=10));
+ g.drawString("To printer : " + urlMap.get(screen), 30, (y+=12));
+ y+=5;
+ }
+ } else {
+ g.setFont(new Font("Sans", Font.BOLD, 11));
+ g.drawString("Print spooling done.", 10, 12);
+ try {
+ this.sendComplete();
+ } catch (Exception e) {
+ e.printStackTrace();
+ exception = e;
+ repaint();
+ }
+ }
+ }
+
+ protected void setToPrint(String screen, String printer) {
+ System.out.println("Document to print: " + screen + " @ " + printer);
+ urlMap.put(screen, printer);
+ }
+
+ protected PdfDecoder openPdf(String fileName) throws Exception {
+ PdfDecoder decoder = new PdfDecoder();
+ try {
+ decoder.openPdfFile(fileName);
+ this.initPdf(decoder);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw e;
+ }
+ return decoder;
+ }
+
+ protected PdfDecoder openPdf(String screen, Map parameters) throws Exception {
+ PdfDecoder decoder = new PdfDecoder();
+ if (remote == null) {
+ throw new Exception("No RMI connection available");
+ }
+ try {
+ // read the PDF from the RMI server
+ byte[] pdfBytes = remote.getFopPdf(screen, parameters);
+
+ // open the PDF
+ decoder.openPdfArray(pdfBytes);
+ this.initPdf(decoder);
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ throw e;
+ } catch (PdfException e) {
+ e.printStackTrace();
+ throw e;
+ }
+
+ return decoder;
+ }
+
+ protected void initPdf(PdfDecoder decoder) throws Exception {
+ // set the render display
+ decoder.setRenderMode(PdfDecoder.RENDERIMAGES + PdfDecoder.RENDERTEXT);
+ decoder.useHiResScreenDisplay(true);
+
+ // values extraction mode, dpi of images, dpi of page as a factor of 72
+ decoder.setExtractionMode(0, 72, scale);
+
+ // resize (ensure at least certain size)
+ decoder.setPageParameters(scale, 1, 0);
+
+ // add a border
+ decoder.setPDFBorder(BorderFactory.createLineBorder(Color.black, 1));
+ decoder.disableBorderForPrinting();
+ }
+
+ protected DocPrintJob createPrinterJob(String printerName, PdfDecoder decoder) throws Exception {
+ PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, null);
+ PrintService service = null;
+
+ for (int i = 0; i < services.length; i++) {
+ if (printerName.equals(services[i].getName())) {
+ service = services[i];
+ }
+ }
+
+ if (service != null) {
+ // setup print job
+ DocPrintJob printJob = service.createPrintJob();
+
+ // work around to get the decoder the page format object
+ decoder.setPageFormat(PrinterJob.getPrinterJob().defaultPage());
+
+ // page range setting
+ PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+ aset.add(new PageRanges(1, decoder.getPageCount()));
+
+ //set page range
+ PageRanges r = (PageRanges) aset.get(PageRanges.class);
+ if (r != null) {
+ decoder.setPagePrintRange(r);
+ }
+
+ return printJob;
+
+ } else {
+ throw new Exception("No available print service.");
+ }
+ }
+
+ protected void loadRemote() {
+ String location = "rmi://" + rmiHost + ":" + rmiPort + "/" + rmiName;
+ try {
+ this.remote = (FopPrintRemote) Naming.lookup(location);
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ exception = e;
+ repaint();
+ } catch (NotBoundException e) {
+ e.printStackTrace();
+ exception = e;
+ repaint();
+ } catch (RemoteException e) {
+ e.printStackTrace();
+ exception = e;
+ repaint();
+ }
+ }
+
+ protected PrintService[] getPrintServices() {
+ return PrintServiceLookup.lookupPrintServices(flavor, null);
+ }
+
+ protected Doc createPrintDoc(PdfDecoder decoder) {
+ return new SimpleDoc(decoder, flavor, null);
+ }
+
+ protected String getScreenUri(String screen) {
+ return screen.indexOf("?") != -1 ? screen.substring(0, screen.indexOf("?")) : screen;
+ }
+
+ protected Map getParameters(String screen) {
+ Map params = parseQueryString(screen.substring(screen.indexOf("?") + 1));
+ System.out.println("Parsed parameters: " + params);
+ return params;
+ }
+
+ private static String parseName(String s, StringBuffer sb) {
+ sb.setLength(0);
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ switch (c) {
+ case '+':
+ sb.append(' ');
+ break;
+ case '%':
+ try {
+ sb.append((char) Integer.parseInt(s.substring(i + 1, i + 3),
+ 16));
+ i += 2;
+ } catch (NumberFormatException e) {
+ // XXX
+ // need to be more specific about illegal arg
+ throw new IllegalArgumentException();
+ } catch (StringIndexOutOfBoundsException e) {
+ String rest = s.substring(i);
+ sb.append(rest);
+ if (rest.length() == 2)
+ i++;
+ }
+
+ break;
+ default:
+ sb.append(c);
+ break;
+ }
+ }
+ return sb.toString();
+ }
+
+ public static Map parseQueryString(String s) {
+ System.out.println("Parsing string: " + s);
+
+ if (s == null) {
+ throw new IllegalArgumentException();
+ }
+ HashMap ht = new HashMap();
+ StringBuffer sb = new StringBuffer();
+ StringTokenizer st = new StringTokenizer(s, "&");
+ while (st.hasMoreTokens()) {
+ String pair = st.nextToken();
+ System.out.println("Next token: " + pair);
+ int pos = pair.indexOf('=');
+ if (pos == -1) {
+ throw new IllegalArgumentException();
+ }
+ String key = parseName(pair.substring(0, pos), sb);
+ String val = parseName(pair.substring(pos + 1, pair.length()), sb);
+ System.out.println("Key: " + key + " / Val: " + val);
+
+ ht.put(key, val);
+ }
+ return ht;
+ }
+}
Property changes on: trunk/framework/webtools/src/org/ofbiz/webtools/print/applet/PdfPrintApplet.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Rev Author
Name: svn:eol-style
+ native
Added: trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintRemote.java
===================================================================
--- trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintRemote.java 2006-01-23 06:26:22 UTC (rev 6544)
+++ trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintRemote.java 2006-01-23 06:36:52 UTC (rev 6545)
@@ -0,0 +1,44 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2001-2006 The Open For Business Project - www.ofbiz.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+package org.ofbiz.webtools.print.rmi;
+
+import java.rmi.Remote;
+import java.rmi.RemoteException;
+import java.util.Map;
+
+/**
+ * FopPrintRemote
+ *
+ * @author <a href="mailto:jaz at ofbiz.org">Andy Zeneski</a>
+ * @version $Rev$
+ * @since 3.5
+ */
+public interface FopPrintRemote extends Remote {
+
+ public static final String module = FopPrintRemote.class.getName();
+
+ public byte[] getFopPdf(String screenUri, Map parameters) throws RemoteException;
+
+}
Property changes on: trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintRemote.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Rev Author
Name: svn:eol-style
+ native
Added: trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintRemoteImpl.java
===================================================================
--- trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintRemoteImpl.java 2006-01-23 06:26:22 UTC (rev 6544)
+++ trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintRemoteImpl.java 2006-01-23 06:36:52 UTC (rev 6545)
@@ -0,0 +1,103 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2001-2006 The Open For Business Project - www.ofbiz.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+package org.ofbiz.webtools.print.rmi;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.io.Writer;
+import java.rmi.RemoteException;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.rmi.server.UnicastRemoteObject;
+import java.util.Map;
+import java.util.Locale;
+
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.service.DispatchContext;
+import org.ofbiz.webapp.view.FopRenderer;
+import org.ofbiz.widget.html.HtmlScreenRenderer;
+import org.ofbiz.widget.screen.ScreenRenderer;
+
+/**
+ * FopPrintRemoteImpl
+ *
+ * @author <a href="mailto:jaz at ofbiz.org">Andy Zeneski</a>
+ * @version $Rev$
+ * @since 3.5
+ */
+public class FopPrintRemoteImpl extends UnicastRemoteObject implements FopPrintRemote {
+
+ public static final String module = FopPrintRemoteImpl.class.getName();
+ protected HtmlScreenRenderer htmlScreenRenderer = new HtmlScreenRenderer();
+ protected DispatchContext dctx = null;
+ protected Locale locale = null;
+
+ public FopPrintRemoteImpl(DispatchContext dctx, Locale locale, RMIClientSocketFactory csf, RMIServerSocketFactory ssf) throws RemoteException {
+ super(0, csf, ssf);
+ this.locale = locale;
+ this.dctx = dctx;
+ }
+
+ public byte[] getFopPdf(String screenUri, Map parameters) throws RemoteException {
+ // make sure the locale object is in the parameters
+ if (parameters.get("locale") == null) {
+ if (this.locale == null) {
+ this.locale = Locale.getDefault();
+ }
+ parameters.put("locale", locale);
+ }
+
+ Debug.log("Attempt to render screen [" + screenUri + "] using parameters: " + parameters, module);
+
+ // render and obtain the XSL-FO
+ Writer writer = new StringWriter();
+ try {
+ ScreenRenderer screens = new ScreenRenderer(writer, null, htmlScreenRenderer);
+ screens.populateContextForService(dctx, parameters);
+ screens.render(screenUri);
+ } catch (Throwable t) {
+ throw new RemoteException("Problems with the response writer/output stream", t);
+ }
+
+ // render the byte array
+ ByteArrayOutputStream out = null;
+ try {
+ out = FopRenderer.render(writer);
+ } catch (GeneralException e) {
+ throw new RemoteException(e.getMessage(), e.getNested());
+ }
+
+ byte[] bytes = out.toByteArray();
+ try {
+ out.close();
+ } catch (IOException e) {
+ throw new RemoteException("Problem closing output stream", e);
+ }
+
+ return bytes;
+ }
+}
Property changes on: trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintRemoteImpl.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Rev Author
Name: svn:eol-style
+ native
Added: trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintServer.java
===================================================================
--- trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintServer.java 2006-01-23 06:26:22 UTC (rev 6544)
+++ trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintServer.java 2006-01-23 06:36:52 UTC (rev 6545)
@@ -0,0 +1,252 @@
+/*
+ * $Id$
+ *
+ * Copyright (c) 2001-2006 The Open For Business Project - www.ofbiz.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+package org.ofbiz.webtools.print.rmi;
+
+import java.io.IOException;
+import java.rmi.Naming;
+import java.rmi.RemoteException;
+import java.rmi.server.RMIClientSocketFactory;
+import java.rmi.server.RMIServerSocketFactory;
+import java.util.Locale;
+import java.util.Map;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.collections.map.LinkedMap;
+
+import org.ofbiz.base.container.Container;
+import org.ofbiz.base.container.ContainerConfig;
+import org.ofbiz.base.container.ContainerException;
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.service.GenericDispatcher;
+import org.ofbiz.service.LocalDispatcher;
+
+/**
+ * FopPrintServer
+ *
+ * @author <a href="mailto:jaz at ofbiz.org">Andy Zeneski</a>
+ * @version $Rev$
+ * @since 3.5
+ */
+public class FopPrintServer implements Container {
+
+ public static final String module = FopPrintServer.class.getName();
+
+ protected FopPrintRemote remote = null;
+ protected String configFile = null;
+ protected String name = null;
+
+ // Container methods
+
+ /**
+ * @see org.ofbiz.base.container.Container#init(String[], String)
+ */
+ public void init(String[] args, String configFile) {
+ this.configFile = configFile;
+ }
+
+ public boolean start() throws ContainerException {
+ // get the container config
+ ContainerConfig.Container cfg = ContainerConfig.getContainer("rmi-dispatcher", configFile);
+ ContainerConfig.Container.Property initialCtxProp = cfg.getProperty("use-initial-context");
+ ContainerConfig.Container.Property lookupHostProp = cfg.getProperty("bound-host");
+ ContainerConfig.Container.Property lookupPortProp = cfg.getProperty("bound-port");
+ ContainerConfig.Container.Property lookupNameProp = cfg.getProperty("bound-name");
+ ContainerConfig.Container.Property delegatorProp = cfg.getProperty("delegator-name");
+ ContainerConfig.Container.Property clientProp = cfg.getProperty("client-factory");
+ ContainerConfig.Container.Property serverProp = cfg.getProperty("server-factory");
+
+ // check the required lookup-name property
+ if (lookupNameProp == null || lookupNameProp.value == null || lookupNameProp.value.length() == 0) {
+ throw new ContainerException("Invalid lookup-name defined in container configuration");
+ } else {
+ this.name = lookupNameProp.value;
+ }
+
+ // check the required delegator-name property
+ if (delegatorProp == null || delegatorProp.value == null || delegatorProp.value.length() == 0) {
+ throw new ContainerException("Invalid delegator-name defined in container configuration");
+ }
+
+ String useCtx = initialCtxProp == null || initialCtxProp.value == null ? "false" : initialCtxProp.value;
+ String host = lookupHostProp == null || lookupHostProp.value == null ? "localhost" : lookupHostProp.value;
+ String port = lookupPortProp == null || lookupPortProp.value == null ? "1099" : lookupPortProp.value;
+ boolean clientAuth = ContainerConfig.getPropertyValue(cfg, "ssl-client-auth", false);
+
+ // setup the factories
+ RMIClientSocketFactory csf = null;
+ RMIServerSocketFactory ssf = null;
+
+ // get the classloader
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+
+ // load the factories
+ if (clientProp != null && clientProp.value != null && clientProp.value.length() > 0) {
+ try {
+ Class c = loader.loadClass(clientProp.value);
+ csf = (RMIClientSocketFactory) c.newInstance();
+ } catch (Exception e) {
+ throw new ContainerException(e);
+ }
+ }
+ if (serverProp != null && serverProp.value != null && serverProp.value.length() > 0) {
+ try {
+ Class c = loader.loadClass(serverProp.value);
+ ssf = (RMIServerSocketFactory) c.newInstance();
+ } catch (Exception e) {
+ throw new ContainerException(e);
+ }
+ }
+
+ // set the client auth flag on our custom SSL socket factory
+ if (ssf != null && ssf instanceof org.ofbiz.service.rmi.socket.ssl.SSLServerSocketFactory) {
+ ((org.ofbiz.service.rmi.socket.ssl.SSLServerSocketFactory) ssf).setNeedClientAuth(clientAuth);
+ }
+
+ // get the delegator for this container
+ GenericDelegator delegator = GenericDelegator.getGenericDelegator(delegatorProp.value);
+
+ // create the LocalDispatcher
+ LocalDispatcher dispatcher = new GenericDispatcher(name, delegator);
+
+ // create the RemoteDispatcher
+ try {
+ remote = new FopPrintRemoteImpl(dispatcher.getDispatchContext(), Locale.getDefault(), csf, ssf);
+ } catch (RemoteException e) {
+ throw new ContainerException("Unable to start the RMI Print Server", e);
+ }
+
+ if (!useCtx.equalsIgnoreCase("true")) {
+ // bind RMIDispatcher to RMI Naming (Must be JRMP protocol)
+ try {
+ Naming.rebind("//" + host + ":" + port + "/" + name, remote);
+ } catch (RemoteException e) {
+ throw new ContainerException("Unable to bind RMI Print Server", e);
+ } catch (java.net.MalformedURLException e) {
+ throw new ContainerException("Invalid URL for binding", e);
+ }
+ } else {
+ // bind RMIDispatcher to InitialContext (must be RMI protocol not IIOP)
+ try {
+ InitialContext ic = new InitialContext();
+ ic.rebind(name, remote);
+ } catch (NamingException e) {
+ throw new ContainerException("Unable to bind RMI Print Server to JNDI", e);
+ }
+
+ // check JNDI
+ try {
+ InitialContext ic = new InitialContext();
+ Object o = ic.lookup(name);
+ if (o == null) {
+ throw new NamingException("Object came back null");
+ }
+ } catch (NamingException e) {
+ throw new ContainerException("Unable to lookup bound objects", e);
+ }
+ }
+
+ return true;
+ }
+
+ public void stop() throws ContainerException {
+ }
+
+ public static String readFopPrintServerCookies(HttpServletRequest req, HttpServletResponse resp) {
+ Map screenPrinterMap = new LinkedMap();
+ Cookie[] cookies = req.getCookies();
+
+ String[] screens = req.getParameterValues("screen");
+ for (int i = 0; i < screens.length; i++) {
+ for (int x = 0; x < cookies.length; x++) {
+ String screen = screens[i].indexOf("?") != -1 ?
+ screens[i].substring(0, screens[i].indexOf("?")) : screens[i];
+ Debug.log("Checking for cookie for FOP report: " + screen, module);
+
+ if (cookies[x].getName().equals("ofbiz.print." + screen)) {
+ String value = cookies[x].getValue();
+ if (value.startsWith("\"")) {
+ value = value.substring(1);
+ }
+ if (value.endsWith("\"")) {
+ value = value.substring(0, value.length() - 1);
+ }
+ screenPrinterMap.put(screens[i], value);
+ Debug.log("Found matching cookie", module);
+ printCookie(cookies[x]);
+ } else if (cookies[x].getName().startsWith("ofbiz.print")) {
+ printCookie(cookies[x]);
+ }
+ }
+ if (!screenPrinterMap.containsKey(screens[i])) {
+ Debug.log("No matching cookie found; setting printer to null");
+ screenPrinterMap.put(screens[i], null);
+ }
+ }
+
+ req.setAttribute("screenPrinterMap", screenPrinterMap);
+ Debug.log("Screen Printer Map - " + screenPrinterMap, module);
+ return "success";
+ }
+
+ public static String writeFopPrintServerCookies(HttpServletRequest req, HttpServletResponse resp) {
+ // get the screens used
+ for (int i = 1; i < 11; i++) {
+ // get the screens/printers used
+ String printer = req.getParameter("printer." + i);
+ String screen = req.getParameter("screen." + i);
+ if (screen != null) {
+ screen = screen.indexOf("?") != -1 ?
+ screen.substring(0, screen.indexOf("?")) : screen;
+
+ Cookie printCookie = new Cookie("ofbiz.print." + screen, printer);
+ printCookie.setMaxAge(60 * 60 * 24 * 365);
+ printCookie.setPath("/");
+ resp.addCookie(printCookie);
+ printCookie(printCookie);
+ }
+ }
+
+ return "success";
+ }
+
+ public static String return404(HttpServletRequest req, HttpServletResponse resp) {
+ try {
+ resp.sendError(404);
+ } catch (IOException e) {
+ Debug.logError(e, module);
+ }
+ return null;
+ }
+
+ private static void printCookie(Cookie cookie) {
+ Debug.log("Cookie - " + cookie.getName() + " = " + cookie.getValue() +
+ " ; " + cookie.getMaxAge() + " @ " + cookie.getPath(), module);
+ }
+}
Property changes on: trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintServer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Rev Author
Name: svn:eol-style
+ native
Property changes on: trunk/framework/webtools/webapp/webtools
___________________________________________________________________
Name: svn:ignore
+ ofbiz-webtools-print.jar
14_os_jpedal.jar
Modified: trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml
===================================================================
--- trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml 2006-01-23 06:26:22 UTC (rev 6544)
+++ trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml 2006-01-23 06:36:52 UTC (rev 6545)
@@ -437,6 +437,32 @@
<response name="error" type="view" value="EntitySyncStatus"/>
</request-map>
+ <!-- printing requests -->
+ <request-map uri="print">
+ <event type="java" path="org.ofbiz.webtools.print.rmi.FopPrintServer" invoke="readFopPrintServerCookies"/>
+ <response name="success" type="view" value="printStart"/>
+ <response name="error" type="view" value="error"/>
+ </request-map>
+ <request-map uri="printComplete">
+ <event type="java" path="org.ofbiz.webtools.print.rmi.FopPrintServer" invoke="writeFopPrintServerCookies"/>
+ <response name="success" type="view" value="printDone"/>
+ <response name="error" type="view" value="error"/>
+ </request-map>
+ <request-map uri="META-INF">
+ <event type="java" path="org.ofbiz.webtools.print.rmi.FopPrintServer" invoke="return404"/>
+ <response name="success" type="none"/>
+ <response name="error" type="none"/>
+ </request-map>
+ <request-map uri="com">
+ <event type="java" path="org.ofbiz.webtools.print.rmi.FopPrintServer" invoke="return404"/>
+ <response name="success" type="none"/>
+ <response name="error" type="none"/>
+ </request-map>
+ <request-map uri="org">
+ <event type="java" path="org.ofbiz.webtools.print.rmi.FopPrintServer" invoke="return404"/>
+ <response name="success" type="none"/>
+ <response name="error" type="none"/>
+ </request-map>
<!-- end of request mappings -->
<!-- View Mappings -->
@@ -494,6 +520,9 @@
<view-map name="availableServices" type="screen" page="component://webtools/widget/AvailableServicesScreens.xml#AvailableServicesList"/>
<view-map name="serviceEcaDetail" type="screen" page="component://webtools/widget/AvailableServicesScreens.xml#ServiceEcaDetail"/>
+ <view-map name="printStart" type="screen" page="component://webtools/widget/CommonScreens.xml#printStart"/>
+ <view-map name="printDone" type="screen" page="component://webtools/widget/CommonScreens.xml#printDone"/>
+
<view-map name="UomReport" page="/UomReport.xml" type="datavision" info="Uom"/>
<view-map name="JasperDemoPdf" page="/JasperDemo.xml" type="jasperreportspdf" info="Uom"/>
<view-map name="JasperDemoXml" page="/JasperDemo.xml" type="jasperreportsxml" info="Uom"/>
Modified: trunk/framework/webtools/webapp/webtools/WEB-INF/web.xml
===================================================================
--- trunk/framework/webtools/webapp/webtools/WEB-INF/web.xml 2006-01-23 06:26:22 UTC (rev 6544)
+++ trunk/framework/webtools/webapp/webtools/WEB-INF/web.xml 2006-01-23 06:36:52 UTC (rev 6545)
@@ -58,7 +58,7 @@
</init-param>
<init-param>
<param-name>allowedPaths</param-name>
- <param-value>/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/images:/includes/maincss.css</param-value>
+ <param-value>/control:/select:/index.html:/index.jsp:/default.html:/default.jsp:/applet:/includes/maincss.css</param-value>
</init-param>
<init-param>
<param-name>errorCode</param-name>
Property changes on: trunk/framework/webtools/webapp/webtools/applet
___________________________________________________________________
Name: svn:ignore
+ ofbiz-webtools-print.jar
14_os_jpedal.jar
Added: trunk/framework/webtools/webapp/webtools/applet/readme.txt
===================================================================
--- trunk/framework/webtools/webapp/webtools/applet/readme.txt 2006-01-23 06:26:22 UTC (rev 6544)
+++ trunk/framework/webtools/webapp/webtools/applet/readme.txt 2006-01-23 06:36:52 UTC (rev 6545)
@@ -0,0 +1,3 @@
+This direcotry hold libraries for webtools related applets. Currently the printing applet files will live here.
+You must download and copy the GPL library JPedal.jar and place it in this directory. The webtools applet files
+will get copied here on build.
Property changes on: trunk/framework/webtools/webapp/webtools/applet/readme.txt
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ "Id Rev Author"
Name: svn:eol-style
+ native
Added: trunk/framework/webtools/webapp/webtools/print/printDone.ftl
===================================================================
--- trunk/framework/webtools/webapp/webtools/print/printDone.ftl 2006-01-23 06:26:22 UTC (rev 6544)
+++ trunk/framework/webtools/webapp/webtools/print/printDone.ftl 2006-01-23 06:36:52 UTC (rev 6545)
@@ -0,0 +1,35 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!-- Copyright (c) 2001-2005 The Open For Business Project - www.ofbiz.org -->
+<#--
+ * Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *@author Andy Zeneski (jaz at ofbiz.org)
+ *@version $Rev$
+ *@since 3.5
+-->
+
+<html>
+ <body>
+ <script language="javascript">
+ window.close();
+ </script>
+ </body>
+</html>
Property changes on: trunk/framework/webtools/webapp/webtools/print/printDone.ftl
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Rev Author
Name: svn:eol-style
+ native
Added: trunk/framework/webtools/webapp/webtools/print/printStart.ftl
===================================================================
--- trunk/framework/webtools/webapp/webtools/print/printStart.ftl 2006-01-23 06:26:22 UTC (rev 6544)
+++ trunk/framework/webtools/webapp/webtools/print/printStart.ftl 2006-01-23 06:36:52 UTC (rev 6545)
@@ -0,0 +1,82 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<!-- Copyright (c) 2001-2005 The Open For Business Project - www.ofbiz.org -->
+<#--
+ * Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *@author Andy Zeneski (jaz at ofbiz.org)
+ *@version $Rev$
+ *@since 3.5
+-->
+<#assign serverRoot = Static["org.ofbiz.base.util.UtilHttp"].getInitialServerRootUrl(request)>
+<#assign serverHost = request.getServerName()>
+<#assign screenMap = (requestAttributes.screenPrinterMap)?if_exists>
+<#assign screens = (screenMap.keySet())?if_exists>
+<#assign auto = "true">
+<#assign count = 1>
+<html>
+ <body>
+ <center>
+ <#if screens?has_content>
+ <object align="center" height="200" width="600" classid="java:org.ofbiz.webtools.print.applet.PdfPrintApplet"
+ type="application/x-java-applet" mayscript="true" archive="/webtools/applet/ofbiz-webtools-print.jar, /webtools/applet/14_os_jpedal.jar"
+ codebase="/webtools/applet" server-url= "${serverRoot}" rmi-name="RMIFopPrintServer" rmi-host="${serverHost}" rmi-port="1099"
+ <#list screens as screen>
+ <#assign printer = screenMap.get(screen)?if_exists>
+ <#if printer?has_content>
+ printer.${count}="${printer}"
+ <#else>
+ <#assign auto = "false">
+ </#if>
+ screen.${count}="${screen}"
+ </#list>>
+
+ <object align="center" height="200" width="600" classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93">
+ <param name="archive" value="/webtools/applet/ofbiz-webtools-print.jar, /webtools/applet/14_os_jpedal.jar">
+ <param name="codebase" value="/webtools/applet">
+ <param name="code" value="org.ofbiz.webtools.print.applet.PdfPrintApplet">
+ <param name="mayscript" value="true">
+ <param name="server-url" value="${serverRoot}">
+ <param name="rmi-name" value="RMIFopPrintServer">
+ <param name="rmi-host" value="${serverHost}">
+ <param name="rmi-port" value="1099">
+ <#list screens as screen>
+ <#assign printer = screenMap.get(screen)?if_exists>
+ <#if printer?has_content>
+ <param name="printer.${count}" value="${printer}">
+ <#else>
+ <#assign auto = "false">
+ </#if>
+ <param name="screen.${count}" value="${screen}">
+
+ </#list>
+ </object>
+ </object>
+ <#else>
+ <p>Nothing to print.</p>
+ </#if>
+ <#if auto == "true">
+ <script language="javascript">
+ window.opener.focus();
+ </script>
+ </#if>
+ </center>
+ </body>
+</html>
Property changes on: trunk/framework/webtools/webapp/webtools/print/printStart.ftl
___________________________________________________________________
Name: svn:mime-type
+ text/html
Name: svn:keywords
+ Id Rev Author
Name: svn:eol-style
+ native
Modified: trunk/framework/webtools/widget/CommonScreens.xml
===================================================================
--- trunk/framework/webtools/widget/CommonScreens.xml 2006-01-23 06:26:22 UTC (rev 6544)
+++ trunk/framework/webtools/widget/CommonScreens.xml 2006-01-23 06:36:52 UTC (rev 6545)
@@ -66,5 +66,20 @@
</widgets>
</section>
</screen>
+
+ <screen name="printStart">
+ <section>
+ <widgets>
+ <platform-specific><html><html-template location="component://webtools/webapp/webtools/print/printStart.ftl"/></html></platform-specific>
+ </widgets>
+ </section>
+ </screen>
+ <screen name="printDone">
+ <section>
+ <widgets>
+ <platform-specific><html><html-template location="component://webtools/webapp/webtools/print/printDone.ftl"/></html></platform-specific>
+ </widgets>
+ </section>
+ </screen>
</screens>
More information about the Svn
mailing list