[richfaces-svn-commits] JBoss Rich Faces SVN: r13385 - in trunk/test-applications/realworld2/web/src/main: java/org/richfaces/realworld/ui and 4 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Mon Apr 6 06:56:30 EDT 2009


Author: amarkhel
Date: 2009-04-06 06:56:30 -0400 (Mon, 06 Apr 2009)
New Revision: 13385

Modified:
   trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java
   trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java
   trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java
   trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java
   trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java
   trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java
   trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java
   trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java
   trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs.xhtml
   trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/avatar.xhtml
   trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/userPrefsEdit.xhtml
   trunk/test-applications/realworld2/web/src/main/webapp/register.xhtml
Log:


Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java	2009-04-06 09:34:17 UTC (rev 13384)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/Controller.java	2009-04-06 10:56:30 UTC (rev 13385)
@@ -124,6 +124,17 @@
 		model.setMainArea(NavigationEnum.ALBUM_IMAGE_EDIT);
 	}
 	
+	@Restrict("#{s:hasRole('admin')}")
+	public void editUser(){
+		userManager.editUser();
+		model.resetModel(NavigationEnum.ALL_SHELFS, user, model.getSelectedShelf(), model.getSelectedAlbum(), model.getSelectedImage());
+	}
+	
+	public void cancelEditUser(){
+		userManager.cancelEditUser();
+		model.resetModel(NavigationEnum.ALL_SHELFS, user, model.getSelectedShelf(), model.getSelectedAlbum(), model.getSelectedImage());
+	}
+	
 	public void cancelEditImage(Image image){
 		//TODO nick - unused image argument
 		model.setMainArea(NavigationEnum.ALBUM_IMAGE_PREVIEW);

Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java	2009-04-06 09:34:17 UTC (rev 13384)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/FileManager.java	2009-04-06 10:56:30 UTC (rev 13385)
@@ -385,4 +385,9 @@
             deleteDirectory(directory);
         }
     }
+
+	public File getFileByAbsolutePath(String path) {
+		File result = new File(path);
+		return result;
+	}
 }
\ No newline at end of file

Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java	2009-04-06 09:34:17 UTC (rev 13384)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/RegistrationManager.java	2009-04-06 10:56:30 UTC (rev 13385)
@@ -52,6 +52,10 @@
     	return "index";
     }
 	
