[jboss-cvs] jboss-seam/src/pdf/org/jboss/seam/pdf/ui ...

Norman Richards norman.richards at jboss.com
Fri Feb 2 21:05:37 EST 2007


  User: nrichards
  Date: 07/02/02 21:05:37

  Modified:    src/pdf/org/jboss/seam/pdf/ui  UIDocument.java
  Log:
  add sendRedirect flag for local generation
  
  Revision  Changes    Path
  1.14      +61 -32    jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: UIDocument.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss-seam/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -b -r1.13 -r1.14
  --- UIDocument.java	29 Jan 2007 03:01:33 -0000	1.13
  +++ UIDocument.java	3 Feb 2007 02:05:37 -0000	1.14
  @@ -5,6 +5,8 @@
   import org.jboss.seam.pdf.DocumentStore;
   import org.jboss.seam.pdf.DocumentStore.DocType;
   
  +import javax.faces.component.UIComponent;
  +import javax.faces.component.ValueHolder;
   import javax.faces.context.*;
   import java.io.*;
   
  @@ -18,6 +20,7 @@
   {
       public static final String COMPONENT_TYPE   = "org.jboss.seam.pdf.ui.UIDocument";
       
  +    
       DocWriter writer;
       Document document;
       ByteArrayOutputStream stream;
  @@ -37,8 +40,13 @@
       String margins;
       Boolean marginMirroring;
    
  +    boolean sendRedirect = true;
  +    
  +    
       UISignature signatureField;
       
  +   
  +    
       public void setType(String type) {
           this.type = type;
       }
  @@ -80,6 +88,15 @@
       }
       
       
  +    public void setSendRedirect(boolean sendRedirect) {
  +        this.sendRedirect = sendRedirect;
  +    }
  +    
  +    public boolean getSendRedirect() {
  +        return sendRedirect;
  +    }
  +    
  +    
       public Object getITextObject() {
           return document;
       }
  @@ -179,11 +196,8 @@
       {
           super.encodeBegin(context);
           
  -        DocumentStore store = DocumentStore.instance();
  -        id = store.newId();
           stream = new ByteArrayOutputStream();
                 
  -        
           try {
               switch (docType) {
               case PDF:
  @@ -204,6 +218,10 @@
               throw new RuntimeException(e);
           }
   
  +        if (sendRedirect) {
  +            DocumentStore store = DocumentStore.instance();
  +            id = store.newId();
  +            
           ResponseWriter response = context.getResponseWriter();
           response.startElement("html", this);
           response.startElement("head", this);
  @@ -222,6 +240,7 @@
   
           response.startElement("body",this);
       }
  +    }
   
       private String baseNameForViewId(String viewId) {
           int pos = viewId.lastIndexOf("/");
  @@ -249,6 +268,7 @@
               bytes = signatureField.sign(bytes);
           }
           
  +        if (sendRedirect) {
           DocumentStore.instance().saveData(id,
                                             baseName,
                                             docType,
  @@ -261,6 +281,15 @@
           removeITextObject();
           
           Manager.instance().beforeRedirect();
  +        } else {
  +            UIComponent parent = getParent();
  +            
  +            if (parent instanceof ValueHolder) {
  +                ValueHolder holder = (ValueHolder) parent;
  +                holder.setValue(bytes);
  +            }
  +
  +        }
       }
   
          
  
  
  



More information about the jboss-cvs-commits mailing list