[seam-commits] Seam SVN: r9856 - in trunk: src/excel/org/jboss/seam/excel/ui and 5 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Jan 2 18:59:49 EST 2009


Author: danielc.roth
Date: 2009-01-02 18:59:49 -0500 (Fri, 02 Jan 2009)
New Revision: 9856

Modified:
   trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java
   trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java
   trunk/src/main/org/jboss/seam/document/ByteArrayDocumentData.java
   trunk/src/main/org/jboss/seam/document/DocumentStore.java
   trunk/src/main/org/jboss/seam/navigation/Pages.java
   trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java
   trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java
   trunk/src/rss/org/jboss/seam/rss/ui/UIFeed.java
   trunk/ui/src/main/java/org/jboss/seam/ui/DocumentStoreUtils.java
Log:
JBSEAM-3684 and some minors

Modified: trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java	2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/excel/org/jboss/seam/excel/exporter/ExcelExporter.java	2009-01-02 23:59:49 UTC (rev 9856)
@@ -153,7 +153,7 @@
    private void redirectExport()
    {
       String viewId = Pages.getViewId(FacesContext.getCurrentInstance());
-      String baseName = UIWorkbook.baseNameForViewId(viewId);
+      String baseName = Pages.getCurrentBaseName();
       DocumentData documentData = new ByteArrayDocumentData(baseName, excelWorkbook.getDocumentType(), excelWorkbook.getBytes());
       String id = DocumentStore.instance().newId();
       String url = DocumentStore.instance().preferredUrlForContent(baseName, excelWorkbook.getDocumentType().getExtension(), id);

Modified: trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java
===================================================================
--- trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java	2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/excel/org/jboss/seam/excel/ui/UIWorkbook.java	2009-01-02 23:59:49 UTC (rev 9856)
@@ -326,7 +326,7 @@
       DocumentType type = excelWorkbook.getDocumentType();
 
       String viewId = Pages.getViewId(context);
-      String baseName = baseNameForViewId(viewId);
+      String baseName = Pages.getCurrentBaseName();
 
       DocumentData documentData = new ByteArrayDocumentData(baseName, type, bytes);
       documentData.setFilename(getFilename());
@@ -362,23 +362,6 @@
       }
    }
 
-   public static String baseNameForViewId(String viewId)
-   {
-      int pos = viewId.lastIndexOf("/");
-      if (pos != -1)
-      {
-         viewId = viewId.substring(pos + 1);
-      }
-
-      pos = viewId.lastIndexOf(".");
-      if (pos != -1)
-      {
-         viewId = viewId.substring(0, pos);
-      }
-
-      return viewId;
-   }
-
    public boolean isSendRedirect()
    {
       return (Boolean) valueOf("sendRedirect", sendRedirect);

Modified: trunk/src/main/org/jboss/seam/document/ByteArrayDocumentData.java
===================================================================
--- trunk/src/main/org/jboss/seam/document/ByteArrayDocumentData.java	2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/main/org/jboss/seam/document/ByteArrayDocumentData.java	2009-01-02 23:59:49 UTC (rev 9856)
@@ -11,6 +11,7 @@
    public ByteArrayDocumentData(String baseName, DocumentType documentType, byte[] data)
    {
       super(baseName, documentType);
+      this.data = data;
    }
 
    @Override

Modified: trunk/src/main/org/jboss/seam/document/DocumentStore.java
===================================================================
--- trunk/src/main/org/jboss/seam/document/DocumentStore.java	2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/main/org/jboss/seam/document/DocumentStore.java	2009-01-02 23:59:49 UTC (rev 9856)
@@ -20,7 +20,7 @@
 public class DocumentStore 
     implements Serializable
 {    
-    public static final String DOCSTORE_BASE_URL = "/seam-docstore";
+    public static final String DOCSTORE_BASE_URL = "/seam/docstore/";
 
     private static final long serialVersionUID = -357154201942127711L;
 

Modified: trunk/src/main/org/jboss/seam/navigation/Pages.java
===================================================================
--- trunk/src/main/org/jboss/seam/navigation/Pages.java	2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/main/org/jboss/seam/navigation/Pages.java	2009-01-02 23:59:49 UTC (rev 9856)
@@ -1654,6 +1654,25 @@
       return getViewId( FacesContext.getCurrentInstance() );
    }
    
+   public static String getCurrentBaseName()
+   {
+      String viewId = getViewId(FacesContext.getCurrentInstance());
+
+      int pos = viewId.lastIndexOf("/");
+      if (pos != -1)
+      {
+         viewId = viewId.substring(pos + 1);
+      }
+
+      pos = viewId.lastIndexOf(".");
+      if (pos != -1)
+      {
+         viewId = viewId.substring(0, pos);
+      }
+
+      return viewId;      
+   }   
+   
    public static String getViewId(FacesContext facesContext)
    {
       if (facesContext!=null)

Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java	2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIDocument.java	2009-01-02 23:59:49 UTC (rev 9856)
@@ -293,23 +293,6 @@
       }
    }
 
