Author: amarkhel
Date: 2009-03-04 11:27:33 -0500 (Wed, 04 Mar 2009)
New Revision: 12826
Added:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLink.java
trunk/test-applications/realworld2/web/src/main/webapp/includes/directImage.xhtml
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/pages.xml
trunk/test-applications/realworld2/web/src/main/webapp/includes/userImage.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/layout/menu.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/layout/panelBar-backup.xhtml
trunk/test-applications/realworld2/web/src/main/webapp/layout/template3.xhtml
Log:
Added:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLink.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLink.java
(rev 0)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLink.java 2009-03-04
16:27:33 UTC (rev 12826)
@@ -0,0 +1,67 @@
+package org.richfaces.realworld.util;
+
+import java.awt.image.BufferedImage;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import javax.imageio.ImageIO;
+import javax.persistence.EntityManager;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.web.RequestParameter;
+import org.jboss.seam.core.Events;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.fileupload.FileManager;
+import org.richfaces.realworld.service.Constants;
+
+@Name("directLink")
+(a)Scope(ScopeType.SESSION)
+public class DirectLink {
+ @In(value="entityManager")
+ protected EntityManager em;
+ @In(create = true)
+ FileManager fileManager;
+ @RequestParameter
+ protected Long imageId;
+
+ private Long id;
+
+ public synchronized void paintImage(OutputStream out, Object data)
+ throws IOException {
+ Image im = em.find(Image.class, id);
+ File imageResource = fileManager.getImage(im.getPath());
+ if (imageResource != null) {
+ FileInputStream fileInputStream = new FileInputStream(imageResource);
+ BufferedInputStream bufferedInputStream = new BufferedInputStream(
+ fileInputStream);
+ InputStream paintData = bufferedInputStream;
+ if (null == paintData) {
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
+ new Exception(""));
+ return;
+ }
+ try {
+ BufferedImage images = ImageIO.read(paintData);
+ ImageIO.write(images, Constants.JPEG, out);
+ } catch (Exception e) {
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
+ new Exception(""));
+ return;
+ } finally {
+ fileInputStream.close();
+ bufferedInputStream.close();
+ paintData.close();
+ }
+ }
+ }
+ public void start(){
+ id=imageId;
+ }
+}
\ No newline at end of file
Property changes on:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/DirectLink.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/pages.xml
===================================================================
--- trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/pages.xml 2009-03-04
14:59:18 UTC (rev 12825)
+++ trunk/test-applications/realworld2/web/src/main/webapp/WEB-INF/pages.xml 2009-03-04
16:27:33 UTC (rev 12826)
@@ -30,7 +30,9 @@
<redirect view-id="/index.xhtml"/>
</navigation>
</page>
-
+<page view-id="/includes/directImage.xhtml">
+<action execute="#{directLink.start}"/>
+</page>
<exception class="org.jboss.seam.framework.EntityNotFoundException">
<redirect view-id="/error.xhtml">
<message>Not found</message>
Added: trunk/test-applications/realworld2/web/src/main/webapp/includes/directImage.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/realworld2/web/src/main/webapp/includes/directImage.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/userImage.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/layout/menu.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/layout/panelBar-backup.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld2/web/src/main/webapp/layout/template3.xhtml
===================================================================
(Binary files differ)