[OFBiz] SVN: r6578 - in trunk/framework/webtools: . src/org/ofbiz/webtools/print/applet src/org/ofbiz/webtools/print/rmi webapp/webtools/WEB-INF webapp/webtools/applet webapp/webtools/print
jaz@svn.ofbiz.org
jaz at svn.ofbiz.org
Wed Jan 25 11:44:43 CST 2006
Author: jaz
Date: 2006-01-25 11:44:37 -0600 (Wed, 25 Jan 2006)
New Revision: 6578
Added:
trunk/framework/webtools/src/org/ofbiz/webtools/print/applet/FopPrintApplet.java
Modified:
trunk/framework/webtools/build.xml
trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintServer.java
trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml
trunk/framework/webtools/webapp/webtools/applet/
trunk/framework/webtools/webapp/webtools/print/printDone.ftl
trunk/framework/webtools/webapp/webtools/print/printStart.ftl
Log:
updated printer applet; now used FOP and renders on the client
Modified: trunk/framework/webtools/build.xml
===================================================================
--- trunk/framework/webtools/build.xml 2006-01-25 16:22:53 UTC (rev 6577)
+++ trunk/framework/webtools/build.xml 2006-01-25 17:44:37 UTC (rev 6578)
@@ -88,20 +88,11 @@
<!-- ================================================================== -->
<target name="classes" depends="prepare,classpath">
- <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">
@@ -128,11 +119,21 @@
<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"/>
+ <fileset file="../../base/lib/avalon-framework-4.1.5.jar"/>
+ <fileset file="../../base/lib/commons/commons-codec.jar"/>
+ <fileset file="../../base/lib/commons/commons-cli.jar"/>
+ <fileset file="../webapp/lib/barcode4j-fop-ext-0.20.5-complete.jar"/>
+ <fileset file="../webapp/lib/batik.jar"/>
+ <fileset file="../webapp/lib/fop.jar"/>
</copy>
+
+ <!-- change this to use your personal certificate -->
+ <signjar sectionsonly="true" keystore="../../base/config/ofbizssl.jks"
+ storepass="changeit" keypass="changeit" storetype="jks" alias="ssl">
+ <fileset dir="webapp/webtools/applet" includes="*.jar"/>
+ </signjar>
</target>
<target name="jar" depends="main-jar, print-jar"/>
Added: trunk/framework/webtools/src/org/ofbiz/webtools/print/applet/FopPrintApplet.java
===================================================================
--- trunk/framework/webtools/src/org/ofbiz/webtools/print/applet/FopPrintApplet.java 2006-01-25 16:22:53 UTC (rev 6577)
+++ trunk/framework/webtools/src/org/ofbiz/webtools/print/applet/FopPrintApplet.java 2006-01-25 17:44:37 UTC (rev 6578)
@@ -0,0 +1,530 @@
+/*
+ * $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 print;
+package org.ofbiz.webtools.print.applet;
+
+import java.awt.*;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLEncoder;
+import java.rmi.Naming;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.StringTokenizer;
+import java.util.Vector;
+import javax.print.Doc;
+import javax.print.DocFlavor;
+import javax.print.DocPrintJob;
+import javax.print.PrintException;
+import javax.print.PrintService;
+import javax.print.PrintServiceLookup;
+import javax.print.ServiceUI;
+import javax.print.SimpleDoc;
+import javax.print.attribute.DocAttributeSet;
+import javax.print.attribute.HashDocAttributeSet;
+import javax.print.attribute.HashPrintRequestAttributeSet;
+import javax.print.attribute.PrintRequestAttributeSet;
+import javax.print.attribute.standard.Copies;
+import javax.print.attribute.standard.JobName;
+import javax.swing.*;
+
+import org.apache.fop.apps.Driver;
+import org.apache.fop.layout.Page;
+import org.apache.fop.render.awt.AWTRenderer;
+import org.apache.commons.codec.binary.Base64;
+import org.xml.sax.InputSource;
+
+import org.ofbiz.webtools.print.rmi.FopPrintRemote;
+
+/**
+ * FopPrinter
+ *
+ * @author <a href="mailto:jaz at ofbiz.org">Andy Zeneski</a>
+ * @version $Rev$
+ * @since Jan 23, 2006
+ */
+public class FopPrintApplet extends JApplet {
+
+ public static final String module = FopPrintApplet.class.getName();
+
+ protected DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PAGEABLE;
+ protected String requestPath = "/webtools/control/getXslFo";
+ protected String serverUrl = null;
+ protected String rmiHost = null;
+ protected String rmiName = null;
+ protected int rmiPort = 1099;
+ protected boolean resetCookies = false;
+ protected boolean started = false;
+
+ protected List printing = new ArrayList();
+ protected Map jobQueue = new HashMap();
+ protected Map toPrint = new HashMap();
+
+ public void init(Map toPrint, String serverUrl, String rmiName, String rmiHost, int rmiPort, boolean reset) {
+ this.serverUrl = serverUrl;
+ this.rmiName = rmiName;
+ this.rmiHost = rmiHost;
+ this.rmiPort = rmiPort;
+ this.toPrint = toPrint;
+ this.resetCookies = reset;
+ }
+
+ public void init() {
+ int port = 1099;
+ if (this.getParameter("rmi-port") != null) {
+ try {
+ port = Integer.parseInt(this.getParameter("rmi-port"));
+ } catch (NumberFormatException e) {
+ }
+ }
+
+ String serverUrl = this.getParameter("server-url");
+ String rmiName = this.getParameter("rmi-name");
+ String rmiHost = this.getParameter("rmi-host");
+ String reset = this.getParameter("reset-cookies");
+ boolean resetCookies = reset != null && "true".equalsIgnoreCase(reset);
+
+ Map toPrint = new HashMap();
+ boolean look = true;
+ int count = 1;
+ while (look) {
+ String printer = this.getParameter("printer." + count);
+ String screen = this.getParameter("screen." + count);
+ if (screen != null && screen.length() > 0) {
+ toPrint.put(screen, printer);
+ count++;
+ } else {
+ look = false;
+ }
+ }
+ this.init(toPrint, serverUrl, rmiName, rmiHost, port, resetCookies);
+ }
+
+ public void paint(Graphics g) {
+ if (!started) {
+ started = true;
+ Thread worker = new Thread() {
+ public void run() {
+ processJobs();
+ }
+ };
+ worker.start();
+ } else {
+ this.removeAll();
+ }
+
+ g.setFont(new Font("Arial", Font.BOLD, 18));
+ g.drawString("Print spooler started sith [" + jobQueue.size() + "] jobs queued...", 70, 70);
+ }
+
+ protected void processJobs() {
+ Iterator i = toPrint.keySet().iterator();
+ while (i.hasNext()) {
+ String screen = (String) i.next();
+ String printer = (String) toPrint.get(screen);
+
+ String screenUri = this.getScreenUri(screen);
+ PrintService service = this.getPrintService(screenUri, printer);
+ if (service != null) {
+ jobQueue.put(screenUri, service);
+ this.repaint();
+
+ try {
+ this.printFo((rmiHost == null ? serverUrl : rmiHost), screen);
+ } catch (Exception e) {
+ e.printStackTrace();
+ this.getAppletContext().showStatus("Unable to render print job.");
+ }
+ } else {
+ System.out.println("No printer for job: " + screenUri);
+ this.getAppletContext().showStatus("No printer(s) available.");
+ }
+ }
+
+ if (jobQueue.size() == 0) {
+ try {
+ this.sendComplete();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ this.repaint();
+ }
+
+ protected void printFo(String url, String screenUrl) throws Exception {
+ if (url.startsWith("http")) {
+ this.printFoFromHttp(url, screenUrl);
+ } else if (url.startsWith("rmi")) {
+ this.printFoFromRmi(url, screenUrl);
+ } else {
+ this.getAppletContext().showStatus("Unsupported protocol used.");
+ }
+ }
+
+ protected void printFoFromRmi(String lookup, String screenUrl) throws Exception {
+ InputSource source = this.getScreenFromRmi(lookup, screenUrl);
+ this.renderFO(this.getScreenUri(screenUrl), source);
+ }
+
+ protected void printFoFromHttp(String server, String screenUrl) throws Exception {
+ InputSource source = this.getScreenFromHttp(server, screenUrl);
+ this.renderFO(this.getScreenUri(screenUrl), source);
+ }
+
+ protected InputSource getScreenFromHttp(String server, String screenUrl) throws Exception {
+ String screen = this.getScreenUri(screenUrl);
+ Map params = this.getParameters(screenUrl);
+ Iterator i = params.keySet().iterator();
+ String paramString = "?screenUri=" + URLEncoder.encode(screen, "UTF-8");
+ while (i.hasNext()) {
+ String key = (String) i.next();
+ Object val = params.get(key);
+ paramString = paramString + "&" + key + "=" + URLEncoder.encode(val.toString(), "UTF-8");
+ }
+
+ URL url = new URL(server + requestPath + paramString);
+ URLConnection con = url.openConnection();
+ con.setDoInput(true);
+ con.setDoOutput(true);
+ con.setUseCaches(false);
+ con.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
+
+ PrintWriter toServlet = new PrintWriter(con.getOutputStream());
+ toServlet.flush();
+ toServlet.close();
+
+ InputStream in = con.getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(in));
+
+ StringBuffer buf = new StringBuffer();
+ String line;
+ while ((line = reader.readLine()) != null) {
+ buf.append(line);
+ buf.append(System.getProperty("line.separator"));
+ }
+ reader.close();
+
+ // convert the base64 string to bytes
+ byte[] bytes = Base64.decodeBase64(buf.toString().getBytes());
+ System.out.println(new String(bytes));
+ return new InputSource(new ByteArrayInputStream(bytes));
+ }
+
+ protected InputSource getScreenFromRmi(String lookup, String screenUrl) throws Exception {
+ FopPrintRemote remote = (FopPrintRemote) Naming.lookup(lookup);
+ if (remote != null) {
+ String screen = this.getScreenUri(screenUrl);
+ Map params = this.getParameters(screenUrl);
+ byte[] fo = remote.getXslFo(screen, params);
+ return new InputSource(new ByteArrayInputStream(fo));
+ }
+ return 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));
+ params.put("locale", Locale.getDefault());
+ System.out.println("Parsed parameters: " + params);
+ return params;
+ }
+
+ protected void setJobComplete(String jobName) throws Exception {
+ jobQueue.remove(jobName);
+ if (jobQueue.size() == 0) {
+ this.sendComplete();
+ }
+ }
+
+ protected void sendComplete() throws Exception {
+ this.getAppletContext().showStatus("Updating settings on server...");
+ StringBuffer buf = new StringBuffer();
+ Iterator i = toPrint.keySet().iterator();
+ int count = 1;
+ while (i.hasNext()) {
+ String screen = (String) i.next();
+ String printerName = (String) toPrint.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(printerName, "UTF-8"));
+ count++;
+ }
+
+ String path = "/webtools/control/printComplete?" + buf.toString();
+ URL url = new URL(serverUrl + path);
+ System.out.println("Returning complete: " + url.toExternalForm());
+ this.getAppletContext().showStatus("All jobs queued.");
+ this.getAppletContext().showDocument(url);
+ }
+
+ protected PrintService getPrintService(String jobName, String printerName) {
+ PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+ PrintService printService[] = PrintServiceLookup.lookupPrintServices(flavor, aset);
+ PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
+
+ PrintService service = null;
+ if (printService.length > 0) {
+ if (!resetCookies && printerName != null && printerName.length() > 0) {
+ System.out.println("Looking for available printer: " + printerName);
+ for (int i = 0; i < printService.length; i++) {
+ PrintService svc = printService[i];
+ if (svc.getName().equals(printerName)) {
+ service = svc;
+ }
+ }
+ }
+
+ if (service == null) {
+ aset.add(new JobName(jobName.substring(jobName.indexOf("#") + 1), Locale.getDefault()));
+ this.getAppletContext().showStatus("Requesting printer settings... [" + jobName.substring(jobName.indexOf("#") + 1) + "]");
+ try {
+ service = ServiceUI.printDialog(null, 200, 200, printService, defaultService, flavor, aset);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+
+ if (service == null) {
+ System.out.println("Null print service returned.");
+ } else {
+ System.out.println("Print service received: " + service.getName());
+ }
+ }
+ }
+
+ return service;
+ }
+
+ /**
+ * Renders an FO inputsource to the selected printer.
+ */
+ protected void renderFO(final String name, final InputSource foFile) throws Exception {
+ final PrintService service = (PrintService) jobQueue.get(name);
+ if (service != null) {
+ this.getAppletContext().showStatus("Rendering PDF...");
+ Thread worker = new Thread() {
+ public void run() {
+ try {
+ PrintRenderer renderer = new PrintRenderer(service, name);
+ Driver driver = new Driver(foFile, null);
+ driver.setRenderer(renderer);
+ driver.run();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ };
+
+ worker.start();
+ }
+ }
+
+ 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) {
+ 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();
+ }
+
+ private 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;
+ }
+
+ // This is stolen from FOP PrintStarter
+ class PrintRenderer extends AWTRenderer {
+
+ public static final int EVEN_AND_ALL = 0;
+ public static final int EVEN = 1;
+ public static final int ODD = 2;
+
+ private int startNumber;
+ private int endNumber;
+ private int mode = EVEN_AND_ALL;
+ private int copies = 0;
+ private PrintService service;
+ private String jobName;
+
+ PrintRenderer(PrintService service, String jobName) {
+ this(service, jobName, EVEN_AND_ALL, 0);
+ }
+
+ PrintRenderer(PrintService service, String jobName, int mode, int copies) {
+ super(null);
+ this.service = service;
+ this.jobName = jobName;
+ this.copies = copies;
+ this.mode = mode;
+ this.startNumber = 0 ;
+ this.endNumber = -1;
+ this.setScaleFactor(1);
+ }
+
+ public void stopRenderer(OutputStream outputStream) throws IOException {
+ super.stopRenderer(outputStream);
+
+ if (endNumber == -1) {
+ endNumber = getPageCount();
+ }
+
+ Vector numbers = getInvalidPageNumbers();
+ for (int i = numbers.size() - 1; i > -1; i--) {
+ removePage(Integer.parseInt((String) numbers.elementAt(i)));
+ }
+
+ PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
+ aset.add(new JobName(jobName.substring(jobName.indexOf("#") + 1), Locale.getDefault()));
+ if (copies > 0) {
+ aset.add(new Copies(copies));
+ }
+
+ if (service != null) {
+ log.info("Printing job [" + jobName + "] to printer - " + service.getName());
+ DocPrintJob job = service.createPrintJob();
+ DocAttributeSet das = new HashDocAttributeSet();
+ Doc doc = new SimpleDoc(this, flavor, das);
+ try {
+ int copiesToPrint = 1;
+ if (!service.isAttributeCategorySupported(Copies.class)) {
+ copiesToPrint = ((Copies) aset.get(Copies.class)).getValue();
+ aset.add(new Copies(1));
+ }
+
+ getAppletContext().showStatus("Printing...");
+ for (int i = 0; i < copiesToPrint; i++) {
+ job.print(doc, aset);
+ }
+
+ try {
+ setJobComplete(jobName);
+ } catch (Exception e) {
+ throw new IOException(e.getMessage());
+ }
+ } catch (PrintException e) {
+ log.error("Unable to print", e);
+ throw new IOException("Unable to print: " + e.getClass().getName() + ": " + e.getMessage());
+ }
+ }
+ }
+
+ public void renderPage(Page page) {
+ pageWidth = (int)((float) page.getWidth() / 1000f);
+ pageHeight = (int)((float) page.getHeight() / 1000f);
+ super.renderPage(page);
+ }
+
+ private Vector getInvalidPageNumbers() {
+ Vector vec = new Vector();
+ int max = getPageCount();
+ boolean isValid;
+ for (int i = 0; i < max; i++) {
+ isValid = true;
+ if (i < startNumber || i > endNumber) {
+ isValid = false;
+ } else if (mode != EVEN_AND_ALL) {
+ if (mode == EVEN && ((i + 1) % 2 != 0)) {
+ isValid = false;
+ } else if (mode == ODD && ((i + 1) % 2 != 1)) {
+ isValid = false;
+ }
+ }
+
+ if (!isValid) {
+ vec.add(i + "");
+ }
+ }
+ return vec;
+ }
+ }
+}
+
Property changes on: trunk/framework/webtools/src/org/ofbiz/webtools/print/applet/FopPrintApplet.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id Rev Author
Name: svn:eol-style
+ native
Modified: trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintServer.java
===================================================================
--- trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintServer.java 2006-01-25 16:22:53 UTC (rev 6577)
+++ trunk/framework/webtools/src/org/ofbiz/webtools/print/rmi/FopPrintServer.java 2006-01-25 17:44:37 UTC (rev 6578)
@@ -25,6 +25,7 @@
package org.ofbiz.webtools.print.rmi;
import java.io.IOException;
+import java.io.Writer;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.server.RMIClientSocketFactory;
@@ -38,11 +39,13 @@
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.collections.map.LinkedMap;
+import org.apache.commons.codec.binary.Base64;
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.base.util.UtilHttp;
import org.ofbiz.entity.GenericDelegator;
import org.ofbiz.service.GenericDispatcher;
import org.ofbiz.service.LocalDispatcher;
@@ -57,7 +60,7 @@
public class FopPrintServer implements Container {
public static final String module = FopPrintServer.class.getName();
-
+ protected static FopPrintServer instance = null;
protected FopPrintRemote remote = null;
protected String configFile = null;
protected String name = null;
@@ -69,6 +72,7 @@
*/
public void init(String[] args, String configFile) {
this.configFile = configFile;
+ instance = this;
}
public boolean start() throws ContainerException {
@@ -178,6 +182,46 @@
public void stop() throws ContainerException {
}
+ public FopPrintRemote getRemote() {
+ return this.remote;
+ }
+
+ public static String getXslFo(HttpServletRequest req, HttpServletResponse resp) {
+ FopPrintRemote remote = instance.getRemote();
+ Map reqParams = UtilHttp.getParameterMap(req);
+ reqParams.put("locale", UtilHttp.getLocale(req));
+
+ String screenUri = (String) reqParams.remove("screenUri");
+ if (screenUri != null && reqParams.size() > 0) {
+ String base64String = null;
+ try {
+ byte[] bytes = remote.getXslFo(screenUri, reqParams);
+ base64String = new String(Base64.encodeBase64(bytes));
+ } catch (RemoteException e) {
+ Debug.logError(e, module);
+ try {
+ resp.sendError(500);
+ } catch (IOException e1) {
+ Debug.logError(e1, module);
+ }
+ }
+ if (base64String != null) {
+ try {
+ Writer out = resp.getWriter();
+ out.write(base64String);
+ } catch (IOException e) {
+ try {
+ resp.sendError(500);
+ } catch (IOException e1) {
+ Debug.logError(e1, module);
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
public static String readFopPrintServerCookies(HttpServletRequest req, HttpServletResponse resp) {
Map screenPrinterMap = new LinkedMap();
Cookie[] cookies = req.getCookies();
Modified: trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml
===================================================================
--- trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml 2006-01-25 16:22:53 UTC (rev 6577)
+++ trunk/framework/webtools/webapp/webtools/WEB-INF/controller.xml 2006-01-25 17:44:37 UTC (rev 6578)
@@ -448,11 +448,26 @@
<response name="success" type="view" value="printDone"/>
<response name="error" type="view" value="error"/>
</request-map>
+ <request-map uri="getXslFo">
+ <event type="java" path="org.ofbiz.webtools.print.rmi.FopPrintServer" invoke="getXslFo"/>
+ <response name="success" type="none"/>
+ <response name="error" type="none"/>
+ </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="barcode.class">
+ <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="default.class">
+ <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"/>
Property changes on: trunk/framework/webtools/webapp/webtools/applet
___________________________________________________________________
Name: svn:ignore
- ofbiz-webtools-print.jar
14_os_jpedal.jar
+ ofbiz-webtools-print.jar
avalon-framework-4.1.5.jar
barcode4j-fop-ext-0.20.5-complete.jar
batik.jar
commons-cli.jar
commons-codec.jar
fop.jar
Modified: trunk/framework/webtools/webapp/webtools/print/printDone.ftl
===================================================================
--- trunk/framework/webtools/webapp/webtools/print/printDone.ftl 2006-01-25 16:22:53 UTC (rev 6577)
+++ trunk/framework/webtools/webapp/webtools/print/printDone.ftl 2006-01-25 17:44:37 UTC (rev 6578)
@@ -29,7 +29,7 @@
<html>
<body>
<script language="javascript">
- window.close();
+ setTimeout('window.close()', 2000);
</script>
</body>
</html>
Modified: trunk/framework/webtools/webapp/webtools/print/printStart.ftl
===================================================================
--- trunk/framework/webtools/webapp/webtools/print/printStart.ftl 2006-01-25 16:22:53 UTC (rev 6577)
+++ trunk/framework/webtools/webapp/webtools/print/printStart.ftl 2006-01-25 17:44:37 UTC (rev 6578)
@@ -34,9 +34,12 @@
<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"
+ <object align="center" height="50" width="350" classid="java:org.ofbiz.webtools.print.applet.FopPrintApplet"
+ type="application/x-java-applet" mayscript="true" archive="/webtools/applet/ofbiz-webtools-print.jar,
+ /webtools/applet/avalon-framework-4.1.5.jar, /webtools/applet/commons-cli.jar, /webtools/applet/commons-codec.jar,
+ /webtools/applet/barcode4j-fop-ext-0.20.5-complete.jar, /webtools/applet/batik.jar, /webtools/applet/fop.jar"
+
+ codebase="/webtools/applet" server-url="${serverRoot}" reset-cookies="false"
<#assign count = 1>
<#list screens as screen>
<#assign printer = screenMap.get(screen)?if_exists>
@@ -50,14 +53,15 @@
</#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="archive" value="/webtools/applet/ofbiz-webtools-print.jar,
+ /webtools/applet/avalon-framework-4.1.5.jar, /webtools/applet/commons-cli.jar, /webtools/applet/commons-codec.jar,
+ /webtools/applet/barcode4j-fop-ext-0.20.5-complete.jar, /webtools/applet/batik.jar, /webtools/applet/fop.jar">
+
<param name="codebase" value="/webtools/applet">
- <param name="code" value="org.ofbiz.webtools.print.applet.PdfPrintApplet">
+ <param name="code" value="org.ofbiz.webtools.print.applet.FopPrintApplet">
<param name="mayscript" value="true">
+ <param name="reset-cookies" value="false">
<param name="server-url" value="${serverRoot}">
- <param name="rmi-name" value="RMIFopPrintServer">
- <param name="rmi-host" value="${serverHost}">
- <param name="rmi-port" value="1099">
<#assign count = 1>
<#list screens as screen>
<#assign printer = screenMap.get(screen)?if_exists>
More information about the Svn
mailing list