-   protected String baseNameForViewId(String viewId)
-   {
-      int pos = viewId.lastIndexOf("/");
-      if (pos != -1)
-      {
-         viewId = viewId.substring(pos + 1);
-      }
-
-      pos = viewId.lastIndexOf(".");
-      if (pos != -1)
-      {
-         viewId = viewId.substring(0, pos);
-      }
-
-      return viewId;
-   }
-
    @Override
    public void encodeEnd(FacesContext context) throws IOException
    {
@@ -323,7 +306,7 @@
       }
 
       String viewId = Pages.getViewId(context);
-      String baseName = baseNameForViewId(viewId);
+      String baseName = Pages.getCurrentBaseName();
 
       DocumentData documentData = new ByteArrayDocumentData(baseName, documentType, bytes);
       String dispositionValue = (String) valueBinding(context, "disposition", disposition);

Modified: trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java
===================================================================
--- trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java	2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/pdf/org/jboss/seam/pdf/ui/UIForm.java	2009-01-02 23:59:49 UTC (rev 9856)
@@ -102,7 +102,7 @@
       }
 
       String viewId = Pages.getViewId(facesContext);
-      String baseName = baseNameForViewId(viewId);
+      String baseName = Pages.getCurrentBaseName();
 
       DocumentStore store = DocumentStore.instance();
       DocumentType documentType = new DocumentData.DocumentType("pdf", "application/pdf");
@@ -124,23 +124,6 @@
       facesContext.getExternalContext().redirect(url);
    }
 