+	public String goToIndex(){
+		return "index";
+	}
+	
 	public String goToRegister(){
     	identity.logout();
     	identity.unAuthenticate();

Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java	2009-04-06 09:34:17 UTC (rev 13384)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/manager/UserManager.java	2009-04-06 10:56:30 UTC (rev 13385)
@@ -20,6 +20,7 @@
  */
 package org.richfaces.realworld.manager;
 
+import java.io.File;
 import java.io.Serializable;
 import java.util.List;
 
@@ -30,9 +31,12 @@
 import org.jboss.seam.annotations.Observer;
 import org.jboss.seam.annotations.Out;
 import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.security.Restrict;
+import org.jboss.seam.core.Events;
 import org.richfaces.realworld.domain.Album;
 import org.richfaces.realworld.domain.Image;
 import org.richfaces.realworld.domain.User;
+import org.richfaces.realworld.service.Constants;
 import org.richfaces.realworld.service.IUserAction;
 
 @Name("userManager")
@@ -43,7 +47,8 @@
 	private static final long serialVersionUID = 6027103521084558931L;
 	
 	@In(scope=ScopeType.CONVERSATION) @Out(scope=ScopeType.CONVERSATION) private User user;
-
+	@In FileManager fileManager;
+	@In(required=false, scope=ScopeType.CONVERSATION) @Out(required=false, scope=ScopeType.CONVERSATION) private File avatarData;
 	@In private IUserAction userAction;
 
 	public Long countImages() {
@@ -76,6 +81,23 @@
 		return userAction.getSharedImages(user);
 	}
 	
+	public void editUser(){
+		if (avatarData != null) {
+			if(!fileManager.saveAvatar(avatarData.getPath(), user)){
+				Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, "File IO Error");
+				return;
+			}
+			avatarData.delete();
+			avatarData = null;
+			user.setHasAvatar(true);
+		}
+		user = userAction.updateUser();
+	}
+	
+	public void cancelEditUser() {
+		avatarData = null;
+	}
+	
 	@Observer(value = "imageAdded")
 	public void onImageAdded() {
 		user.updateStatistics();

Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java	2009-04-06 09:34:17 UTC (rev 13384)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileUploadBean.java	2009-04-06 10:56:30 UTC (rev 13385)
@@ -69,7 +69,7 @@
 	private String FILE_SAVE_ERROR;
 	
 	@In IImageAction imageAction;
-	@In @Out
+	@In(required = true, scope=ScopeType.CONVERSATION) @Out(scope=ScopeType.CONVERSATION)
 	FileWrapper fileWrapper;
 
 	@In Model model;

Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java	2009-04-06 09:34:17 UTC (rev 13384)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/FileWrapper.java	2009-04-06 10:56:30 UTC (rev 13385)
@@ -32,7 +32,7 @@
 import org.richfaces.realworld.domain.Image;
 
 @Name("fileWrapper")
- at Scope(ScopeType.SESSION)
+ at Scope(ScopeType.CONVERSATION)
 @AutoCreate
 public class FileWrapper implements Serializable{
 

Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java	2009-04-06 09:34:17 UTC (rev 13384)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/ui/UserPrefsHelper.java	2009-04-06 10:56:30 UTC (rev 13385)
@@ -5,7 +5,6 @@
 
 import java.io.File;
 import java.io.Serializable;
-import java.util.List;
 
 import javax.faces.model.SelectItem;
 
@@ -14,17 +13,11 @@
 import org.jboss.seam.annotations.Name;
 import org.jboss.seam.annotations.Out;
 import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.security.Restrict;
-import org.jboss.seam.core.Events;
 import org.richfaces.event.UploadEvent;
 import org.richfaces.model.UploadItem;
 import org.richfaces.realworld.domain.Sex;
 import org.richfaces.realworld.domain.User;
-import org.richfaces.realworld.manager.FileManager;
 import org.richfaces.realworld.manager.Model;
-import org.richfaces.realworld.manager.NavigationEnum;
-import org.richfaces.realworld.service.Constants;
-import org.richfaces.realworld.service.FlushStrategy;
 import org.richfaces.realworld.service.IUserAction;
 
 /**
@@ -32,22 +25,20 @@
  *
  */
 @Name("userPrefsBean")
- at Scope(ScopeType.SESSION)
+ at Scope(ScopeType.CONVERSATION)
 public class UserPrefsHelper implements Serializable{
-
 	private static final long serialVersionUID = -1767281809514660171L;
 	@In IUserAction userAction;
-	@In FileManager fileManager;
-	@In @Out Model model;
-	@In @Out User user;
 	
 	Boolean avatarModalOpened = false;
 	
-	File avatarData = null;
+	@In(required=false, scope=ScopeType.CONVERSATION) @Out(required=false, scope=ScopeType.CONVERSATION) private File avatarData;
 
-	static final Sex[] sexs = Sex.values();
+	static final SelectItem[] sexs = new SelectItem[] {
+			new SelectItem(Sex.MALE, "Male"),
+			new SelectItem(Sex.FEMALE, "Female") };
 	
-	public static Sex[] getSexs() {
+	public SelectItem [] getSexs() {
 		return sexs;
 	}
 
@@ -55,33 +46,6 @@
 		UploadItem item = event.getUploadItem();
 		avatarData = item.getFile();
 	}
-	
-	@Restrict("#{s:hasRole('admin')}")
-	//TODO nick - are we saving current user?
-	public void saveUser(){
-		if (avatarData != null) {
-			if(!fileManager.saveAvatar(avatarData.getPath(), user)){
-				Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, "File IO Error");
-				return;
-			}
-			avatarData.delete();
-			avatarData = null;
-			user.setHasAvatar(true);
-		}
-		user = userAction.updateUser();
-		model.resetModel(NavigationEnum.ALL_SHELFS, user, model.getSelectedShelf(), model.getSelectedAlbum(), model.getSelectedImage());
-	}
-	
-	public String goToIndex(){
-		return "index";
-	}
-	
-	@Restrict("#{s:hasRole('admin')}")
-	public void cancel() {
-		user = userAction.resetUser();
-		avatarData = null;
-		model.resetModel(NavigationEnum.ALL_SHELFS, user, model.getSelectedShelf(), model.getSelectedAlbum(), model.getSelectedImage());
-	}
 
 	public Boolean getAvatarModalOpened() {
 		return avatarModalOpened;
@@ -98,4 +62,4 @@
 	public void setAvatarData(File avatarData) {
 		this.avatarData = avatarData;
 	}
-}
+}
\ No newline at end of file

Modified: trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java
===================================================================
--- trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java	2009-04-06 09:34:17 UTC (rev 13384)
+++ trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java	2009-04-06 10:56:30 UTC (rev 13385)
@@ -57,8 +57,13 @@
     public void paintImage(OutputStream out, Object data) throws IOException {
         if (null == data) {
             return;
+        } 
+        File imageResource = null;
+        if(data.toString().endsWith("upload")){
+        	imageResource = fileManager.getFileByAbsolutePath(data.toString());
+        }else{
+        	imageResource = fileManager.getFileByPath(data.toString());
         }
-        File imageResource = fileManager.getFileByPath(data.toString());
         if (imageResource != null) {
             FileInputStream fileInputStream = new FileInputStream(imageResource);
             BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);

Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/avatar.xhtml
===================================================================
(Binary files differ)

Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs/userPrefsEdit.xhtml
===================================================================
(Binary files differ)

Modified: trunk/test-applications/realworld2/web/src/main/webapp/includes/userPrefs.xhtml
===================================================================
(Binary files differ)

Modified: trunk/test-applications/realworld2/web/src/main/webapp/register.xhtml
===================================================================
(Binary files differ)




More information about the richfaces-svn-commits mailing list