Package org.jboss.seam.document

Examples of org.jboss.seam.document.DocumentStore


         @Override
         protected void invokeApplication() throws Exception
         {
            Conversation.instance().begin();

            DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.document.documentStore}");
            String docId = store.newId();

            Contexts.getSessionContext().set("docId", docId);

            DocumentData documentData = new ByteArrayDocumentData("base", UIDocument.PDF, new byte[100]);
            store.saveData(docId, documentData);
         }

         @Override
         protected void renderResponse() throws Exception
         {
            String docId = (String) getValue("#{docId}");
            assert docId != null;

            DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.document.documentStore}");
            assert store.idIsValid(docId);

         }
      }.run();

      // different conversation
      new FacesRequest("/whyseam.xhtml")
      {
         @Override
         protected void renderResponse() throws Exception
         {
            String docId = (String) getValue("#{docId}");
            assert docId != null;

            DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.document.documentStore}");
            assert !store.idIsValid(docId);
         }
      }.run();

      new FacesRequest("/whyseam.xhtml", conversationId)
      {
         @Override
         protected void renderResponse() throws Exception
         {
            String docId = (String) getValue("#{docId}");
            assert docId != null;

            DocumentStore store = (DocumentStore) getValue("#{org.jboss.seam.document.documentStore}");
            assert store.idIsValid(docId);

            ByteArrayDocumentData data = (ByteArrayDocumentData)store.getDocumentData(docId);
            assert data.getDocumentType().equals(UIDocument.PDF);
            assert data.getData().length == 100;
         }
      }.run();
   }
View Full Code Here


         return;
      }
     
      if (sendRedirect)
      {
         DocumentStore store = DocumentStore.instance();
         String id = store.newId();

         String url = store.preferredUrlForContent(baseName, type.getExtension(), id);
         url = Manager.instance().encodeConversationId(url, viewId);

         store.saveData(id, documentData);

         context.getExternalContext().redirect(url);

      }
      else
View Full Code Here

      }

      String viewId = Pages.getViewId(facesContext);
      String baseName = Pages.getCurrentBaseName();

      DocumentStore store = DocumentStore.instance();
      DocumentType documentType = new DocumentData.DocumentType("pdf", "application/pdf");
      DocumentData documentData = new ByteArrayDocumentData(baseName, documentType, buffer.toByteArray());
      documentData.setFilename(getFilename());

      if (getExportKey() != null)
      {
         log.debug("Exporting PDF data to event key #0", getExportKey());
         Contexts.getEventContext().set(getExportKey(), documentData);
         return;
      }

      String id = store.newId();
      String url = store.preferredUrlForContent(baseName, documentType.getExtension(), id);
      url = Manager.instance().encodeConversationId(url, viewId);
      store.saveData(id, documentData);
      log.debug("Redirecting to #0 for PDF view", url);
      facesContext.getExternalContext().redirect(url);
   }
View Full Code Here

         documentData.setFilename(fileNameValue);
      }

      if (sendRedirect)
      {
         DocumentStore store = DocumentStore.instance();
         String id = store.newId();

         String url = store.preferredUrlForContent(baseName, documentType.getExtension(), id);
         url = Manager.instance().encodeConversationId(url, viewId);

         store.saveData(id, documentData);

         removeITextObject();

         context.getExternalContext().redirect(url);
      }
View Full Code Here

         return;
      }

      if (sendRedirect)
      {
         DocumentStore store = DocumentStore.instance();
         String id = store.newId();

         String url = store.preferredUrlForContent(baseName, type.getExtension(), id);
         url = Manager.instance().encodeConversationId(url, viewId);

         store.saveData(id, documentData);

         context.getExternalContext().redirect(url);

      }
      else
View Full Code Here

         documentData.setFilename(fileNameValue);
      }

      if (sendRedirect)
      {
         DocumentStore store = DocumentStore.instance();
         String id = store.newId();

         String url = store.preferredUrlForContent(baseName, documentType.getExtension(), id);
         url = Manager.instance().encodeConversationId(url, viewId);

         store.saveData(id, documentData);

         removeITextObject();

         context.getExternalContext().redirect(url);
      }
View Full Code Here

        }

        String viewId = Pages.getViewId(facesContext);
        String baseName = baseNameForViewId(viewId);

        DocumentStore store = DocumentStore.instance();
        DocumentType documentType = new DocumentData.DocumentType("pdf",
                "application/pdf");
        DocumentData documentData = new DocumentData(baseName, documentType,
                buffer.toByteArray());
        documentData.setFilename(getFilename());

        if (getExportKey() != null) {
            log.debug("Exporting PDF data to event key #0", getExportKey());
            Contexts.getEventContext().set(getExportKey(), documentData);
            return;
        }

        String id = store.newId();
        String url = store.preferredUrlForContent(baseName, documentType
                .getExtension(), id);
        url = Manager.instance().encodeConversationId(url, viewId);
        store.saveData(id, documentData);
        log.debug("Redirecting to #0 for PDF view", url);
        facesContext.getExternalContext().redirect(url);
    }
View Full Code Here

    public static String addResourceToDataStore(FacesContext ctx, UIResource resource) {
        String baseName = Pages.getCurrentBaseName();
        String viewId = Pages.getViewId(ctx);

        DocumentStore store = DocumentStore.instance();
        String id = store.newId();

        DocumentType type = new DocumentType("", resource.getContentType());

        DocumentData documentData = new DownloadableDocumentData(baseName, type, resource.getData());
        documentData.setFilename(resource.getFileName());
        documentData.setDisposition(resource.getDisposition());

        String url = store.preferredUrlForContent(resource.getFileName(), type.getExtension(), id);
        url = Manager.instance().encodeConversationId(url, viewId);
        store.saveData(id, documentData);
        return url;
    }
View Full Code Here

TOP

Related Classes of org.jboss.seam.document.DocumentStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.