-   public static String baseNameForViewId(String viewId)
-   {
-      int pos = viewId.lastIndexOf("/");
-      if (pos != -1)
-      {
-         viewId = viewId.substring(pos + 1);
-      }
-
-      pos = viewId.lastIndexOf(".");
-      if (pos != -1)
-      {
-         viewId = viewId.substring(0, pos);
-      }
-
-      return viewId;
-   }
-
    @Override
    public String getFamily()
    {

Modified: trunk/src/rss/org/jboss/seam/rss/ui/UIFeed.java
===================================================================
--- trunk/src/rss/org/jboss/seam/rss/ui/UIFeed.java	2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/src/rss/org/jboss/seam/rss/ui/UIFeed.java	2009-01-02 23:59:49 UTC (rev 9856)
@@ -6,10 +6,10 @@
 import java.text.SimpleDateFormat;
 import java.util.Date;
 
+import javax.faces.context.FacesContext;
 import javax.servlet.http.HttpServletResponse;
 
 import org.jboss.seam.contexts.Contexts;
-import javax.faces.context.FacesContext;
 
 import yarfraw.core.datamodel.ChannelFeed;
 import yarfraw.core.datamodel.FeedFormat;
@@ -18,23 +18,23 @@
 
 /*
  * atomFeed =
-   element atom:feed {
-      atomCommonAttributes,
-      (atomAuthor*
-       & atomCategory*
-       & atomContributor*
-       & atomGenerator?
-       & atomIcon?
-       & atomId
-       & atomLink*
-       & atomLogo?
-       & atomRights?
-       & atomSubtitle?
-       & atomTitle
-       & atomUpdated
-       & extensionElement*),
-      atomEntry*
-   }
+ element atom:feed {
+ atomCommonAttributes,
+ (atomAuthor*
+ & atomCategory*
+ & atomContributor*
+ & atomGenerator?
+ & atomIcon?
+ & atomId
+ & atomLink*
+ & atomLogo?
+ & atomRights?
+ & atomSubtitle?
+ & atomTitle
+ & atomUpdated
+ & extensionElement*),
+ atomEntry*
+ }
  */
 
 public class UIFeed extends SyndicationComponent
@@ -52,7 +52,6 @@
    private String link;
    private FeedFormat feedFormat = FeedFormat.ATOM10;
 
-
    @SuppressWarnings("unchecked")
    @Override
    public void encodeBegin(FacesContext facesContext) throws IOException
@@ -61,7 +60,8 @@
       channelFeed.setUid(getUid());
       channelFeed.setTitle(getTitle());
       channelFeed.setDescriptionOrSubtitle(getSubtitle());
-      if (getUpdated() != null) {
+      if (getUpdated() != null)
+      {
          channelFeed.setPubDate(getUpdated(), new SimpleDateFormat(ATOM_DATE_FORMAT));
       }
       channelFeed.addLink(getLink());
@@ -73,17 +73,20 @@
    {
       ChannelFeed channelFeed = (ChannelFeed) Contexts.getEventContext().get(FEED_IMPL_KEY);
       ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
-      try {
+      try
+      {
          FeedWriter.writeChannel(feedFormat, channelFeed, byteStream);
-      } catch (YarfrawException e) {
+      }
+      catch (YarfrawException e)
+      {
          /**
           * Was IOException, but 1.5 does not have this constructor
           * http://java.sun.com/j2se/1.5.0/docs/api/java/io/IOException.html
           */
          throw new RuntimeException("Could not create feed", e);
       }
-      Writer responseWriter = ((HttpServletResponse)facesContext.getExternalContext().getResponse()).getWriter();
-      HttpServletResponse response = (HttpServletResponse)facesContext.getExternalContext().getResponse();
+      Writer responseWriter = ((HttpServletResponse) facesContext.getExternalContext().getResponse()).getWriter();
+      HttpServletResponse response = (HttpServletResponse) facesContext.getExternalContext().getResponse();
       response.setContentType(MIMETYPE);
       response.setContentLength(byteStream.size());
       responseWriter.write(byteStream.toString());
@@ -91,23 +94,6 @@
       facesContext.responseComplete();
    }
 
-   public static String baseNameForViewId(String viewId)
-   {
-      int pos = viewId.lastIndexOf("/");
-      if (pos != -1)
-      {
-         viewId = viewId.substring(pos + 1);
-      }
-
-      pos = viewId.lastIndexOf(".");
-      if (pos != -1)
-      {
-         viewId = viewId.substring(0, pos);
-      }
-
-      return viewId;
-   }
-
    public boolean isSendRedirect()
    {
       return sendRedirect;
@@ -184,5 +170,4 @@
       this.uid = uid;
    }
 
-
 }

Modified: trunk/ui/src/main/java/org/jboss/seam/ui/DocumentStoreUtils.java
===================================================================
--- trunk/ui/src/main/java/org/jboss/seam/ui/DocumentStoreUtils.java	2009-01-02 22:56:08 UTC (rev 9855)
+++ trunk/ui/src/main/java/org/jboss/seam/ui/DocumentStoreUtils.java	2009-01-02 23:59:49 UTC (rev 9856)
@@ -20,7 +20,7 @@
 
    public static String addResourceToDataStore(FacesContext ctx, UIResource resource)
    {
-      String baseName = baseNameForViewId(Pages.getCurrentViewId());
+      String baseName = Pages.getCurrentBaseName();
       String viewId = Pages.getViewId(ctx);
 
       DocumentStore store = DocumentStore.instance();
@@ -77,26 +77,4 @@
 
    }
 
-   /**
-    * TODO: This part should be refactored in to Pages.java Used (at least)
-    * here, in pdf module and excel
-    * 
-    */
-   public static String baseNameForViewId(String viewId)
-   {
-      int pos = viewId.lastIndexOf("/");
-      if (pos != -1)
-      {
-         viewId = viewId.substring(pos + 1);
-      }
-
-      pos = viewId.lastIndexOf(".");
-      if (pos != -1)
-      {
-         viewId = viewId.substring(0, pos);
-      }
-
-      return viewId;
-   }
-
 }




More information about the seam-commits mailing list