JBoss Rich Faces SVN: r11643 - in trunk/test-applications/seleniumTest/richfaces/src: main/webapp/pages/calendar and 1 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: dsvyatobatsko
Date: 2008-12-08 11:25:49 -0500 (Mon, 08 Dec 2008)
New Revision: 11643
Modified:
trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/showAttributesTest.xhtml
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
Log:
https://jira.jboss.org/jira/browse/RF-5254 completed
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-08 15:47:24 UTC (rev 11642)
+++ trunk/test-applications/seleniumTest/richfaces/src/main/java/org/ajax4jsf/bean/CalendarTestBean.java 2008-12-08 16:25:49 UTC (rev 11643)
@@ -423,7 +423,7 @@
this.showWeeksBar = showWeeksBar;
}
- public void initShowAttributes() {
+ public void initShowAttributesTest() {
showApplyButton = true;
showHeader = true;
showFooter = true;
Modified: trunk/test-applications/seleniumTest/richfaces/src/main/webapp/pages/calendar/showAttributesTest.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-08 15:47:24 UTC (rev 11642)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/testng/CalendarTest.java 2008-12-08 16:25:49 UTC (rev 11643)
@@ -39,7 +39,7 @@
static final String RESET_METHOD = "#{calendarBean.reset}";
- static final String INIT_SHOW_ATTRIBUTES = "#{calendarBean.initShowAttributes}";
+ static final String INIT_SHOW_ATTRIBUTES_TEST = "#{calendarBean.initShowAttributesTest}";
static final String FORM_ID = "_form:";
@@ -57,6 +57,8 @@
String calendarFooterId;
+ String weekDaysBarId;
+
String ajaxSubmitId;
String serverSubmitId;
@@ -101,6 +103,20 @@
String inputDateId;
+ String showApplyButtonId;
+
+ String showHeaderId;
+
+ String showFooterId;
+
+ String showInputId;
+
+ String showWeekDaysBarId;
+
+ String showWeeksBarId;
+
+ String showPopupId;
+
void initIds(String parentId) {
calendarId = parentId + FORM_ID + "calendar";
calendarHeaderId = calendarId + "Header";
@@ -127,6 +143,14 @@
currentDateHeaderXpath = "//td[@id='"+calendarHeaderId+"']/table/tbody/tr/td[3]/div";
popupButtonId = calendarId + "PopupButton";
inputDateId = calendarId + "InputDate";
+ showApplyButtonId = parentId + FORM_ID + "showApplyButton";
+ showHeaderId = parentId + FORM_ID + "showHeader";
+ showFooterId = parentId + FORM_ID + "showFooter";
+ showInputId = parentId + FORM_ID + "showInput";
+ showWeekDaysBarId = parentId + FORM_ID + "showWeekDaysBar";
+ showWeeksBarId = parentId + FORM_ID + "showWeeksBar";
+ showPopupId = parentId + FORM_ID + "showPopup";
+ weekDaysBarId = calendarId + "WeekDay";
}
String getStatus() {
@@ -628,15 +652,138 @@
@Test
public void testShowHeaderAttribute(Template template) {
- renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES);
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+ writeStatus("Check 'showHeader' attribute");
+
+ writeStatus("Non-popup mode");
+ check(showPopupId, false);
+
+ AssertPresent(calendarHeaderId, "Header is not present");
+ check(showHeaderId, false);
+ AssertNotPresent(calendarHeaderId, "Header is present");
+
+ writeStatus("Popup mode");
+ check(showPopupId, true);
+
+ showPopup();
+
+ AssertNotPresent(calendarHeaderId, "Header is present");
+ check(showHeaderId, true);
+ AssertPresent(calendarHeaderId, "Header is not present");
}
+ @Test
+ public void testShowFooterAttribute(Template template) {
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+ writeStatus("Check 'showFooter' attribute");
+
+ writeStatus("Non-popup mode");
+ check(showPopupId, false);
+
+ AssertPresent(calendarFooterId, "Footer is not present");
+ check(showFooterId, false);
+ AssertNotPresent(calendarFooterId, "Footer is present");
+
+ writeStatus("Popup mode");
+ check(showPopupId, true);
+
+ showPopup();
+
+ AssertNotPresent(calendarFooterId, "Footer is present");
+ check(showFooterId, true);
+ AssertPresent(calendarFooterId, "Footer is not present");
+ }
+
+ @Test
+ public void testShowWeekDaysBar(Template template) {
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+ writeStatus("Check 'showWeekDaysBar' attribute");
+
+ writeStatus("Non-popup mode");
+ check(showPopupId, false);
+
+ AssertPresent(weekDaysBarId, "Week days bar is not present");
+ check(showWeekDaysBarId, false);
+ AssertNotPresent(weekDaysBarId, "Week days bar is present");
+
+ writeStatus("Popup mode");
+ check(showPopupId, true);
+
+ showPopup();
+
+ AssertNotPresent(weekDaysBarId, "Week days bar is present");
+ check(showWeekDaysBarId, true);
+ AssertPresent(weekDaysBarId, "Week days bar is not present");
+ }
+
+ @Test
+ public void testShowWeeksBar(Template template) {
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+ String weeksBarId = calendarId + "WeekNumCell1";
+ writeStatus("Check 'showWeeksBar' attribute");
+
+ writeStatus("Non-popup mode");
+ check(showPopupId, false);
+
+ AssertPresent(weeksBarId, "Weeks bar is not present");
+ check(showWeeksBarId, false);
+ AssertNotPresent(weeksBarId, "Weeks bar is present");
+
+ writeStatus("Popup mode");
+ check(showPopupId, true);
+
+ showPopup();
+
+ AssertNotPresent(weeksBarId, "Weeks bar is present");
+ check(showWeeksBarId, true);
+ AssertPresent(weeksBarId, "Weeks bar is not present");
+ }
+
+ @Test
+ public void testShowInput(Template template) {
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+ writeStatus("Check 'showInput' attribute");
+
+ writeStatus("This attribute makes sense in popup mode only");
+ check(showPopupId, true);
+
+ AssertVisible(inputDateId, "Input is not visible");
+ check(showInputId, false);
+ AssertNotVisible(inputDateId, "Input is visible");
+ }
+
+ @Test
+ public void testShowApplyButton(Template template) {
+ renderPage(SHOW_ATTRIBURES_TEST_URL, template, INIT_SHOW_ATTRIBUTES_TEST);
+ initIds(getParentId());
+ String applyButtonXpath = "//td[@id='" + calendarFooterId + "']/table/tbody/tr/td[6]";
+ writeStatus("Check 'showApplyButton' attribute");
+
+ writeStatus("This attribute makes sense in popup mode only");
+ check(showPopupId, true);
+
+ showPopup();
+
+ Assert.assertTrue(isVisible(applyButtonXpath), "Apply button is not visible");
+ check(showApplyButtonId, false);
+ Assert.assertFalse(isVisible(applyButtonXpath), "Apply button is visible");
+ }
+
private void setPopup(boolean isPopup) {
- check(isPopupId, isPopup);
+ runScript("$('" + isPopupId + "').checked=" + isPopup);
}
- private void check(String checkBoxId, boolean isChecked) {
- runScript("$('" + checkBoxId + "').checked=" + isChecked);
+ private boolean check(String checkBoxId, boolean isChecked) {
+ boolean prevValue = Boolean.parseBoolean(runScript("$('" + checkBoxId + "').checked"));
+ if (prevValue != isChecked) {
+ clickAjaxCommandAndWait(checkBoxId);
+ }
+ return prevValue;
}
private void setup() {
16 years, 1 month
JBoss Rich Faces SVN: r11642 - in trunk/test-applications/realworld: ejb/src/main/java/org/richfaces/realworld/service and 7 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2008-12-08 10:47:24 -0500 (Mon, 08 Dec 2008)
New Revision: 11642
Added:
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/FriendHelper.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/SelectedImageIndex.java
Modified:
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Comment.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/FriendshipRequest.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Message.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java
trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/AvatarUpload.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/session/Authenticator.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeActionManager.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeRootItem.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeSelectionManager.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ModalPanelHelper.java
trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/NavigationHelper.java
trunk/test-applications/realworld/web/src/main/webapp/fileUpload.xhtml
trunk/test-applications/realworld/web/src/main/webapp/imagePreview.xhtml
trunk/test-applications/realworld/web/src/main/webapp/layout/menu.xhtml
trunk/test-applications/realworld/web/src/main/webapp/layout/menuShared.xhtml
trunk/test-applications/realworld/web/src/main/webapp/navigation.xhtml
trunk/test-applications/realworld/web/src/main/webapp/search.xhtml
trunk/test-applications/realworld/web/src/main/webapp/userPrefs.xhtml
Log:
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Album.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -30,6 +30,7 @@
import org.hibernate.validator.NotNull;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Role;
import org.jboss.seam.annotations.Scope;
/**
@@ -40,8 +41,8 @@
*/
@Entity
@Name("album")
-(a)Scope(ScopeType.PAGE)
@Table(name = "albums")
+@Role(name="selectedAlbum", scope = ScopeType.CONVERSATION)
public class Album implements Serializable {
private static final long serialVersionUID = -7042878411608396483L;
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Comment.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Comment.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Comment.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -24,7 +24,6 @@
@Entity
@Name("comment")
-(a)Scope(ScopeType.PAGE)
@Table(name = "comments")
public class Comment implements Serializable{
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/FriendshipRequest.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/FriendshipRequest.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/FriendshipRequest.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -1,5 +1,7 @@
package org.richfaces.realworld.domain;
+import java.io.Serializable;
+
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
@@ -17,7 +19,7 @@
@Entity
@Name("friendshipRequest")
@Table(name = "friendship_requests")
-public class FriendshipRequest {
+public class FriendshipRequest implements Serializable{
@Id
@GeneratedValue
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Image.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -31,6 +31,7 @@
import org.hibernate.validator.NotNull;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Role;
import org.jboss.seam.annotations.Scope;
/**
@@ -41,8 +42,8 @@
*/
@Entity
@Name("image")
-(a)Scope(ScopeType.PAGE)
@Table(name = "Images")
+@Role(name="selectedImage", scope = ScopeType.CONVERSATION)
public class Image implements Serializable {
private static final long serialVersionUID = -7042878411608396483L;
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Message.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Message.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/Message.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -24,7 +24,6 @@
@Entity
@Name("message")
@Table(name = "messages")
-(a)Scope(ScopeType.PAGE)
public class Message implements Serializable{
@Id
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/domain/User.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -31,6 +31,7 @@
import org.hibernate.validator.Pattern;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Role;
import org.jboss.seam.annotations.Scope;
/*@NamedQueries({
@@ -41,8 +42,9 @@
})*/
@Entity
+(a)Scope(ScopeType.SESSION)
@Name("user")
-(a)Scope(ScopeType.SESSION)
+@Role(name="selectedUser", scope = ScopeType.CONVERSATION)
@Table(name = "Users")
public class User implements Serializable {
@@ -319,4 +321,26 @@
return null;
}
+ public Album getAlbumByName(String albumName){
+ for(Album a : this.getChildAlbums()){
+ if(a.getName().equals(albumName)){
+ return a;
+ }
+ }
+ return null;
+ }
+
+ public void removeFromSharedAlbums(Album album) {
+ sharedAlbums.remove(album);
+ }
+
+ public void addSharedAlbum(Album album) {
+ if (album == null) {
+ throw new IllegalArgumentException("Null album!");
+ }
+ if(sharedAlbums.contains(album)){
+ return;
+ }
+ sharedAlbums.add(album);
+ }
}
\ No newline at end of file
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/AlbumAction.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -13,7 +13,6 @@
import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.User;
-@Stateful
@Name("albumAction")
public class AlbumAction implements IAlbumAction {
//@PersistenceContext(unitName = "entityManager", type=PersistenceContextType.EXTENDED)
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/IUserAction.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -8,12 +8,13 @@
import javax.ejb.Remove;
import org.jboss.seam.annotations.Destroy;
+import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.FriendshipRequest;
import org.richfaces.realworld.domain.User;
@Local
public interface IUserAction {
- public boolean login(String username, String password);
+ public User login(String username, String password);
@Remove
public void remove();
@@ -30,4 +31,6 @@
public void removeFromFriends(User owner, User removed);
public boolean friendExist(User user, User friend);
public void addFriend(User user, User friend, FriendshipRequest request);
+ public void removeFromSharedAlbums(User user, Album album);
+ public void addSharedAlbum(Album album);
}
\ No newline at end of file
Modified: trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java
===================================================================
--- trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/ejb/src/main/java/org/richfaces/realworld/service/UserAction.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -35,12 +35,11 @@
@In(create = true, required = true) @Out
private User user;
- public boolean login(String username, String password) {
- user = (User)em.createQuery("from User u where u.login = :username and u.password = :password")
+ public User login(String username, String password) {
+ return user = (User)em.createQuery("from User u where u.login = :username and u.password = :password")
.setParameter("username", username)
.setParameter("password", password)
.getSingleResult();
- return user != null;
}
@Remove
@@ -106,4 +105,14 @@
user.addFriend(friend);
friend.addFriend(user);
}
+
+ public void removeFromSharedAlbums(User user, Album album) {
+ user.removeFromSharedAlbums(album);
+ em.flush();
+ }
+
+ public void addSharedAlbum(Album album) {
+ user.addSharedAlbum(album);
+
+ }
}
\ No newline at end of file
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/AvatarUpload.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/AvatarUpload.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/AvatarUpload.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -20,7 +20,7 @@
import org.richfaces.realworld.domain.User;
@Name("avatarUpload")
-(a)Scope(ScopeType.PAGE)
+(a)Scope(ScopeType.CONVERSATION)
public class AvatarUpload implements Serializable{
@In(create=true)
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/fileupload/FileUploadBean.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -36,6 +36,7 @@
import org.jboss.seam.faces.FacesMessages;
import org.richfaces.event.UploadEvent;
import org.richfaces.model.UploadItem;
+import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.tree.TreeActionManager;
@@ -46,17 +47,20 @@
*
*/
@Name("fileUploadBean")
-(a)Scope(ScopeType.SESSION)
+(a)Scope(ScopeType.CONVERSATION)
@Synchronized(timeout=2000)
public class FileUploadBean implements Serializable{
@In @Out
private User user;
- @In
- TreeSelectionManager treeSelectionManager;
-
@In(create=true)
+ private Image selectedImage;
+
+ @In(create=true)
+ private Album selectedAlbum;
+
+ @In(create=true)
TreeActionManager treeActionManager;
@In(create=true)
@@ -90,8 +94,8 @@
image.setDescription("Sample Description");
image.setName("Sample Name");
image.setPath(item.getFileName());
- image.setAlbumName(treeSelectionManager.getSelectedAlbum().getName());
- image.setAlbum(treeSelectionManager.getSelectedAlbum());
+ image.setAlbumName(selectedAlbum.getName());
+ image.setAlbum(selectedAlbum);
file.setImage(image);
files.add(file);
}
@@ -112,7 +116,7 @@
for(FileItem file:files){
if(file.isSelected()){
//Save file to disk
- String fileName = user.getLogin() + fileManager.getFileSeparator() + treeSelectionManager.getSelectedAlbum().getName() + fileManager.getFileSeparator() + file.getImage().getPath();
+ String fileName = user.getLogin() + fileManager.getFileSeparator() + selectedAlbum.getName() + fileManager.getFileSeparator() + file.getImage().getPath();
try {
fileManager.addImage(fileName , file.getData());
} catch (IOException e) {
@@ -127,7 +131,7 @@
public void storeAll() {
for(FileItem file:files){
//Save file to disk
- String fileName = user.getLogin() + fileManager.getFileSeparator() + treeSelectionManager.getSelectedAlbum().getName() + fileManager.getFileSeparator() + file.getImage().getPath();
+ String fileName = user.getLogin() + fileManager.getFileSeparator() + selectedAlbum.getName() + fileManager.getFileSeparator() + file.getImage().getPath();
try {
fileManager.addImage(fileName , file.getData());
} catch (IOException e) {
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/search/SearchBean.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -26,6 +26,7 @@
import org.richfaces.realworld.service.ISearchService;
@Name("searchBean")
+(a)Scope(ScopeType.CONVERSATION)
public class SearchBean implements Serializable {
/**
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/session/Authenticator.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/session/Authenticator.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/session/Authenticator.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -6,26 +6,41 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
+import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.Scope;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.Log;
import org.jboss.seam.security.Identity;
import org.jboss.seam.web.Session;
+import org.richfaces.realworld.domain.Album;
+import org.richfaces.realworld.domain.Image;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.fileupload.AvatarUpload;
import org.richfaces.realworld.fileupload.FileManager;
import org.richfaces.realworld.service.IUserAction;
@Name("authenticator")
+(a)Scope(ScopeType.CONVERSATION)
public class Authenticator
{
@Logger Log log;
@In Identity identity;
+ @Out
+ private Image selectedImage;
+
+ @Out(required=false)
+ private User selectedUser;
+
+ @Out
+ private Album selectedAlbum;
+
@In FacesMessages facesMessages;
@In(create = true)
@@ -45,11 +60,19 @@
{
log.info("authenticating #0", identity.getUsername());
try{
- if(userAction.login(identity.getUsername(), identity.getPassword())){
+ User user = userAction.login(identity.getUsername(), identity.getPassword());
+ if(user != null){
identity.addRole("admin");
if(!fileManager.isDirectoryPresent(identity.getUsername())){
fileManager.addDirectory(identity.getUsername());
}
+ if(user.getChildAlbums().size() > 0){
+ selectedAlbum = user.getChildAlbums().get(0);
+ if(selectedAlbum.getImages().size() > 0){
+ selectedImage = selectedAlbum.getImages().get(0);
+ }
+ selectedUser = user;
+ }
return true;
}
}catch(Exception nre){
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeActionManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeActionManager.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeActionManager.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -8,6 +8,7 @@
import javax.faces.model.SelectItem;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
@@ -23,15 +24,20 @@
import org.richfaces.realworld.service.IImageAction;
import org.richfaces.realworld.service.IMessageAction;
import org.richfaces.realworld.service.IUserAction;
+import org.richfaces.realworld.util.NavigationEnum;
import org.richfaces.realworld.util.RatingHelper;
+import org.richfaces.realworld.util.SelectedImageIndex;
@Name("treeActionManager")
-(a)Scope(ScopeType.PAGE)
+(a)Scope(ScopeType.CONVERSATION)
public class TreeActionManager implements Serializable{
@In
private User user;
+ @Out(required=false)
+ private User selectedUser;
+
@In(create=true, required=true)
private IAlbumAction albumAction;
@@ -50,22 +56,40 @@
@In(create=true, required=true) @Out
private Album album;
+ @In(create=true) @Out
+ private SelectedImageIndex selectedImageIndex;
+
@In(create=true)
FileManager fileManager;
+ @In(create=true) @Out
+ private Image selectedImage;
+
+ @In(create=true) @Out
+ private Album selectedAlbum;
+
+ @In(create=true) TreeSelectionManager treeSelectionManager;
+
@In(create=true) TreeRootItem treeRoot;
- @In(create=true, required=true)
- TreeSelectionManager treeSelectionManager;
+ private String selectedAlbumName;
+ public String getSelectedAlbumName() {
+ return selectedAlbumName;
+ }
+
+ public void setSelectedAlbumName(String selectedAlbumName) {
+ this.selectedAlbumName = selectedAlbumName;
+ }
+
public void addAlbum(){
albumAction.addAlbum(album);
treeRoot.getAvailableAlbums().add(new SelectItem(album.getName()));
TreeAlbumItem albumItem = new TreeAlbumItem(album.getId(), treeRoot, album);
treeRoot.addAlbumToTree(albumItem);
fileManager.addDirectory(user.getLogin() + fileManager.getFileSeparator() + album.getName());
- treeSelectionManager.setSelectedImage(null);
- treeSelectionManager.setSelectedAlbum(albumItem.getAlbum());
+ selectedImage = null;
+ selectedAlbum = albumItem.getAlbum();
}
@@ -100,8 +124,8 @@
treeRoot.getAvailableAlbums().remove(item);
treeRoot.removeChild(album.getId());
fileManager.deleteDirectory(user.getLogin() + fileManager.getFileSeparator() + albumName);
- treeSelectionManager.setSelectedImage(null);
- treeSelectionManager.setSelectedAlbum(null);
+ selectedImage = null;
+ selectedAlbum = null;
}
public void deleteImage(Image image){
@@ -111,7 +135,7 @@
imageAction.deleteImage(image);
parent.removeChild(image.getId());
fileManager.deleteImage(user.getLogin() + fileManager.getFileSeparator() + albumName + fileManager.getFileSeparator() + imagePath);
- treeSelectionManager.setSelectedImage(null);
+ selectedImage = null;
}
public void editImage(Image image){
@@ -127,8 +151,8 @@
String fileNameOld = user.getLogin() + fileManager.getFileSeparator() + image.getAlbum().getName() + fileManager.getFileSeparator() + image.getPath();
String fileNameNew = user.getLogin() + fileManager.getFileSeparator() + image.getAlbumName() + fileManager.getFileSeparator() + image.getPath();
fileManager.renameImage(fileNameOld, fileNameNew);
- treeSelectionManager.setSelectedImage(imageItem.getImage());
- treeSelectionManager.setSelectedAlbum(albumItem.getAlbum());
+ selectedImage = imageItem.getImage();
+ selectedAlbum = albumItem.getAlbum();
}else{
TreeImageItem imageItem = (TreeImageItem)parent.getChild(image.getId());
imageItem.setImage(image);
@@ -140,8 +164,8 @@
TreeAlbumItem albumItem = treeRoot.getAlbumByName(image.getAlbumName());
TreeImageItem imageItem = new TreeImageItem(image.getId(),albumItem,image);
albumItem.addChild(image.getId(), imageItem);
- treeSelectionManager.setSelectedImage(imageItem.getImage());
- treeSelectionManager.setSelectedAlbum(albumItem.getAlbum());
+ selectedImage = imageItem.getImage();
+ selectedAlbum = albumItem.getAlbum();
}
public void editComment(Comment comment) {
@@ -152,7 +176,7 @@
imageAction.addComment(comment);
}
- public void addAutoComment(User user, Image image) {
+ public void addAutoComment(Image image) {
Comment comment = new Comment();
comment.setAuthor(user);
comment.setDate(new Date());
@@ -203,7 +227,32 @@
}*/
}
+ public void addToSharedAlbums(Image image){
+ userAction.addSharedAlbum(image.getAlbum());
+ }
+
+ @Begin(join=true)
+ public void removeFromSharedAlbums(Album album){
+ userAction.removeFromSharedAlbums(user, album);
+ }
+
public void vote(Image image){
imageAction.vote(image, (Long)Long.valueOf(ratingHelper.getInputSlider().getValue().toString()));
}
+
+ public void showSharedAlbum(Image image){
+ NavigationEnum mainArea = NavigationEnum.IMAGE_PREVIEW;
+ treeSelectionManager.setMainArea(mainArea);
+ selectedUser = image.getAlbum().getOwner();
+ selectedAlbum = image.getAlbum();
+ selectedImage = selectedAlbum.getImages().get(0);
+ selectedImageIndex.setSelectedImageIndex(1);
+ }
+
+ @Begin(join=true)
+ public void updateSelectedAlbum(){
+ selectedAlbum = user.getAlbumByName(this.getSelectedAlbumName());
+ selectedImage = selectedAlbum.getImages().get(0);
+ selectedImageIndex.setSelectedImageIndex(1);
+ }
}
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeRootItem.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeRootItem.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeRootItem.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -21,7 +21,7 @@
import org.richfaces.realworld.service.IImageAction;
@Name("treeRoot")
-(a)Scope(ScopeType.PAGE)
+(a)Scope(ScopeType.CONVERSATION)
public class TreeRootItem implements TreeNode {
@In @Out
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeSelectionManager.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeSelectionManager.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/tree/TreeSelectionManager.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -17,17 +17,16 @@
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
-import javax.faces.model.SelectItemGroup;
import javax.imageio.ImageIO;
import org.ajax4jsf.context.AjaxContext;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.annotations.Synchronized;
-import org.richfaces.component.UIDataTable;
import org.richfaces.component.UIDatascroller;
import org.richfaces.component.UIDragSupport;
import org.richfaces.component.UITree;
@@ -43,24 +42,26 @@
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.fileupload.FileManager;
import org.richfaces.realworld.util.NavigationEnum;
+import org.richfaces.realworld.util.SelectedImageIndex;
@Name("treeSelectionManager")
+(a)Scope(ScopeType.CONVERSATION)
@Synchronized(timeout=2000)
-(a)Scope(ScopeType.SESSION)
public class TreeSelectionManager implements Serializable{
- private static final FacesContext FacesContext = null;
-
@In
private User user;
private NavigationEnum mainArea = NavigationEnum.IMAGE_PREVIEW;
+ @In(required=false) @Out
private Image selectedImage;
+ @In(required=false) @Out
private Album selectedAlbum;
- private int selectedImageIndex = 1;
+ @In(create=true) @Out
+ private SelectedImageIndex selectedImageIndex;
@In(create=true)
FileManager fileManager;
@@ -70,127 +71,43 @@
private String nodeTitle;
- public Album getSelectedAlbum() {
- return selectedAlbum;
- }
-
public void showFileUpload(TreeAlbumItem item){
- this.setSelectedAlbum(item.getAlbum());
+ selectedAlbum = item.getAlbum();
if(item.isLeaf()){
- this.setSelectedImage(null);
+ selectedImage=null;
}else{
- this.setSelectedImage(((TreeImageItem)(item.getImages().get(0))).getImage());
+ selectedImage = ((TreeImageItem)(item.getImages().get(0))).getImage();
}
this.setMainArea(NavigationEnum.FILE_UPLOAD);
}
public void scrollerListener(DataScrollerEvent event) {
- List<Image> images = this.getSelectedAlbum().getImages();
+ List<Image> images = selectedAlbum.getImages();
if (event.getNewScrolVal().equals("previous")) {
for(int index = 0 ; index < images.size(); index++){
- if(images.get(index) == this.getSelectedImage()){
- this.setSelectedImage(images.get(index - 1));
- this.setSelectedImageIndex(index);
+ if(images.get(index) == selectedImage){
+ selectedImage = images.get(index - 1);
+ selectedImageIndex.setSelectedImageIndex(index);
}
}
} else if (event.getNewScrolVal().equals("last")) {
- this.setSelectedImage(images.get(images.size() - 1));
- this.setSelectedImageIndex(images.size());
+ selectedImage = images.get(images.size() - 1);
+ selectedImageIndex.setSelectedImageIndex(images.size());
} else if (event.getNewScrolVal().equals("next")) {
for(int index = 0 ; index < images.size(); index++){
- if(images.get(index) == this.getSelectedImage()){
- this.setSelectedImage(images.get(index + 1));
- this.setSelectedImageIndex(index + 2);
+ if(images.get(index) == selectedImage){
+ selectedImage = images.get(index + 1);
+ selectedImageIndex.setSelectedImageIndex(index + 2);
return;
}
}
} else if (event.getNewScrolVal().equals("first")) {
- this.setSelectedImage(images.get(0));
- this.setSelectedImageIndex(1);
+ selectedImage = images.get(0);
+ selectedImageIndex.setSelectedImageIndex(1);
}
}
- public synchronized void paint(OutputStream out, Object data) throws IOException{
- if (null == data) {
- return;
- }
- File imageResource = fileManager.getImage(user.getLogin() + fileManager.getFileSeparator() + this.getSelectedAlbum().getName() + fileManager.getFileSeparator() + data.toString());
- if (imageResource != null) {
- FileInputStream fileInputStream = new FileInputStream(imageResource);
- BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
- InputStream paintData = bufferedInputStream;
- if (null == paintData) {
- // throw new Exception("");
- // TODO
- }
- try{
- BufferedImage image = ImageIO.read(paintData);
- ImageIO.write(image, "jpeg", out);
- }catch(Exception e){
-
- }finally{
- fileInputStream.close();
- bufferedInputStream.close();
- paintData.close();
- }
- }
- }
-
- public synchronized void paintAvatar(OutputStream out, Object data) throws IOException{
- if (null == data) {
- return;
- }
- File imageResource = fileManager.getImage(user.getLogin() + fileManager.getFileSeparator() + "avatars" + fileManager.getFileSeparator() + data.toString());
- if (imageResource != null) {
- FileInputStream fileInputStream = new FileInputStream(imageResource);
- BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
- InputStream paintData = bufferedInputStream;
- if (null == paintData) {
- // throw new Exception("");
- // TODO
- }
- try{
- BufferedImage image = ImageIO.read(paintData);
- ImageIO.write(image, "jpeg", out);
- }catch(Exception e){
-
- }finally{
- fileInputStream.close();
- bufferedInputStream.close();
- paintData.close();
- }
- }
- }
-
- public synchronized void paintFriendAvatar(OutputStream out, Object data) throws IOException{
- if (null == data) {
- return;
- }
- String temp = data.toString();
- String[] array = temp.split(":");
- File imageResource = fileManager.getImage(array[0] + fileManager.getFileSeparator() + "avatars" + fileManager.getFileSeparator() + array[1]);
- if (imageResource != null) {
- FileInputStream fileInputStream = new FileInputStream(imageResource);
- BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
- InputStream paintData = bufferedInputStream;
- if (null == paintData) {
- // throw new Exception("");
- // TODO
- }
- try{
- BufferedImage image = ImageIO.read(paintData);
- ImageIO.write(image, "jpeg", out);
- }catch(Exception e){
-
- }finally{
- fileInputStream.close();
- bufferedInputStream.close();
- paintData.close();
- }
- }
- }
-
public void dropListener(DropEvent dropEvent) {
// resolve drag destination attributes
@@ -275,37 +192,14 @@
return index;
}
- public Image getSelectedImage() {
- return selectedImage;
- }
-
- public void setSelectedImage(Image selectedImage) {
- this.selectedImage = selectedImage;
- }
-
- public void setSelectedAlbum(Album selectedAlbum) {
- this.selectedAlbum = selectedAlbum;
- }
-
public Boolean adviseNodeSelected(UITree tree) {
TreeRowKey treeRowKey = (TreeRowKey) tree.getRowKey();
TreeNode treeNode = (TreeNode) tree.getRowData(treeRowKey);
-
- if(treeNode instanceof TreeAlbumItem){
- TreeAlbumItem currentNode = (TreeAlbumItem)treeNode;
- if(this.getSelectedAlbum() != null){
- return currentNode.getAlbum() == this.getSelectedAlbum() && null == this.getSelectedImage() ? Boolean.TRUE: Boolean.FALSE;
- }else{
- this.setSelectedAlbum(currentNode.getAlbum());
- if(currentNode.isLeaf()){
- return Boolean.TRUE ;
- }else{
- this.setSelectedImage(((TreeImageItem)(currentNode.getImages().get(0))).getImage());
- return Boolean.FALSE ;
- }
- }
- }else if(treeNode instanceof TreeImageItem){
- return ((TreeImageItem)treeNode).getImage() == this.getSelectedImage() ? Boolean.TRUE : Boolean.FALSE;
+ if (treeNode instanceof TreeAlbumItem) {
+ TreeAlbumItem currentNode = (TreeAlbumItem) treeNode;
+ return currentNode.getAlbum() == selectedAlbum;
+ } else if (treeNode instanceof TreeImageItem) {
+ return ((TreeImageItem) treeNode).getImage() == selectedImage;
}
return null;
}
@@ -313,17 +207,9 @@
public Boolean adviseNodeOpened(UITree tree) {
TreeRowKey treeRowKey = (TreeRowKey) tree.getRowKey();
TreeNode treeNode = (TreeNode) tree.getRowData(treeRowKey);
- if(treeNode instanceof TreeAlbumItem){
- TreeAlbumItem currentNode = (TreeAlbumItem)treeNode;
- if(this.getSelectedAlbum() != null){
- return currentNode.getAlbum() == this.getSelectedAlbum() ? Boolean.TRUE: Boolean.FALSE;
- }else{
- this.setSelectedAlbum(currentNode.getAlbum());
- if(!currentNode.isLeaf()){
- this.setSelectedImage(((TreeImageItem)currentNode.getImages().get(0)).getImage());
- }
- return Boolean.TRUE ;
- }
+ if (treeNode instanceof TreeAlbumItem) {
+ TreeAlbumItem currentNode = (TreeAlbumItem) treeNode;
+ return currentNode.getAlbum() == selectedAlbum;
}
return null;
}
@@ -340,10 +226,10 @@
TreeNode<String> currentNode = tree.getModelTreeNode(tree.getRowKey());
if(currentNode instanceof TreeImageItem){
Image image = ((TreeImageItem)currentNode).getImage();
- this.setSelectedImage(image);
+ selectedImage = image;
Album album = ((TreeAlbumItem)currentNode.getParent()).getAlbum();
- if(album != this.getSelectedAlbum()){
- this.setSelectedAlbum(album);
+ if(album != selectedAlbum){
+ selectedAlbum = album;
}
int index = album.getIndex(image);
setDataScrollerIndex(index);
@@ -352,29 +238,29 @@
TreeAlbumItem node = (TreeAlbumItem)currentNode;
setDataScrollerIndex(0);
if (node.isLeaf()) {
- this.setSelectedImage(null);
+ selectedImage = null;
Album album = node.getAlbum();
- this.setSelectedAlbum(album);
+ selectedAlbum = album;
}else{
- if(node.getAlbum() == this.getSelectedAlbum()){
+ if(node.getAlbum() == selectedAlbum){
return;
}else{
- setSelectedAlbum(node.getAlbum());
- this.setSelectedImage(node.getAlbum().getImages().get(0));
+ selectedAlbum = node.getAlbum();
+ selectedImage = node.getAlbum().getImages().get(0);
}
}
}
}
public void updateScroller(ActionEvent event){
- this.setDataScrollerIndex(this.selectedImageIndex - 1);
+ this.setDataScrollerIndex(selectedImageIndex.getSelectedImageIndex()- 1);
}
private void setDataScrollerIndex(int index) {
UIComponent component = FacesContext.getCurrentInstance().getViewRoot();
UIDatascroller scroller = (UIDatascroller)component.findComponent("mainform:sc1");
scroller.setPage(index+1);
- this.setSelectedImageIndex(index+1);
+ selectedImageIndex.setSelectedImageIndex(index+1);
}
public String getNodeTitle() {
@@ -392,20 +278,18 @@
public void setMainArea(NavigationEnum mainArea) {
this.mainArea = mainArea;
}
-
- public int getSelectedImageIndex() {
- return selectedImageIndex;
- }
-
- public void setSelectedImageIndex(int selectedImageIndex) {
- this.selectedImageIndex = selectedImageIndex;
- }
public SelectItem[] getAvailableIndexOfImages(){
- SelectItem[] group = new SelectItem[this.getSelectedAlbum().getImages().size()];
- for(int i = 0; i < this.getSelectedAlbum().getImages().size(); i++){
+ SelectItem[] group = new SelectItem[selectedAlbum.getImages().size()];
+ for(int i = 0; i < selectedAlbum.getImages().size(); i++){
group[i] = new SelectItem(i+1);
}
return group;
}
+
+ public void updateSelectedItems(Image image){
+ selectedImage = image;
+ Integer index = selectedAlbum.getIndex(selectedImage);
+ setDataScrollerIndex(index);
+ }
}
Added: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/FriendHelper.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/FriendHelper.java (rev 0)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/FriendHelper.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -0,0 +1,65 @@
+package org.richfaces.realworld.util;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.Scope;
+import org.richfaces.realworld.domain.Album;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.User;
+
+@Name("friendHelper")
+(a)Scope(ScopeType.CONVERSATION)
+public class FriendHelper {
+
+ @Out(required=false)
+ private User selectedUser;
+
+ @In(required=false) @Out
+ private Image selectedImage;
+
+ @In(required=false) @Out
+ private Album selectedAlbum;
+
+ @In(create=true) @Out
+ private SelectedImageIndex selectedImageIndex;
+
+ private String albumName;
+
+ public String getAlbumName() {
+ return albumName;
+ }
+
+ public void setAlbumName(String albumName) {
+ this.albumName = albumName;
+ }
+
+ public List<String> getFriendAlbums(User friend){
+ List<String> albumNames = new ArrayList<String>();
+ for(Album album:friend.getChildAlbums()){
+ albumNames.add(album.getName());
+ }
+ return albumNames;
+ }
+
+ @Begin(join=true)
+ public void chooseAlbum(User friend){
+ selectedUser = friend;
+ selectedAlbum = selectedUser.getAlbumByName(this.getAlbumName());
+ selectedImage = selectedAlbum.getImages().get(0);
+ selectedImageIndex.setSelectedImageIndex(1);
+ }
+
+ @Begin(join=true)
+ public void chooseAlbum(Album album){
+ selectedUser = album.getOwner();
+ selectedAlbum = album;
+ selectedImage = selectedAlbum.getImages().get(0);
+ selectedImageIndex.setSelectedImageIndex(1);
+ }
+}
Property changes on: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/FriendHelper.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Added: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java (rev 0)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -0,0 +1,112 @@
+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 org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.User;
+import org.richfaces.realworld.fileupload.FileManager;
+
+@Name("imageLoader")
+(a)Scope(ScopeType.CONVERSATION)
+public class ImageLoader {
+
+ @In(create=true)
+ FileManager fileManager;
+
+ @In
+ private User user;
+
+ public synchronized void paint(OutputStream out, Object data) throws IOException{
+ if (null == data) {
+ return;
+ }
+ Image image = (Image)data;
+ File imageResource = fileManager.getImage(image.getAlbum().getOwner().getLogin() + fileManager.getFileSeparator() + image.getAlbum().getName() + fileManager.getFileSeparator() + image.getPath());
+ if (imageResource != null) {
+ FileInputStream fileInputStream = new FileInputStream(imageResource);
+ BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
+ InputStream paintData = bufferedInputStream;
+ if (null == paintData) {
+ // throw new Exception("");
+ // TODO
+ }
+ try{
+ BufferedImage images = ImageIO.read(paintData);
+ ImageIO.write(images, "jpeg", out);
+ }catch(Exception e){
+
+ }finally{
+ fileInputStream.close();
+ bufferedInputStream.close();
+ paintData.close();
+ }
+ }
+ }
+
+ public synchronized void paintAvatar(OutputStream out, Object data) throws IOException{
+ if (null == data) {
+ return;
+ }
+ File imageResource = fileManager.getImage(user.getLogin() + fileManager.getFileSeparator() + "avatars" + fileManager.getFileSeparator() + data.toString());
+ if (imageResource != null) {
+ FileInputStream fileInputStream = new FileInputStream(imageResource);
+ BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
+ InputStream paintData = bufferedInputStream;
+ if (null == paintData) {
+ // throw new Exception("");
+ // TODO
+ }
+ try{
+ BufferedImage image = ImageIO.read(paintData);
+ ImageIO.write(image, "jpeg", out);
+ }catch(Exception e){
+
+ }finally{
+ fileInputStream.close();
+ bufferedInputStream.close();
+ paintData.close();
+ }
+ }
+ }
+
+ public synchronized void paintFriendAvatar(OutputStream out, Object data) throws IOException{
+ if (null == data) {
+ return;
+ }
+ String temp = data.toString();
+ String[] array = temp.split(":");
+ File imageResource = fileManager.getImage(array[0] + fileManager.getFileSeparator() + "avatars" + fileManager.getFileSeparator() + array[1]);
+ if (imageResource != null) {
+ FileInputStream fileInputStream = new FileInputStream(imageResource);
+ BufferedInputStream bufferedInputStream = new BufferedInputStream(fileInputStream);
+ InputStream paintData = bufferedInputStream;
+ if (null == paintData) {
+ // throw new Exception("");
+ // TODO
+ }
+ try{
+ BufferedImage image = ImageIO.read(paintData);
+ ImageIO.write(image, "jpeg", out);
+ }catch(Exception e){
+
+ }finally{
+ fileInputStream.close();
+ bufferedInputStream.close();
+ paintData.close();
+ }
+ }
+ }
+}
Property changes on: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ImageLoader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ModalPanelHelper.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ModalPanelHelper.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/ModalPanelHelper.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -18,7 +18,7 @@
import org.richfaces.realworld.tree.TreeActionManager;
@Name("modalPanelHelper")
-(a)Scope(ScopeType.SESSION)
+(a)Scope(ScopeType.CONVERSATION)
public class ModalPanelHelper implements Serializable{
private String caption;
@@ -145,7 +145,7 @@
this.searchRequired = false;
}
- public void initModalPanelData( String actionName, String caption, Comment comment, User user, Image image){
+ public void initModalPanelData( String actionName, String caption, Comment comment, Image image){
this.caption = caption;
this.actionName = actionName;
if(null != comment){
Modified: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/NavigationHelper.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/NavigationHelper.java 2008-12-08 15:38:23 UTC (rev 11641)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/NavigationHelper.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -1,8 +1,11 @@
package org.richfaces.realworld.util;
+import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
@Name(value="navigationHelper")
+(a)Scope(ScopeType.CONVERSATION)
public class NavigationHelper {
private NavigationEnum navigationEnum;
Added: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/SelectedImageIndex.java
===================================================================
--- trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/SelectedImageIndex.java (rev 0)
+++ trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/SelectedImageIndex.java 2008-12-08 15:47:24 UTC (rev 11642)
@@ -0,0 +1,20 @@
+package org.richfaces.realworld.util;
+
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+
+@Name("selectedImageIndex")
+(a)Scope(ScopeType.CONVERSATION)
+public class SelectedImageIndex {
+
+ private Integer selectedImageIndex = 1;
+
+ public Integer getSelectedImageIndex() {
+ return selectedImageIndex;
+ }
+
+ public void setSelectedImageIndex(Integer selectedImageIndex) {
+ this.selectedImageIndex = selectedImageIndex;
+ }
+}
Property changes on: trunk/test-applications/realworld/web/src/main/java/org/richfaces/realworld/util/SelectedImageIndex.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Id Revision Date
Name: svn:eol-style
+ native
Modified: trunk/test-applications/realworld/web/src/main/webapp/fileUpload.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/imagePreview.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/layout/menu.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/layout/menuShared.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/navigation.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/search.xhtml
===================================================================
(Binary files differ)
Modified: trunk/test-applications/realworld/web/src/main/webapp/userPrefs.xhtml
===================================================================
(Binary files differ)
16 years, 1 month
JBoss Rich Faces SVN: r11641 - trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2008-12-08 10:38:23 -0500 (Mon, 08 Dec 2008)
New Revision: 11641
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
Log:
RF-5197
only for test
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-12-08 15:29:18 UTC (rev 11640)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-12-08 15:38:23 UTC (rev 11641)
@@ -157,8 +157,12 @@
System.out.println("------>firefoxDir#" + j + ": " + firefoxDirs[j].getPath());
File[] firefoxes = firefoxDirs[j].listFiles(new FileFilter() {
public boolean accept(File pathname) {
- return pathname != null&& pathname.getName().startsWith("firefox")
- && pathname.isFile();
+ boolean result = false;
+ if (pathname != null && pathname.isFile()) {
+ String name = pathname.getName();
+ result = "firefox".equals(name) || "firefox-bin".equals(name);
+ }
+ return result;
}
});
for (int k = firefoxes.length - 1; k >= 0 && "*firefox".equals(browser); k--) {
16 years, 1 month
JBoss Rich Faces SVN: r11640 - trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2008-12-08 10:29:18 -0500 (Mon, 08 Dec 2008)
New Revision: 11640
Modified:
trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
Log:
RF-5197
only for test
Modified: trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java
===================================================================
--- trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-12-08 15:26:58 UTC (rev 11639)
+++ trunk/test-applications/seleniumTest/richfaces/src/test/java/org/richfaces/SeleniumTestBase.java 2008-12-08 15:29:18 UTC (rev 11640)
@@ -23,8 +23,8 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileFilter;
import java.io.FileInputStream;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -141,25 +141,33 @@
@BeforeClass
@Parameters({"browser", "filterPrefix"})
public void startSelenium(String browser, String filterPrefix) {
- String[] paths = {"/usr/lib/firefox-1.0.4/firefox-bin",
- "/usr/lib/firefox-1.5.0.10/firefox-bin",
- "/usr/lib/firefox-1.5.0.12/firefox-bin",
- "/usr/lib64/firefox-1.5.0.12/firefox-bin",
- "/usr/lib/firefox-3.0b5/firefox-bin",
- "/usr/lib64/firefox-3.0b5/firefox-bin",
- "/usr/lib/firefox-3.0.1/firefox-bin",
- "/usr/lib64/firefox-3.0.1/firefox-bin",
- "/usr/lib/firefox/firefox-bin",
- "/usr/lib/firefox-1.5.0.9/firefox-bin"
- };
if ("*firefox".equals(browser)) {
- for (int i = 0; i < paths.length && "*firefox".equals(browser); i++) {
- String path = paths[i];
- File file = new File(path);
- if (file.isFile()) {
- browser += " " + path;
- }
- }
+ File[] libs = {new File("/usr/lib"), new File("/usr/lib64")};
+ for (int i = 0; i < libs.length && "*firefox".equals(browser); i++) {
+ File lib = libs[i];
+ if (lib.isDirectory()) {
+ System.out.println("---->lib#" + i + ": " + lib.getPath());
+ File[] firefoxDirs = lib.listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ return pathname != null&& pathname.getName().startsWith("firefox")
+ && pathname.isDirectory();
+ }
+ });
+ for (int j = firefoxDirs.length - 1; j >= 0 && "*firefox".equals(browser); j--) {
+ System.out.println("------>firefoxDir#" + j + ": " + firefoxDirs[j].getPath());
+ File[] firefoxes = firefoxDirs[j].listFiles(new FileFilter() {
+ public boolean accept(File pathname) {
+ return pathname != null&& pathname.getName().startsWith("firefox")
+ && pathname.isFile();
+ }
+ });
+ for (int k = firefoxes.length - 1; k >= 0 && "*firefox".equals(browser); k--) {
+ System.out.println("-------->firefoxes#" + k + ": " + firefoxes[k].getPath());
+ browser += " " + firefoxes[k].getPath();
+ }
+ }
+ }
+ }
}
synchronized (MUTEX) {
this.filterPrefix = filterPrefix;
16 years, 1 month
JBoss Rich Faces SVN: r11639 - in trunk/samples/richfaces-demo/src/main: java/org/richfaces/demo/queue and 6 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: ilya_shaikovsky
Date: 2008-12-08 10:26:58 -0500 (Mon, 08 Dec 2008)
New Revision: 11639
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/queue/
trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/queue/MojarraBean.java
trunk/samples/richfaces-demo/src/main/webapp/css/queueStylesheet.css
trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/resources/
trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/resources/bgblack18.jpg
trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/resources/button2.gif
trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/resources/button3.gif
trunk/samples/richfaces-demo/src/main/webapp/scripts/queueUi.js
Modified:
trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/queue.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/usage.xhtml
Log:
Added: trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/queue/MojarraBean.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/queue/MojarraBean.java (rev 0)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/demo/queue/MojarraBean.java 2008-12-08 15:26:58 UTC (rev 11639)
@@ -0,0 +1,25 @@
+package org.richfaces.demo.queue;
+
+
+import java.util.Random;
+
+import javax.faces.event.ActionEvent;
+
+/**
+ * <p>This simple bean conains one <code>ActionEvent</code>
+ * handler to simulate random processing times for
+ * requests on the server.
+ * <p/>
+ *
+ */
+public class MojarraBean {
+
+ public void process(ActionEvent ae) {
+ Random generator2 = new Random(System.currentTimeMillis());
+ int delay = generator2.nextInt(6001) + 1;
+ try {
+ Thread.sleep(delay);
+ } catch (Exception e) {
+ }
+ }
+}
Modified: trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2008-12-08 15:18:10 UTC (rev 11638)
+++ trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2008-12-08 15:26:58 UTC (rev 11639)
@@ -413,6 +413,11 @@
<managed-bean-class>org.richfaces.demo.editor.EditorBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+ <managed-bean>
+ <managed-bean-name>mojarraBean</managed-bean-name>
+ <managed-bean-class>org.richfaces.demo.queue.MojarraBean</managed-bean-class>
+ <managed-bean-scope>session</managed-bean-scope>
+ </managed-bean>
<navigation-rule>
<from-view-id>/richfaces/include/examples/wstep1.xhtml</from-view-id>
<navigation-case>
Added: trunk/samples/richfaces-demo/src/main/webapp/css/queueStylesheet.css
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/css/queueStylesheet.css (rev 0)
+++ trunk/samples/richfaces-demo/src/main/webapp/css/queueStylesheet.css 2008-12-08 15:26:58 UTC (rev 11639)
@@ -0,0 +1,90 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common Development
+ * and Distribution License("CDDL") (collectively, the "License"). You
+ * may not use this file except in compliance with the License. You can obtain
+ * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
+ * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
+ * language governing permissions and limitations under the License.
+ *
+ * When distributing the software, include this License Header Notice in each
+ * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
+ * Sun designates this particular file as subject to the "Classpath" exception
+ * as provided by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the License
+ * Header, with the fields enclosed by brackets [] replaced by your own
+ * identifying information: "Portions Copyrighted [year]
+ * [name of copyright owner]"
+ *
+ * Contributor(s):
+ *
+ * If you wish your version of this file to be governed by only the CDDL or
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
+ * elects to include this software in this distribution under the [CDDL or GPL
+ * Version 2] license." If you don't indicate a single choice of license, a
+ * recipient has the option to distribute your version of this file under
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
+ * its licensees as provided above. However, if you add GPL Version 2 code
+ * and therefore, elected the GPL Version 2 license, then the option applies
+ * only if the new code is made subject to such option by the copyright
+ * holder.
+ */
+
+.title-panel {
+ background-image: url('bgblack18.jpg');
+ height: 80px;
+ width: 900px;
+}
+
+.title-panel-text {
+ color: white;
+ font-family: 'Georgia','Times New Roman','times',serif;
+ font-size: 24px;
+ font-weight: bold;
+}
+
+.title-panel-subtext {
+ color: white;
+ font-family: 'Georgia','Times New Roman','times',serif;
+ font-size: 14px;
+ font-style: italic
+}
+
+body {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 12px;
+}
+
+.panel-input-border {
+ border: 2px outset blue;
+ background-color: #e0eeee;
+}
+
+.panel-data-border {
+ border: 3px outset blue;
+ background-color: #e0eeee;
+}
+
+.keytitle {
+ font-family: Arial, Helvetica, sans-serif;
+ font-size: 16px;
+ color: #330066;
+}
+
+.ticker {
+ position: relative;
+ visibility: hidden;
+ font-size: 16px;
+}
+
+.serialize-border {
+ border: 4px outset red;
+}
+
+.queueCell {
+ background-color: #00ffff;
+}
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/queue.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/queue.xhtml 2008-12-08 15:18:10 UTC (rev 11638)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/queue.xhtml 2008-12-08 15:26:58 UTC (rev 11639)
@@ -3,22 +3,43 @@
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:a4j="http://richfaces.org/a4j"
- xmlns:rich="http://richfaces.org/rich">
- <style>
- .link{
- width:40px;
- height:40px;
- }
- </style>
- <h:form>
- <rich:dataGrid value="#{queueBean.buttons}" var="button" columns="4">
- <rich:paint2D cacheable="false" paint="#{queueBean.paint}" data="#{button.color}">
- </rich:paint2D>
- <ui:remove>
- <h:panelGroup layout="block" style="background-color: #{button.color}" styleClass="link">
- <h:outputText value="#{button.name}"/>
- </h:panelGroup>
- </ui:remove>
- </rich:dataGrid>
- </h:form>
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:c="http://java.sun.com/jstl/core">
+ <a4j:loadScript src="/scripts/queueUi.js"/>
+ <a4j:loadStyle src="/css/queueStylesheet.js"/>
+ <h:form id="form1" prependId="false">
+ <a4j:queue />
+
+ <h:panelGrid columns="2" cellspacing="5">
+ <h:panelGrid id="board1" columns="6" border="1">
+ <f:facet name="header">
+ <h:outputText value="Ajax Requests" styleClass="keytitle" />
+ </f:facet>
+
+ <c:forEach begin="0" end="17" step="1" var="i">
+ <h:panelGrid>
+ <a4j:commandButton id="_#{i}" image="queue/examples/resources/button2.gif"
+ style="height:50px;width:50px;"
+ onclick="buttonpush('_#{i}');"
+ oncomplete="buttonpop('_#{i}');"
+ actionListener="#{mojarraBean.process}" />
+ <h:panelGrid cellpadding="5">
+ <h:outputText value="#{i}" style="font-weight:bold"/>
+ </h:panelGrid>
+ </h:panelGrid>
+ </c:forEach>
+ </h:panelGrid>
+ <h:panelGrid>
+ <f:facet name="header">
+ <h:outputText value="Request Queue" styleClass="keytitle" />
+ </f:facet>
+ <table id="queuetable" border="1">
+ <tr id="tr1">
+ </tr>
+ </table>
+ </h:panelGrid>
+ </h:panelGrid>
+
+ </h:form>
+
</ui:composition>
Added: trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/resources/bgblack18.jpg
===================================================================
(Binary files differ)
Property changes on: trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/resources/bgblack18.jpg
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/resources/button2.gif
===================================================================
(Binary files differ)
Property changes on: trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/resources/button2.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/resources/button3.gif
===================================================================
(Binary files differ)
Property changes on: trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/examples/resources/button3.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/usage.xhtml 2008-12-08 15:18:10 UTC (rev 11638)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/queue/usage.xhtml 2008-12-08 15:26:58 UTC (rev 11639)
@@ -8,8 +8,16 @@
<ui:composition template="/templates/component-sample.xhtml">
<ui:define name="sample">
<p>
- DESCRIPTION
+ The <b>Ajax Requests</b> area represent individual Ajax requests that can be fired by clicking the green images (a4j:commandLink components).
+ A <i>JSF managed bean</i> on the server causes a random sleep time (4 seconds or less) to simulate
+ different processing times for each request. The <a4j:queue/> (defined as global
+ for the form where controls placed) handles all the requests and fires next one only after
+ the responce from previous returned.
</p>
+ <p>
+ The demo JavaScript on the client includes a function that subscribes to these queue events, so the UI is updated as queue events happen.<br />
+ Just click on any sequence of green images (any number, any order) and you will see that each request is handled in the order they were fired.
+ </p>
<fieldset class="demo_fieldset">
<legend class="demo_legend">Queue demo</legend>
Added: trunk/samples/richfaces-demo/src/main/webapp/scripts/queueUi.js
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/scripts/queueUi.js (rev 0)
+++ trunk/samples/richfaces-demo/src/main/webapp/scripts/queueUi.js 2008-12-08 15:26:58 UTC (rev 11639)
@@ -0,0 +1,50 @@
+var disabledImage = 'queue/examples/resources/button3.gif';
+var enabledImage = 'queue/examples/resources/button2.gif';
+
+function buttonpush(buttonName) {
+ var button = document.getElementById(buttonName);
+ if (!button.disabled) {
+ button.src = disabledImage;
+ button.disabled = true;
+ }
+ var txt = document.createTextNode(buttonName);
+ addCell(txt);
+}
+
+function buttonpop(buttonName) {
+ var txt = document.createTextNode(buttonName);
+ removeCell(txt);
+}
+
+function addCell(cellData) {
+ var cell = document.getElementById("tr1").insertCell(0);
+ cell.setAttribute("height", "50px");
+ cell.setAttribute("width", "50px");
+ cell.innerHTML = cellData.nodeValue;
+ cell.className = "queueCell";
+}
+
+function removeCell(cellData) {
+ var row = document.getElementById("tr1");
+ var cells = row.getElementsByTagName("td");
+ if (typeof cells != 'undefined' || cells != null) {
+ for (var i=0; i<cells.length; i++) {
+ if (cells[i].firstChild.nodeValue == cellData.nodeValue) {
+ row.deleteCell(i);
+ var button = document.getElementById(cellData.nodeValue);
+ button.disabled = false;
+ button.src = enabledImage;
+ break;
+ }
+ }
+ }
+}
+
+function errorMsg(eventName, data) {
+ alert("Name: "+eventName+" Error Status: "+data.statusMessage);
+}
+
+// Listen for all queue events
+//OpenAjax.hub.subscribe("javax.faces.Event.**",msg);
+// Listen for all error events
+//OpenAjax.hub.subscribe("javax.faces.Error.**",errorMsg);
\ No newline at end of file
16 years, 1 month
JBoss Rich Faces SVN: r11638 - trunk/ui/message/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-12-08 10:18:10 -0500 (Mon, 08 Dec 2008)
New Revision: 11638
Modified:
trunk/ui/message/src/main/config/component/message.xml
Log:
https://jira.jboss.org/jira/browse/RF-5094
Modified: trunk/ui/message/src/main/config/component/message.xml
===================================================================
--- trunk/ui/message/src/main/config/component/message.xml 2008-12-08 14:44:09 UTC (rev 11637)
+++ trunk/ui/message/src/main/config/component/message.xml 2008-12-08 15:18:10 UTC (rev 11638)
@@ -255,9 +255,13 @@
The attribute takes a value-binding expression for a component property of a backing bean
</description>
</property>
-
+
&ui_component_attributes;
&ajax_output_attributes;
+ <property hidden="true">
+ <name>keepTransient</name>
+ <classname>boolean</classname>
+ </property>
</component>
<component>
@@ -529,9 +533,13 @@
The attribute takes a value-binding expression for a component property of a backing bean
</description>
</property>
-
&ui_component_attributes;
&ajax_output_attributes;
+ <property hidden="true">
+ <name>keepTransient</name>
+ <classname>boolean</classname>
+ </property>
+
</component>
</components>
\ No newline at end of file
16 years, 1 month
JBoss Rich Faces SVN: r11637 - trunk/ui/core/src/main/java/org/ajax4jsf/component.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-12-08 09:44:09 -0500 (Mon, 08 Dec 2008)
New Revision: 11637
Modified:
trunk/ui/core/src/main/java/org/ajax4jsf/component/UIQueue.java
Log:
TODO done
Modified: trunk/ui/core/src/main/java/org/ajax4jsf/component/UIQueue.java
===================================================================
--- trunk/ui/core/src/main/java/org/ajax4jsf/component/UIQueue.java 2008-12-08 14:43:40 UTC (rev 11636)
+++ trunk/ui/core/src/main/java/org/ajax4jsf/component/UIQueue.java 2008-12-08 14:44:09 UTC (rev 11637)
@@ -33,7 +33,6 @@
*/
public abstract class UIQueue extends UIComponentBase {
- //TODO move to appropriate place
public static final String GLOBAL_QUEUE_NAME = "org.richfaces.queue.global";
public static final String COMPONENT_TYPE = "org.ajax4jsf.Queue";
16 years, 1 month
JBoss Rich Faces SVN: r11636 - trunk/framework/impl/src/main/javascript/ajaxjsf.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-12-08 09:43:40 -0500 (Mon, 08 Dec 2008)
New Revision: 11636
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
Log:
Queue: clearing on window unload implemented
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-12-08 14:43:06 UTC (rev 11635)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/queue.js 2008-12-08 14:43:40 UTC (rev 11636)
@@ -1,14 +1,5 @@
-//TODO observe unload
-//unload
-
A4J.AJAX._eventQueues = {};
-var extend = function(target, source) {
- for (var property in source) {
- target[property] = source[property];
- }
-};
-
//queue constructor
A4J.AJAX.EventQueue = function() {
var DROP_NEW = 'dropNew';
@@ -16,6 +7,12 @@
var FIRE_NEW = 'fireNew';
var FIRE_NEXT = 'fireNext';
+ var extend = function(target, source) {
+ for (var property in source) {
+ target[property] = source[property];
+ }
+ };
+
var extendOptions = function(options) {
var opts = {};
@@ -69,6 +66,9 @@
abort: function() {
if (this.request) {
+ //tell request not to notify queue after its processing finished
+ //request.queue = undefined
+ //is not ok for this case because user might want to obtain queue in any event handler
this.request.shouldNotifyQueue = false;
this.request.abort();
this.request = undefined;
@@ -107,6 +107,14 @@
}
},
+ clearEntry: function() {
+ this.stopTimer();
+ if (this.request) {
+ this.request.shouldNotifyQueue = false;
+ this.request = undefined;
+ }
+ },
+
getEventsCount: function() {
return this.eventsCount;
},
@@ -137,6 +145,8 @@
LOG.debug("Queue '" + this.name + "' will submit request NOW");
var req = firstItem.submit();
+
+ //see entry.abort() method for more details about this assignment
req.shouldNotifyQueue = true;
if (this.requestOptions.queueonsubmit) {
@@ -280,6 +290,15 @@
LOG.debug("There are " + this.items.length + " requests more in this queue");
this.submitFirst();
+ },
+
+ clear: function() {
+ var length = this.items.length;
+ for ( var i = 0; i < this.items.length; i++) {
+ this.items[i].clearEntry();
+ }
+
+ this.items.splice(0, length);
}
});
@@ -292,6 +311,10 @@
return A4J.AJAX._eventQueues[name];
};
+A4J.AJAX.EventQueue.getQueues = function() {
+ return A4J.AJAX._eventQueues;
+};
+
A4J.AJAX.EventQueue.addQueue = function(queue) {
var name = queue.name;
@@ -304,6 +327,12 @@
};
A4J.AJAX.EventQueue.removeQueue = function(name) {
+ var queue = A4J.AJAX._eventQueues[name];
+
+ if (queue) {
+ queue.clear();
+ }
+
delete A4J.AJAX._eventQueues[name];
};
@@ -373,4 +402,20 @@
return queue;
}
-}();
\ No newline at end of file
+}();
+
+(function () {
+ var observer = function() {
+ var queues = A4J.AJAX.EventQueue.getQueues();
+ for (var queueName in queues) {
+ var queue = queues[queueName];
+ queue.clear();
+ }
+ };
+
+ if (window.addEventListener) {
+ window.addEventListener("unload", observer, false);
+ } else {
+ window.attachEvent("onunload", observer);
+ }
+})();
\ No newline at end of file
16 years, 1 month
JBoss Rich Faces SVN: r11635 - trunk/framework/impl/src/main/javascript/ajaxjsf.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2008-12-08 09:43:06 -0500 (Mon, 08 Dec 2008)
New Revision: 11635
Modified:
trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
Log:
Fixed possible memory leaks in Ajax script
Modified: trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js
===================================================================
--- trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-12-08 14:38:05 UTC (rev 11634)
+++ trunk/framework/impl/src/main/javascript/ajaxjsf/JSFAJAX.js 2008-12-08 14:43:06 UTC (rev 11635)
@@ -55,9 +55,13 @@
if(window.document.documentElement != _this._documentElement){
LOG.warn("Page for current request have been unloaded - abort processing" );
_this.abort();
+ _this = undefined;
return;
};
- if(_this._aborted){return;};
+ if(_this._aborted){
+ _this = undefined;
+ return;
+ };
LOG.debug("Reqest state : "+_this._request.readyState );
if (_this._request.readyState == 4 ) {
LOG.debug("Reqest end with state 4");
16 years, 1 month
JBoss Rich Faces SVN: r11634 - trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2008-12-08 09:38:05 -0500 (Mon, 08 Dec 2008)
New Revision: 11634
Modified:
trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js
Log:
fix setValue in save() method
Modified: trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js
===================================================================
--- trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js 2008-12-08 14:09:12 UTC (rev 11633)
+++ trunk/ui/inplaceInput/src/main/resources/org/richfaces/renderkit/html/scripts/inplaceinput.js 2008-12-08 14:38:05 UTC (rev 11634)
@@ -298,8 +298,8 @@
save : function(e) {
if (this.invokeEvent(this.events.onviewactivation, this.inplaceInput, "rich:onviewactivation", {oldValue : this.valueKeeper.value, value : this.tempValueKeeper.value})) {
- var userValue = {value:this.tempValueKeeper.value};
- this.setValue(e,userValue);
+ var userValue = this.tempValueKeeper.value;
+ this.setValue(userValue);
if (this.events.onviewactivated) {
this.inplaceInput.fire("rich:onviewactivated", {oldValue : this.valueKeeper.value, value : this.tempValueKeeper.value});
}
16 years, 1 month