JBoss Rich Faces SVN: r14024 - in trunk/ui/componentControl/src/main: java/org/richfaces/component and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-05-05 13:33:02 -0400 (Tue, 05 May 2009)
New Revision: 14024
Modified:
trunk/ui/componentControl/src/main/config/component/componentControl.xml
trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java
Log:
https://jira.jboss.org/jira/browse/RF-6275
Modified: trunk/ui/componentControl/src/main/config/component/componentControl.xml
===================================================================
--- trunk/ui/componentControl/src/main/config/component/componentControl.xml 2009-05-05 16:29:40 UTC (rev 14023)
+++ trunk/ui/componentControl/src/main/config/component/componentControl.xml 2009-05-05 17:33:02 UTC (rev 14024)
@@ -37,6 +37,7 @@
<description>
Disable default action for target event ( append "return false;" to JavaScript )
</description>
+ <!-- Has a special dynamic default value -->
</property>
<property>
<name>event</name>
Modified: trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java
===================================================================
--- trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java 2009-05-05 16:29:40 UTC (rev 14023)
+++ trunk/ui/componentControl/src/main/java/org/richfaces/component/UIComponentControl.java 2009-05-05 17:33:02 UTC (rev 14024)
@@ -21,7 +21,9 @@
package org.richfaces.component;
+import javax.el.ELException;
import javax.el.ValueExpression;
+import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.component.UIComponentBase;
import javax.faces.component.UIParameter;
@@ -51,6 +53,9 @@
private static final Log log = LogFactory.getLog(UIComponentControl.class);
+ private boolean disableDefault = false;
+ private boolean disableDefaultSet = false;
+
/**
* @return JavaScript eventString. Rebuild on every call, since can be in
* loop ( as in dataTable ) with different parameters.
@@ -137,6 +142,35 @@
public abstract void setAttachTo(String value);
+ public boolean isDisableDefault() {
+ if (this.disableDefaultSet) {
+ return (this.disableDefault);
+ }
+
+ ValueExpression ve = getValueExpression("disableDefault");
+ if (ve != null) {
+ Boolean value = null;
+
+ try {
+ value = (Boolean) ve.getValue(getFacesContext().getELContext());
+ } catch (ELException e) {
+ throw new FacesException(e);
+ }
+
+ if (null != value) {
+ return value.booleanValue();
+ }
+ }
+
+ String event = getEvent();
+ return ("contextmenu".equalsIgnoreCase(event) || "oncontextmenu".equalsIgnoreCase(event));
+ }
+
+ public void setDisableDefault(boolean disableDefault) {
+ this.disableDefaultSet = true;
+ this.disableDefault = disableDefault;
+ }
+
protected String replaceClientIds(FacesContext context,
UIComponent component, String selector) {
return HtmlUtil.expandIdSelector(selector, component, context);
@@ -197,4 +231,22 @@
public abstract void setAttachTiming(String attachTiming);
public abstract String getAttachTiming();
+
+ @Override
+ public Object saveState(FacesContext context) {
+ Object[] state = new Object[3];
+ state[0] = super.saveState(context);
+ state[1] = this.disableDefault ? Boolean.TRUE : Boolean.FALSE;
+ state[2] = this.disableDefaultSet ? Boolean.TRUE : Boolean.FALSE;
+
+ return state;
+ }
+
+ @Override
+ public void restoreState(FacesContext context, Object stateObject) {
+ Object[] state = (Object[]) stateObject;
+ super.restoreState(context, state[0]);
+ this.disableDefault = ((Boolean) state[1]).booleanValue();
+ this.disableDefaultSet = ((Boolean) state[2]).booleanValue();
+ }
}
15 years, 7 months
JBoss Rich Faces SVN: r14023 - in trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum: service and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-05-05 12:29:40 -0400 (Tue, 05 May 2009)
New Revision: 14023
Modified:
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Comment.java
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/AlbumAction.java
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IAlbumAction.java
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IImageAction.java
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IShelfAction.java
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ImageAction.java
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ShelfAction.java
Log:
Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Comment.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Comment.java 2009-05-05 16:29:24 UTC (rev 14022)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/Comment.java 2009-05-05 16:29:40 UTC (rev 14023)
@@ -64,7 +64,7 @@
@JoinColumn(nullable = false)
private Image image;
- @ManyToOne(cascade = CascadeType.REMOVE, fetch = FetchType.LAZY)
+ @ManyToOne(fetch = FetchType.LAZY)
@OnDelete(action = OnDeleteAction.CASCADE)
@JoinColumn(nullable = true)
private User author;
Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java 2009-05-05 16:29:24 UTC (rev 14022)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java 2009-05-05 16:29:40 UTC (rev 14023)
@@ -66,6 +66,10 @@
query = "select u from User u where u.login = :username and u.passwordHash = :password"
),
@NamedQuery(
+ name = "user-comments",
+ query = "select c from Comment c where c.author = :author"
+ ),
+ @NamedQuery(
name = "user-exist",
query = "select u from User u where u.login = :login"
),
Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/AlbumAction.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/AlbumAction.java 2009-05-05 16:29:24 UTC (rev 14022)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/AlbumAction.java 2009-05-05 16:29:40 UTC (rev 14023)
@@ -96,4 +96,12 @@
throw new PhotoAlbumException(e.getMessage());
}
}
+
+ /**
+ * Refresh state of given album
+ * @param album - album to Synchronize
+ */
+ public void resetAlbum(Album album) {
+ em.refresh(album);
+ }
}
Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java 2009-05-05 16:29:24 UTC (rev 14022)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java 2009-05-05 16:29:40 UTC (rev 14023)
@@ -170,6 +170,8 @@
public static final String SEARCH_NO_OPTIONS_ERROR = "You must select at least one search option";
public static final String TREE_ID = "treeform";
public static final String SEARCH_NO_WHERE_OPTIONS_ERROR = "You must specify where search execute";
+ public static final String USER_COMMENTS_QUERY = "user-comments";
+ public static final String AUTHOR_PARAMETER = "author";
private Constants(){
}
}
\ No newline at end of file
Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IAlbumAction.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IAlbumAction.java 2009-05-05 16:29:24 UTC (rev 14022)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IAlbumAction.java 2009-05-05 16:29:40 UTC (rev 14023)
@@ -38,5 +38,7 @@
void deleteAlbum(Album album) throws PhotoAlbumException;
void editAlbum(Album album) throws PhotoAlbumException;
+
+ public void resetAlbum(Album album);
}
\ No newline at end of file
Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IImageAction.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IImageAction.java 2009-05-05 16:29:24 UTC (rev 14022)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IImageAction.java 2009-05-05 16:29:40 UTC (rev 14023)
@@ -27,6 +27,7 @@
import org.richfaces.photoalbum.domain.Comment;
import org.richfaces.photoalbum.domain.Image;
import org.richfaces.photoalbum.domain.MetaTag;
+import org.richfaces.photoalbum.domain.User;
/**
* Interface for manipulating with image entity
@@ -55,4 +56,8 @@
public boolean isImageWithThisPathExist(Image image);
+ public List<Comment> findAllUserComments(User user);
+
+ public void resetImage(Image imageo);
+
}
\ No newline at end of file
Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IShelfAction.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IShelfAction.java 2009-05-05 16:29:24 UTC (rev 14022)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/IShelfAction.java 2009-05-05 16:29:40 UTC (rev 14023)
@@ -43,4 +43,6 @@
void editShelf(Shelf shelf) throws PhotoAlbumException;
List<Shelf> getPredefinedShelves();
+
+ void resetShelf(Shelf shelf);
}
Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ImageAction.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ImageAction.java 2009-05-05 16:29:24 UTC (rev 14022)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ImageAction.java 2009-05-05 16:29:40 UTC (rev 14023)
@@ -36,6 +36,8 @@
import org.richfaces.photoalbum.domain.Comment;
import org.richfaces.photoalbum.domain.Image;
import org.richfaces.photoalbum.domain.MetaTag;
+import org.richfaces.photoalbum.domain.Shelf;
+import org.richfaces.photoalbum.domain.User;
/**
* Class for manipulating with image entity. Analogous to DAO pattern.
* EJB3 Bean
@@ -157,10 +159,10 @@
*/
public void deleteComment(Comment comment) throws PhotoAlbumException {
try{
+ Image image = comment.getImage();
em.remove(comment);
+ image.removeComment(comment);
em.flush();
-
- em.refresh(comment.getImage());
}
catch(Exception e){
throw new PhotoAlbumException(e.getMessage());
@@ -228,4 +230,22 @@
.setParameter(Constants.ALBUM_PARAMETER, image.getAlbum())
.getResultList().size() != 0;
}
+
+ /**
+ * Retrieve all cooments posted by given user.
+ * @return list of comments
+ */
+ public List<Comment> findAllUserComments(User user) {
+ return em.createNamedQuery(Constants.USER_COMMENTS_QUERY)
+ .setParameter(Constants.AUTHOR_PARAMETER, user)
+ .getResultList();
+ }
+
+ /**
+ * Refresh state of given image
+ * @param image - image to Synchronize
+ */
+ public void resetImage(Image image) {
+ em.refresh(image);
+ }
}
Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ShelfAction.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ShelfAction.java 2009-05-05 16:29:24 UTC (rev 14022)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/ShelfAction.java 2009-05-05 16:29:40 UTC (rev 14023)
@@ -106,4 +106,12 @@
public List<Shelf> getPredefinedShelves() {
return em.createNamedQuery(Constants.USER_SHELVES_QUERY).getResultList();
}
+
+ /**
+ * Refresh state of given shelf
+ * @param shelf - shelf to Synchronize
+ */
+ public void resetShelf(Shelf shelf) {
+ em.refresh(shelf);
+ }
}
\ No newline at end of file
15 years, 7 months
JBoss Rich Faces SVN: r14022 - in trunk/examples/photoalbum/source/web/src/main: java/org/richfaces/photoalbum/util and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-05-05 12:29:24 -0400 (Tue, 05 May 2009)
New Revision: 14022
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Controller.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/SessionListener.java
trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties
trunk/examples/photoalbum/source/web/src/main/webapp/includes/album/createAlbum.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageEditInfo.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/inputNumberSlider.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/index/menu.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/misc/confirmation.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/search.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/shelf/createShelf.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/userPrefs/userPrefsEdit.xhtml
Log:
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java 2009-05-05 14:38:33 UTC (rev 14021)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java 2009-05-05 16:29:24 UTC (rev 14022)
@@ -125,6 +125,7 @@
albumAction.editAlbum(album);
}catch(Exception e){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.ALBUM_SAVING_ERROR);
+ albumAction.resetAlbum(album);
return;
}
//Reset 'album' component in conversation scope
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Controller.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Controller.java 2009-05-05 14:38:33 UTC (rev 14021)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Controller.java 2009-05-05 16:29:24 UTC (rev 14022)
@@ -287,6 +287,14 @@
return image.isOwner(user);
}
+ public boolean isUserHaveShelves(){
+ return user.getShelves().size() > 0 ;
+ }
+
+ public boolean isUserHaveAlbums(){
+ return user.getAlbums().size() > 0 ;
+ }
+
public boolean isUserShelf(Shelf shelf){
return shelf != null && shelf.isOwner(user);
}
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java 2009-05-05 14:38:33 UTC (rev 14021)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java 2009-05-05 16:29:24 UTC (rev 14022)
@@ -85,6 +85,7 @@
imageAction.editImage(image, metatagsChanged);
}catch(Exception e){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.IMAGE_SAVING_ERROR);
+ imageAction.resetImage(image);
return;
}
Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.ALBUM_IMAGE_PREVIEW);
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java 2009-05-05 14:38:33 UTC (rev 14021)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java 2009-05-05 16:29:24 UTC (rev 14022)
@@ -98,6 +98,7 @@
shelfAction.editShelf(shelf);
}catch(Exception e){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.SHELF_SAVING_ERROR);
+ shelfAction.resetShelf(shelf);
return;
}
Events.instance().raiseEvent(Constants.SHELF_EDITED_EVENT, shelf);
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/SessionListener.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/SessionListener.java 2009-05-05 14:38:33 UTC (rev 14021)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/SessionListener.java 2009-05-05 16:29:24 UTC (rev 14022)
@@ -1,5 +1,7 @@
package org.richfaces.photoalbum.util;
+import java.util.List;
+
import javax.persistence.EntityManager;
import org.jboss.seam.ScopeType;
@@ -11,8 +13,10 @@
import org.jboss.seam.annotations.Startup;
import org.jboss.seam.annotations.Transactional;
import org.jboss.seam.core.Events;
+import org.richfaces.photoalbum.domain.Comment;
import org.richfaces.photoalbum.domain.User;
import org.richfaces.photoalbum.service.Constants;
+import org.richfaces.photoalbum.service.IImageAction;
@Scope(ScopeType.SESSION)
@Name("sessionListener")
@@ -21,12 +25,18 @@
@In(required=false) User user;
+ @In IImageAction imageAction;
+
@In(value="entityManager") EntityManager em;
@Destroy @Transactional @Observer("org.jboss.seam.sessionExpired")
public void onDestroy(){
if(user.getId() != null && !user.isPreDefined()){
user = em.merge(user);
+ List<Comment> userComments = imageAction.findAllUserComments(user);
+ for(Comment c : userComments){
+ em.remove(c);
+ }
em.remove(user);
em.flush();
Events.instance().raiseEvent(Constants.USER_DELETED_EVENT, user);
Modified: trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties 2009-05-05 14:38:33 UTC (rev 14021)
+++ trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties 2009-05-05 16:29:24 UTC (rev 14022)
@@ -260,7 +260,7 @@
search_criteria=Search criteria:
keywords=Keywords:
user_profile_=User profile
-
+message_authorHeader=Author
all_new_images=All new images
in_album=in album
public_shelves=Pre-defined Shelves
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/album/createAlbum.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageEditInfo.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/inputNumberSlider.xhtml
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/inputNumberSlider.xhtml 2009-05-05 14:38:33 UTC (rev 14021)
+++ trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/inputNumberSlider.xhtml 2009-05-05 16:29:24 UTC (rev 14022)
@@ -8,7 +8,7 @@
<div><rich:inputNumberSlider enableManualInput="false"
value="#{imageSizeHelper.value}" minValue="80" maxValue="200"
showArrows="false" showBoundaryValues="true" showInput="false"
- step="40">
+ step="40" width="100">
<a4j:support event="onchange" reRender="userAlbumImages" />
</rich:inputNumberSlider></div>
</ui:composition>
\ No newline at end of file
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/index/menu.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/misc/confirmation.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/search.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/shelf/createShelf.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/userPrefs/userPrefsEdit.xhtml
===================================================================
(Binary files differ)
15 years, 7 months
JBoss Rich Faces SVN: r14021 - in trunk/ui/contextMenu/src/main: java/org/richfaces/component and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: nbelaevski
Date: 2009-05-05 10:38:33 -0400 (Tue, 05 May 2009)
New Revision: 14021
Modified:
trunk/ui/contextMenu/src/main/config/component/contextMenu.xml
trunk/ui/contextMenu/src/main/java/org/richfaces/component/UIContextMenu.java
Log:
https://jira.jboss.org/jira/browse/RF-3532
Modified: trunk/ui/contextMenu/src/main/config/component/contextMenu.xml
===================================================================
--- trunk/ui/contextMenu/src/main/config/component/contextMenu.xml 2009-05-05 13:54:14 UTC (rev 14020)
+++ trunk/ui/contextMenu/src/main/config/component/contextMenu.xml 2009-05-05 14:38:33 UTC (rev 14021)
@@ -56,9 +56,9 @@
<name>disableDefaultMenu</name>
<classname>boolean</classname>
<description>
- Forbids default handling for adjusted event. Default value "true".
+ Forbids default handling for adjusted event. Default value "false".
</description>
- <defaultvalue><![CDATA[getEvent().equalsIgnoreCase("onContextMenu")]]></defaultvalue>
+ <defaultvalue><![CDATA[false]]></defaultvalue>
</property>
<property>
<name>showDelay</name>
Modified: trunk/ui/contextMenu/src/main/java/org/richfaces/component/UIContextMenu.java
===================================================================
--- trunk/ui/contextMenu/src/main/java/org/richfaces/component/UIContextMenu.java 2009-05-05 13:54:14 UTC (rev 14020)
+++ trunk/ui/contextMenu/src/main/java/org/richfaces/component/UIContextMenu.java 2009-05-05 14:38:33 UTC (rev 14021)
@@ -21,11 +21,7 @@
package org.richfaces.component;
-import javax.el.ELException;
-import javax.el.ValueExpression;
-import javax.faces.FacesException;
import javax.faces.component.UIComponentBase;
-import javax.faces.context.FacesContext;
/**
* @author Maksim Kaszynski
@@ -37,9 +33,6 @@
public static final String ON_CONTEXT_MENU = "onContextMenu";
public static final String DISABLE_DEFAULT_MENU = "disableDefaultMenu";
- private boolean disableDefaultMenu = false;
- private boolean disableDefaultMenuSet = false;
-
public abstract boolean isAttached();
public abstract void setAttached(boolean b);
@@ -55,45 +48,7 @@
public abstract void setShowDelay(Integer showDelay);
public abstract Integer getShowDelay();
- public boolean isDisableDefaultMenu() {
- if (this.disableDefaultMenuSet) {
- return this.disableDefaultMenu;
- }
-
- ValueExpression ve = getValueExpression(DISABLE_DEFAULT_MENU);
- if (ve != null) {
- try {
- Boolean value = (Boolean) ve.getValue(getFacesContext().getELContext());
- if (value != null) {
- return value;
- }
- } catch (ELException e) {
- throw new FacesException(e);
- }
- }
-
- return ON_CONTEXT_MENU.equalsIgnoreCase(getEvent());
- }
+ public abstract boolean isDisableDefaultMenu();
+ public abstract void setDisableDefaultMenu(boolean disableDefault);
- public void setDisableDefaultMenu(boolean disableDefault) {
- this.disableDefaultMenu = disableDefault;
- this.disableDefaultMenuSet = true;
- }
-
- @Override
- public Object saveState(FacesContext context) {
- Object[] state = new Object[9];
- state[0] = super.saveState(context);
- state[1] = isDisableDefaultMenu();
- state[2] = disableDefaultMenuSet;
- return state;
- }
-
- @Override
- public void restoreState(FacesContext context, Object state) {
- Object[] states = (Object[]) state;
- super.restoreState(context, states[0]);
- disableDefaultMenu = (Boolean) states[1];
- disableDefaultMenuSet = (Boolean) states[2];
- }
}
15 years, 7 months
JBoss Rich Faces SVN: r14020 - trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2009-05-05 09:54:14 -0400 (Tue, 05 May 2009)
New Revision: 14020
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/CopyImageStuff.java
Log:
fix deploying on JBoss 5.0
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/CopyImageStuff.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/CopyImageStuff.java 2009-05-05 13:52:08 UTC (rev 14019)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/CopyImageStuff.java 2009-05-05 13:54:14 UTC (rev 14020)
@@ -3,7 +3,6 @@
*/
package org.richfaces.photoalbum.util;
-import static org.richfaces.photoalbum.service.Constants.IMAGE_FOLDER;
import static org.richfaces.photoalbum.service.Constants.PHOTOALBUM_FOLDER;
import static org.richfaces.photoalbum.service.Constants.TEMP_DIR;
import static org.richfaces.photoalbum.service.Constants.UPLOAD_FOLDER_PATH_ERROR;
@@ -70,8 +69,9 @@
final ServletContext servletContext = ServletLifecycle.getServletContext();
if (servletContext != null) {
- this.imageSrc = getClass().getClassLoader().getResource(IMAGE_FOLDER).getPath();
- }else {
+// this.imageSrc = getClass().getClassLoader().getResource(IMAGE_FOLDER).getPath();
+ this.imageSrc = ServletLifecycle.getServletContext().getRealPath("WEB-INF/classes/Upload");
+ } else {
throw new IllegalStateException(UPLOAD_FOLDER_PATH_ERROR);
}
15 years, 7 months
JBoss Rich Faces SVN: r14019 - in trunk/examples/photoalbum/source/web/src/main: java/org/richfaces/photoalbum/search and 8 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-05-05 09:52:08 -0400 (Tue, 05 May 2009)
New Revision: 14019
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/DnDManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileUploadManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/SlideshowManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/UserManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ISearchOption.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ImageSearchHelper.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByAlbum.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByImage.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByShelf.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByTag.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByUser.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/CopyImageStuff.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/FileUtils.java
trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties
trunk/examples/photoalbum/source/web/src/main/webapp/includes/album/albumInfo.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForAlbum.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForImage.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForShelf.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForUser.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageEditInfo.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/index/tree.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/search.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/shelf/shelfInfo.xhtml
Log:
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -115,7 +115,7 @@
}
/**
- * Method, that invoked when user click 'Edit album' button. Only registered users can create new albums.
+ * Method, that invoked when user click 'Edit album' button. Only registered users can edit albums.
* @param album - edited album
*
*/
@@ -132,7 +132,7 @@
}
/**
- * Method, that invoked when user click 'Delete album' button. Only registered users can create new albums.
+ * Method, that invoked when user click 'Delete album' button. Only registered users can delete albums.
* @param album - album to delete
*
*/
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Authenticator.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -22,7 +22,6 @@
import java.io.File;
import java.io.Serializable;
-import java.security.MessageDigest;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
@@ -39,7 +38,6 @@
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.security.Credentials;
import org.jboss.seam.security.Identity;
-import org.jboss.seam.util.Hex;
import org.richfaces.photoalbum.domain.User;
import org.richfaces.photoalbum.service.Constants;
import org.richfaces.photoalbum.service.IUserAction;
@@ -77,8 +75,7 @@
} catch (LoginException e) {
setLoginFailed(true);
credentials.clear();
- identity.login();
- identity.addRole(Constants.GUEST_ROLE);
+ loginAnonymous();
facesMessages.clear();
facesMessages.add(Constants.INVALID_LOGIN_OR_PASSWORD);
FacesContext.getCurrentInstance().renderResponse();
@@ -145,9 +142,7 @@
public boolean authenticate()
{
if (wantLoginAnonymous()) {
- identity.addRole(Constants.GUEST_ROLE);
- Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.ANONYM);
- return true;
+ return loginAnonymous();
}
try {
User user = userAction.login(credentials.getUsername(), HashUtils.hash(credentials.getPassword()));
@@ -164,6 +159,12 @@
return false;
}
+ private boolean loginAnonymous() {
+ identity.addRole(Constants.GUEST_ROLE);
+ Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.ANONYM);
+ return true;
+ }
+
public String logout(){
identity.logout();
return Constants.LOGOUT_OUTCOME;
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/DnDManager.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/DnDManager.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/DnDManager.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -19,7 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.richfaces.photoalbum.manager;
-
+/**
+ * Class encapsulated all functionality, related to drag'n'drop process.
+ *
+ * @author Andrey Markhel
+ */
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -47,18 +51,25 @@
@In IAlbumAction albumAction;
+ /**
+ * Listenet, that invoked during drag'n'drop process. Only registered users can drag images.
+ *
+ * @param event - event, indicated that drag'n'drop started
+ */
@Restrict("#{s:hasRole('admin')}")
public void processDrop(DropEvent dropEvent) {
Dropzone dropzone = (Dropzone) dropEvent.getComponent();
Object dragValue = dropEvent.getDragValue();
Object dropValue = dropzone.getDropValue();
if(dragValue instanceof Image){
- if(!((Album)dropValue).getOwner().getLogin().equals(user.getLogin())){
- Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.DND_PHOTO_ERROR);
- return;
- }
- handleImage((Image)dragValue, (Album)dropValue);
+ //If user drag image
+ if(!((Album)dropValue).getOwner().getLogin().equals(user.getLogin())){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.DND_PHOTO_ERROR);
+ return;
+ }
+ handleImage((Image)dragValue, (Album)dropValue);
}else if(dragValue instanceof Album){
+ //If user drag album
if(!((Shelf)dropValue).getOwner().getLogin().equals(user.getLogin())){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.DND_ALBUM_ERROR);
return;
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileUploadManager.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileUploadManager.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/FileUploadManager.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -67,11 +67,18 @@
@In private FileManager fileManager;
+ /**
+ * Listenet, that invoked during file upload process. Only registered users can upload images.
+ *
+ * @param event - event, indicated that file upload started
+ */
@Restrict("#{s:hasRole('admin')}")
public void listener(UploadEvent event) throws Exception {
UploadItem item = event.getUploadItem();
+ //Construct image from item
Image image = constructImage(item);
try {
+ //Extract metadata(size, camera model etc..)
extractMetadata(item, image);
} catch (Exception e1) {
addError(item, image, Constants.FILE_PROCESSING_ERROR);
@@ -83,20 +90,26 @@
return;
}
try{
+ //Check if image with given name already exist
if(imageAction.isImageWithThisPathExist(image)){
+ //If exist generate new path for image
image.setPath(generateNewPath(image.getPath()));
}
+ //Save to database
imageAction.addImage(image);
}catch(Exception e){
addError(item, image, Constants.IMAGE_SAVING_ERROR);
return;
}
+ //Save to disk
if(!fileManager.addImage(image.getFullPath(), item.getFile().getPath())){
addError(item, image, Constants.FILE_SAVE_ERROR);
return;
}
+ //Prepare to show in UI
fileWrapper.getFiles().add(image);
Events.instance().raiseEvent(Constants.IMAGE_ADDED_EVENT, image);
+ //Delete temporary fule
item.getFile().delete();
}
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -57,7 +57,7 @@
@In User user;
/**
- * Method, that invoked when user click 'Delete image' button. Only registered users can create new albums.
+ * Method, that invoked when user click 'Delete image' button. Only registered users can delete images.
* @param image - image to delete
*
*/
@@ -75,7 +75,7 @@
}
/**
- * Method, that invoked when user click 'Edit image' button. Only registered users can create new albums.
+ * Method, that invoked when user click 'Edit image' button. Only registered users can edit images.
* @param image - image to edit
*
*/
@@ -91,7 +91,7 @@
}
/**
- * Method, that invoked when user add comment to image. Only registered users can create new albums.
+ * Method, that invoked when user add comment to image. Only registered users can add comments to image.
* @param image - image
* @param message - comment text
*
@@ -121,7 +121,7 @@
}
/**
- * Method, that invoked when user delete comment. Only registered users can create new albums.
+ * Method, that invoked when user delete comment. Only registered users can delete comments.
* @param comment - comment to delete
*
*/
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -57,7 +57,7 @@
@In User user;
/**
- * Method, that invoked when user want to create new shelf. Only registered users can create new albums.
+ * Method, that invoked when user want to create new shelf. Only registered users can create new shelves.
*
*/
@Restrict("#{s:hasRole('admin')}")
@@ -67,7 +67,7 @@
}
/**
- * Method, that invoked on creation of the new shelf. Only registered users can create new albums.
+ * Method, that invoked on creation of the new shelf. Only registered users can create new shelves.
* @param album - new album
*
*/
@@ -88,7 +88,7 @@
}
/**
- * Method, that invoked when user click 'Edit shelf' button. Only registered users can create new albums.
+ * Method, that invoked when user click 'Edit shelf' button. Only registered users can edit shelves.
* @param shelf - shelf to edit
*
*/
@@ -104,7 +104,7 @@
}
/**
- * Method, that invoked when user click 'Delete shelf' button. Only registered users can create new albums.
+ * Method, that invoked when user click 'Delete shelf' button. Only registered users can delete shelves.
* @param image - shelf to delete
*
*/
@@ -123,7 +123,7 @@
/**
* This method used to populate 'pre-defined shelves' tree
*
- * @return List of predefined shelfs
+ * @return List of predefined shelves
*
*/
public List<Shelf> getPredefinedShelves() {
@@ -136,7 +136,7 @@
/**
* This method used to populate 'my shelves' tree
*
- * @return List of users shelfs
+ * @return List of users shelves
*
*/
public List<Shelf> getUserShelves(){
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/SlideshowManager.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/SlideshowManager.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/SlideshowManager.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -19,7 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.richfaces.photoalbum.manager;
-
+/**
+ * Class encapsulated all functionality, related to working with slideshow.
+ *
+ * @author Andrey Markhel
+ */
import java.io.Serializable;
import org.jboss.seam.ScopeType;
@@ -64,6 +68,10 @@
this.active = active;
}
+ /**
+ * This method invoked after user click on 'Start slideshow' button and no image is selected. After execution of this method slideshow will be activated.
+ *
+ */
public void startSlideshow(){
active = true;
this.slideshowIndex = 0;
@@ -73,7 +81,9 @@
return;
}
this.selectedImage = model.getImages().get(this.slideshowIndex);
+ //mark image as 'visited'
this.selectedImage.setVisited(true);
+ //Check if that image was recently deleted. If yes, immediately stop slideshow
FileManager fileManager = (FileManager)Contexts.getApplicationContext().get(Constants.FILE_MANAGER_COMPONENT);
if(!fileManager.isFilePresent(this.selectedImage.getFullPath())){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.IMAGE_RECENTLY_DELETED_ERROR);
@@ -83,6 +93,11 @@
}
}
+ /**
+ * This method invoked after user click on 'Start slideshow' button. After execution of this method slideshow will be activated starting from selected image.
+ *
+ *@param selectedImage - first image to show during slideshow
+ */
public void startSlideshow(Image selectedImage){
active = true;
if(model.getImages() == null || model.getImages().size() < 1){
@@ -92,7 +107,9 @@
}
this.slideshowIndex = model.getImages().indexOf(selectedImage);
this.selectedImage = selectedImage;
+ //mark image as 'visited'
this.selectedImage.setVisited(true);
+ //Check if that image was recently deleted. If yes, immediately stop slideshow
FileManager fileManager = (FileManager)Contexts.getApplicationContext().get(Constants.FILE_MANAGER_COMPONENT);
if(!fileManager.isFilePresent(this.selectedImage.getFullPath())){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.IMAGE_RECENTLY_DELETED_ERROR);
@@ -102,6 +119,10 @@
}
}
+ /**
+ * This method invoked after user click on 'Stop slideshow' button. After execution of this method slideshow will be de-activated.
+ *
+ */
@Observer(Constants.STOP_SLIDESHOW_EVENT)
public void stopSlideshow(){
active = false;
@@ -125,16 +146,23 @@
this.selectedImage = selectedImage;
}
+ /**
+ * This method used to prepare next image to show during slideshow
+ *
+ */
public void showNextImage(){
if(!active){
return;
}
+ //reset index if we reached last image
if(slideshowIndex == model.getImages().size() - 1){
slideshowIndex = -1;
}
slideshowIndex++;
selectedImage = model.getImages().get(slideshowIndex);
+ //mark image as 'visited'
this.selectedImage.setVisited(true);
+ //Check if that image was recently deleted. If yes, stopping slideshow
FileManager fileManager = (FileManager)Contexts.getApplicationContext().get(Constants.FILE_MANAGER_COMPONENT);
if(!fileManager.isFilePresent(this.selectedImage.getFullPath())){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.IMAGE_RECENTLY_DELETED_ERROR);
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/UserManager.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/UserManager.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/UserManager.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -19,7 +19,11 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
package org.richfaces.photoalbum.manager;
-
+/**
+ * Class encapsulated all functionality, related to working with user.
+ *
+ * @author Andrey Markhel
+ */
import java.io.File;
import java.io.Serializable;
@@ -51,8 +55,13 @@
@In IUserAction userAction;
+ /**
+ * Method, that invoked when user want to edit her profile.
+ *
+ */
@Observer(Constants.EDIT_USER_EVENT)
public void editUser(){
+ //If new avatar was uploaded
if (avatarData != null) {
if(!fileManager.saveAvatar(avatarData, user)){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.FILE_IO_ERROR);
@@ -71,6 +80,10 @@
}
}
+ /**
+ * Method, that invoked when user click 'Cancel' button during edit her profile.
+ *
+ */
@Observer(Constants.CANCEL_EDIT_USER_EVENT)
public void cancelEditUser() {
avatarData = null;
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ISearchOption.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ISearchOption.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ISearchOption.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -8,21 +8,37 @@
import org.richfaces.photoalbum.service.ISearchAction;
/**
+ * Abstract class, that represent base functionality for particular search option(album, shelf, etc..)
* @author Andrey Markavtsov
*
*/
public abstract class ISearchOption {
- private static final String TEMPLATE = "/includes/search/result/albumsResult.xhtml";
-
private boolean selected = true;
private List<?> searchResult;
-
+ /**
+ * Abstract method, that return name of particular search option. This name used in UI as header of rich:tab. Must be implemented in sub-classes
+ *
+ * @return name
+ */
public abstract String getName();
+ /**
+ * Abstract method, that return description of particular search option. This description used in UI as header of page with search result. Must be implemented in sub-classes
+ *
+ * @return description of search option
+ */
public abstract String getSearchResultName();
+ /**
+ * Abstract method, that perform search in given option. Must be implemented in sub-classes
+ *
+ * @param action - action will be performed
+ * @param searchQuery - query to search
+ * @param searchInMyAlbums - is search in users albums will be performed
+ * @param searchInShared - is search in shared albums will be performed
+ */
public abstract void search(ISearchAction action, String searchQuery, boolean searchInMyAlbums, boolean searchInShared);
public boolean getSelected() {
@@ -38,9 +54,12 @@
return getName();
}
- public String getSearchResultTemplate() {
- return TEMPLATE;
- }
+ /**
+ * Abstract method, that return template to render of particular search option. Must be implemented in sub-classes
+ *
+ * @return template to render
+ */
+ public abstract String getSearchResultTemplate();
public List<?> getSearchResult() {
return searchResult;
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ImageSearchHelper.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ImageSearchHelper.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/ImageSearchHelper.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -15,7 +15,11 @@
import org.richfaces.photoalbum.manager.NavigationEnum;
import org.richfaces.photoalbum.service.Constants;
import org.richfaces.photoalbum.service.ISearchAction;
-
+/**
+ * Class, that encapsulate functionality related to search process.
+ * @author Andrey Markavtsov
+ *
+ */
@Name("searchImageHelper")
@Scope(ScopeType.CONVERSATION)
@AutoCreate
@@ -41,6 +45,10 @@
boolean searchInShared = true;
+ /**
+ * Default constructor. During instantiation populate in field options all possible search options
+ *
+ */
public ImageSearchHelper() {
options = new ArrayList<ISearchOption>();
options.add(new SearchOptionByShelf());
@@ -50,6 +58,9 @@
options.add(new SearchOptionByTag());
}
+ /**
+ * Method, used to construct criteria string, to represent this string in UI.
+ */
public String getCriteriaString(){
StringBuilder s = new StringBuilder();
for(ISearchOption option:options) {
@@ -63,19 +74,27 @@
return s.toString();
}
+ /**
+ * Method, that perform search, when user clicks by 'Find' button.
+ */
public void search() {
if(!isSearchOptionSelected()){
+ //If no options selected
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.SEARCH_NO_OPTIONS_ERROR);
return;
}
if(!isWhereSearchOptionSelected()){
+ //If both search in My and search is shared unselected
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.SEARCH_NO_WHERE_OPTIONS_ERROR);
return;
}
keywords = new ArrayList<String>();
+ //Update view
Events.instance().raiseEvent(Constants.UPDATE_MAIN_AREA_EVENT, NavigationEnum.SEARCH);
+ // parse query
keywords = parse(searchQuery);
Iterator<ISearchOption> it = options.iterator();
+ //Search by first keyword by default
selectedKeyword = keywords.get(0).trim();
while (it.hasNext()) {
ISearchOption option = it.next();
@@ -84,11 +103,11 @@
}
}
}
-
- private boolean isWhereSearchOptionSelected() {
- return seachInMyAlbums || searchInShared;
- }
+ /**
+ * Method, that perform search by particular phrase
+ * @param keyword - keyword to search
+ */
public void search(String keyword) {
if(!isSearchOptionSelected()){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.SEARCH_NO_OPTIONS_ERROR);
@@ -104,25 +123,9 @@
}
}
- private List<String> parse(String searchQuery2) {
- return Arrays.asList(searchQuery2.split(Constants.COMMA));
- }
-
- boolean isOptionSelected() {
- return selectedOption != null;
- }
-
- private boolean isSearchOptionSelected() {
- boolean isOptionSelected = false;
- for(ISearchOption i : options){
- if(i.getSelected()){
- isOptionSelected = true;
- break;
- }
- }
- return isOptionSelected;
- }
-
+ /**
+ * Method, invoked when user select or unselect search option.
+ */
public void processSelection() {
Iterator<ISearchOption> it = options.iterator();
while (it.hasNext()) {
@@ -189,4 +192,36 @@
public void setSelectedKeyword(String selectedKeyword) {
this.selectedKeyword = selectedKeyword;
}
+
+ public boolean isResultExist(){
+ for(ISearchOption option : options){
+ if(option.getSelected() && option.getSearchResult().size() > 0){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private List<String> parse(String searchQuery2) {
+ return Arrays.asList(searchQuery2.split(Constants.COMMA));
+ }
+
+ private boolean isWhereSearchOptionSelected() {
+ return seachInMyAlbums || searchInShared;
+ }
+
+ boolean isOptionSelected() {
+ return selectedOption != null;
+ }
+
+ private boolean isSearchOptionSelected() {
+ boolean isOptionSelected = false;
+ for(ISearchOption i : options){
+ if(i.getSelected()){
+ isOptionSelected = true;
+ break;
+ }
+ }
+ return isOptionSelected;
+ }
}
\ No newline at end of file
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByAlbum.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByAlbum.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByAlbum.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -1,31 +1,40 @@
package org.richfaces.photoalbum.search;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.richfaces.photoalbum.domain.Album;
import org.richfaces.photoalbum.service.ISearchAction;
-
-
+/**
+ * Class, that encapsulate functionality related to search by album entity.
+ * @author Andrey Markavtsov
+ *
+ */
public class SearchOptionByAlbum extends ISearchOption {
private static final String TEMPLATE = "/includes/search/result/albumsResult.xhtml";
private static final String ALBUMS_SEARCH_RESULT = "Albums search result";
private static final String ALBUMS = "Albums";
- Map<String, Object> params = new HashMap<String, Object>();
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#getName()
+ */
@Override
public String getName() {
return ALBUMS;
}
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#getSearchResultName()
+ */
@Override
public String getSearchResultName() {
return ALBUMS_SEARCH_RESULT;
}
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#search()
+ */
@Override
public void search(ISearchAction action, String q, boolean searchInMyAlbums, boolean searchInShared) {
List<Album> searchByAlbum = action.searchByAlbum(q, searchInMyAlbums, searchInShared);
@@ -36,16 +45,11 @@
}
}
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#getSearchResultTemplate()
+ */
@Override
public String getSearchResultTemplate() {
return TEMPLATE;
}
-
- public Map<String, Object> getParams() {
- return params;
- }
-
- public void setParams(Map<String, Object> params) {
- this.params = params;
- }
}
\ No newline at end of file
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByImage.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByImage.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByImage.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -4,14 +4,13 @@
package org.richfaces.photoalbum.search;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import org.richfaces.photoalbum.domain.Image;
import org.richfaces.photoalbum.service.ISearchAction;
/**
+ * Class, that encapsulate functionality related to search by image entity.
* @author Andrey Markavtsov
*
*/
@@ -20,7 +19,6 @@
private static final String TEMPLATE = "/includes/search/result/imageResult.xhtml";
private static final String IMAGES_SEARCH_RESULT = "Images search result";
private static final String IMAGES = "Images";
- Map<String, Object> params = new HashMap<String, Object>();
/* (non-Javadoc)
* @see org.richfaces.photoalbum.search.ISearchOption#getName()
@@ -29,11 +27,17 @@
return IMAGES;
}
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#getSearchResultName()
+ */
@Override
public String getSearchResultName() {
return IMAGES_SEARCH_RESULT;
}
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#search()
+ */
@Override
public void search(ISearchAction action, String q, boolean searchInMyAlbums, boolean searchInShared) {
List<Image> searchByImage = action.searchByImage(q, searchInMyAlbums, searchInShared);
@@ -44,16 +48,11 @@
}
}
+ /* (non-Javadoc)
+ * @see org.richfaces.photoalbum.search.ISearchOption#getSearchResultTemplate()
+ */
@Override
public String getSearchResultTemplate() {
return TEMPLATE;
}
-
- public Map<String, Object> getParams() {
- return params;
- }
-
- public void setParams(Map<String, Object> params) {
- this.params = params;
- }
}
\ No newline at end of file
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByShelf.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByShelf.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByShelf.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -10,7 +10,8 @@
import org.richfaces.photoalbum.service.ISearchAction;
/**
- * @author Andrey
+ * Class, that encapsulate functionality related to search by shelf entity.
+ * @author Andrey Markavtsov
*
*/
public class SearchOptionByShelf extends ISearchOption {
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByTag.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByTag.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByTag.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -10,7 +10,8 @@
import org.richfaces.photoalbum.service.ISearchAction;
/**
- * @author Andrey
+ * Class, that encapsulate functionality related to search by metatag entity.
+ * @author Andrey Markavtsov
*
*/
public class SearchOptionByTag extends ISearchOption {
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByUser.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByUser.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/search/SearchOptionByUser.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -10,6 +10,7 @@
import org.richfaces.photoalbum.service.ISearchAction;
/**
+ * Class, that encapsulate functionality related to search by user entity.
* @author Andrey Markavtsov
*
*/
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/CopyImageStuff.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/CopyImageStuff.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/CopyImageStuff.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -3,14 +3,6 @@
*/
package org.richfaces.photoalbum.util;
-import org.jboss.seam.ScopeType;
-import org.jboss.seam.annotations.Create;
-import org.jboss.seam.annotations.Destroy;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.Out;
-import org.jboss.seam.annotations.Scope;
-import org.jboss.seam.annotations.Startup;
-import org.jboss.seam.contexts.ServletLifecycle;
import static org.richfaces.photoalbum.service.Constants.IMAGE_FOLDER;
import static org.richfaces.photoalbum.service.Constants.PHOTOALBUM_FOLDER;
import static org.richfaces.photoalbum.service.Constants.TEMP_DIR;
@@ -19,13 +11,24 @@
import static org.richfaces.photoalbum.util.FileUtils.deleteDirectory;
import static org.richfaces.photoalbum.util.FileUtils.joinFiles;
-import javax.servlet.ServletContext;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
+import javax.servlet.ServletContext;
+import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.Create;
+import org.jboss.seam.annotations.Destroy;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Out;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.annotations.Startup;
+import org.jboss.seam.contexts.ServletLifecycle;
+
+
/**
+ * Utility class, that perform copying images from ear file to temp folder at startup application
* @author Andrey Markavtsov
*
*/
@@ -43,14 +46,21 @@
private String imageSrc;
+ /**
+ * Method, that perform copying images from ear file to temp folder at startup application
+ *
+ */
@Create
public void create() throws IOException {
resolveImageFolder();
resolveUploadRoot();
-
copyImages();
}
+ /**
+ * Method, that perform deleting images from temp folder during destroy application
+ *
+ */
@Destroy
public void destroy()throws IOException {
deleteDirectory(uploadRoot, true);
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/FileUtils.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/FileUtils.java 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/util/FileUtils.java 2009-05-05 13:52:08 UTC (rev 14019)
@@ -12,6 +12,11 @@
import javax.imageio.ImageWriter;
import javax.imageio.stream.ImageInputStream;
+/**
+ * Utility class for operations with file-system
+ *
+ */
+
public class FileUtils {
private static final String JPEG = "jpeg";
@@ -20,6 +25,10 @@
private static final boolean CLOCK = true;
private static final boolean VERIFY = true;
+ /**
+ * Utility method for copying file
+ *
+ */
public static void copyFile(File srcFile, File destFile) throws IOException {
if (!srcFile.getPath().toLowerCase().endsWith(JPG) && !srcFile.getPath().toLowerCase().endsWith(JPEG)) {
return;
@@ -54,6 +63,10 @@
}
}
+ /**
+ * Utility method for copying directory
+ *
+ */
public static void copyDirectory(File srcDir, File dstDir)
throws IOException {
@@ -74,6 +87,10 @@
}
}
+ /**
+ * Utility method for delete directory
+ *
+ */
public static boolean deleteDirectory(File dir , boolean isInitialDelete){
if (dir.isDirectory()) {
if (dir.exists()) {
@@ -100,6 +117,10 @@
return true;
}
+ /**
+ * Utility method for concatenation names of collection of files
+ *
+ */
public static String joinFiles(String... files) {
final StringBuilder res = new StringBuilder();
for (String file : files) {
@@ -109,7 +130,10 @@
return res.substring(0, res.length() - 1);
}
-
+ /**
+ * Utility method for delete file
+ *
+ */
public static void deleteFile(File file) {
if (file.exists()) {
file.delete();
@@ -207,6 +231,10 @@
return ret;
}
+ /**
+ * Utility method for creation of directory
+ *
+ */
public static void addDirectory(File directory) {
if (directory.exists()) {
deleteDirectory(directory, false);
Modified: trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties 2009-05-05 12:18:44 UTC (rev 14018)
+++ trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties 2009-05-05 13:52:08 UTC (rev 14019)
@@ -105,6 +105,7 @@
confirm.ok=OK
confirm.cancel=Cancel
shelf.edit=Edit shelf properties
+shelf.view=View shelf
shelf.delete=Delete shelf
album.edit=Edit album properties
album.delete=Delete album
@@ -221,7 +222,7 @@
created.image=Captured
contain=contain
pics_into=images into
-new=new
+new= new
shelf.albums=albums
images_=images
tags=Tags
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/album/albumInfo.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForAlbum.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForImage.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForShelf.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/contextMenu/CMForUser.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageEditInfo.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/index/tree.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/search.xhtml
===================================================================
(Binary files differ)
Modified: trunk/examples/photoalbum/source/web/src/main/webapp/includes/shelf/shelfInfo.xhtml
===================================================================
(Binary files differ)
15 years, 7 months
JBoss Rich Faces SVN: r14018 - Reports/3.3.1 and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: tkuprevich
Date: 2009-05-05 08:18:44 -0400 (Tue, 05 May 2009)
New Revision: 14018
Added:
trunk/test-applications/qa/Test Reports/3.3.1/RFTestReport3.3.1.CR2.xls
Modified:
trunk/test-applications/qa/Test Reports/3.3.1/RFTestReport3.3.1.CR1.xls
Log:
Modified: trunk/test-applications/qa/Test Reports/3.3.1/RFTestReport3.3.1.CR1.xls
===================================================================
(Binary files differ)
Added: trunk/test-applications/qa/Test Reports/3.3.1/RFTestReport3.3.1.CR2.xls
===================================================================
(Binary files differ)
Property changes on: trunk/test-applications/qa/Test Reports/3.3.1/RFTestReport3.3.1.CR2.xls
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
15 years, 7 months
JBoss Rich Faces SVN: r14017 - in trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum: service and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-05-05 04:19:53 -0400 (Tue, 05 May 2009)
New Revision: 14017
Modified:
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java
trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java
Log:
Fix RF-7008
Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java 2009-05-05 08:19:49 UTC (rev 14016)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/domain/User.java 2009-05-05 08:19:53 UTC (rev 14017)
@@ -371,4 +371,22 @@
result = 31 * result + (login != null ? login.hashCode() : 0);
return result;
}
+
+ public boolean hasShelfWithName(String name) {
+ for(Shelf s : getShelves()){
+ if(s.getName().equals(name)){
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public boolean hasAlbumWithName(String name) {
+ for(Album a : getAlbums()){
+ if(a.getName().equals(name)){
+ return true;
+ }
+ }
+ return false;
+ }
}
\ No newline at end of file
Modified: trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java
===================================================================
--- trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java 2009-05-05 08:19:49 UTC (rev 14016)
+++ trunk/examples/photoalbum/source/ejb/src/main/java/org/richfaces/photoalbum/service/Constants.java 2009-05-05 08:19:53 UTC (rev 14017)
@@ -53,6 +53,8 @@
public static final String USER_DELETED_EVENT = "userDeletedEvent";
//Errors(Internationalization pending)
+ public static final String SAME_ALBUM_EXIST_ERROR = "You already have album with given name.";
+ public static final String SAME_SHELF_EXIST_ERROR = "You already have shelf with given name.";
public static final String AVATAR_SAVING_ERROR = "Error while saving avatar to disk";
public static final String YOU_CAN_T_ADD_IMAGES_TO_THAT_ALBUM_ERROR = "You can't add images to that album";
public static final String SHELF_RECENTLY_DELETED_ERROR = "This shelf was recently deleted. Refresh your browser to see actual data.";
15 years, 7 months
JBoss Rich Faces SVN: r14016 - trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager.
by richfaces-svn-commits@lists.jboss.org
Author: amarkhel
Date: 2009-05-05 04:19:49 -0400 (Tue, 05 May 2009)
New Revision: 14016
Modified:
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java
Log:
Fix RF-7008
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java 2009-05-05 00:24:43 UTC (rev 14015)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java 2009-05-05 08:19:49 UTC (rev 14016)
@@ -71,6 +71,11 @@
Contexts.getConversationContext().set(Constants.ALBUM_VARIABLE, album);
return;
}
+ //Album name must be unique in shelf
+ if(user.hasAlbumWithName(album.getName())){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.SAME_ALBUM_EXIST_ERROR);
+ return;
+ }
//All data is valid
validationSuccess = true;
try{
Modified: trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java
===================================================================
--- trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java 2009-05-05 00:24:43 UTC (rev 14015)
+++ trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java 2009-05-05 08:19:49 UTC (rev 14016)
@@ -73,6 +73,10 @@
*/
@Restrict("#{s:hasRole('admin')}")
public void addShelf(Shelf shelf) {
+ if(user.hasShelfWithName(shelf.getName())){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, Constants.SAME_SHELF_EXIST_ERROR);
+ return;
+ }
validationSuccess = true;
try{
shelfAction.addShelf(shelf);
15 years, 7 months
JBoss Rich Faces SVN: r14015 - in trunk: samples/layout-sample/src/main/webapp/pages and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2009-05-04 20:24:43 -0400 (Mon, 04 May 2009)
New Revision: 14015
Added:
trunk/samples/layout-sample/src/main/webapp/pages/RF-6641.xhtml
trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutPanelRenderer.java
Modified:
trunk/samples/layout-sample/src/main/java/org/richfaces/samples/LayoutBean.java
trunk/samples/layout-sample/src/main/webapp/pages/layout.xhtml
trunk/ui/layout/src/main/config/component/layoutPanel.xml
trunk/ui/layout/src/main/java/org/richfaces/component/UILayoutPanel.java
trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutRenderer.java
trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler.java
trunk/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx
trunk/ui/layout/src/main/templates/org/richfaces/htmlLayoutPanel.jspx
Log:
Start moving layout panels from CSS to style attributes.
Modified: trunk/samples/layout-sample/src/main/java/org/richfaces/samples/LayoutBean.java
===================================================================
--- trunk/samples/layout-sample/src/main/java/org/richfaces/samples/LayoutBean.java 2009-05-04 22:02:51 UTC (rev 14014)
+++ trunk/samples/layout-sample/src/main/java/org/richfaces/samples/LayoutBean.java 2009-05-05 00:24:43 UTC (rev 14015)
@@ -22,7 +22,7 @@
private boolean rendered = true;
- private String width;
+ private float width;
/**
* @return the rendered
@@ -41,14 +41,14 @@
/**
* @return the width
*/
- public String getWidth() {
+ public float getWidth() {
return width;
}
/**
* @param width the width to set
*/
- public void setWidth(String width) {
+ public void setWidth(float width) {
this.width = width;
}
Added: trunk/samples/layout-sample/src/main/webapp/pages/RF-6641.xhtml
===================================================================
--- trunk/samples/layout-sample/src/main/webapp/pages/RF-6641.xhtml (rev 0)
+++ trunk/samples/layout-sample/src/main/webapp/pages/RF-6641.xhtml 2009-05-05 00:24:43 UTC (rev 14015)
@@ -0,0 +1,40 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:ui="http://java.sun.com/jsf/facelets"
+ xmlns:h="http://java.sun.com/jsf/html"
+ xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:rich="http://richfaces.org/rich"
+ xmlns:a4j="http://richfaces.org/a4j"
+ xmlns:c="http://java.sun.com/jsp/jstl/core">
+<body>
+<h:form>
+ <rich:layout>
+ <rich:layoutPanel position="left">
+
+ <rich:layout>
+
+ <rich:layoutPanel position="top">
+ <p>top</p>
+ </rich:layoutPanel>
+ <rich:layoutPanel position="center">
+ <p>center</p>
+ </rich:layoutPanel>
+ <rich:layoutPanel position="left">
+ <p>left</p>
+ </rich:layoutPanel>
+ <rich:layoutPanel position="right">
+ <p>right</p>
+ </rich:layoutPanel>
+ <rich:layoutPanel position="bottom">
+ <p>bottom</p>
+ </rich:layoutPanel>
+ </rich:layout>
+ </rich:layoutPanel>
+
+ <rich:layoutPanel position="center">
+ <p>center-right</p>
+ </rich:layoutPanel>
+ </rich:layout>
+</h:form>
+</body>
+</html>
\ No newline at end of file
Property changes on: trunk/samples/layout-sample/src/main/webapp/pages/RF-6641.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/samples/layout-sample/src/main/webapp/pages/layout.xhtml
===================================================================
--- trunk/samples/layout-sample/src/main/webapp/pages/layout.xhtml 2009-05-04 22:02:51 UTC (rev 14014)
+++ trunk/samples/layout-sample/src/main/webapp/pages/layout.xhtml 2009-05-05 00:24:43 UTC (rev 14015)
@@ -1,10 +1,10 @@
-<layout:page xmlns="http://www.w3.org/1999/xhtml"
+<rich:page xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
- xmlns:layout="http://richfaces.org/layout"
xmlns:c="http://java.sun.com/jsp/jstl/core"
+ xmlns:rich="http://richfaces.org/rich"
markupposition="xhtml"
contentposition="text/html"
theme="#{bean.theme}"
@@ -19,7 +19,8 @@
>
<f:facet name="pageHeader">
<style>
- .yui-u {text-align: center;}
+ .layout {text-align: center;border-width: 1px;border-color: red;border-style: solid;}
+ .layoutPanel {text-align: center;border-width: 1px;border-color: blue;margin: 0px;border-style: dotted;}
</style>
</f:facet>
<f:facet name="header">
@@ -53,12 +54,29 @@
<!-- body of the page -->
- <layout:layout>
- <layout:layoutPanel position="center">Center panel</layout:layoutPanel>
- <layout:layoutPanel position="left">Left</layout:layoutPanel>
- <layout:layoutPanel position="right">Right</layout:layoutPanel>
- <layout:layoutPanel position="top">Top</layout:layoutPanel>
- <layout:layoutPanel position="bottom">Bottom</layout:layoutPanel>
- </layout:layout>
+ <div class="layout" style="zoom: 1">
+ <div class="layoutPanel top" style="">Top</div>
+ <div class="layoutPanel left" style="float: left; width: 38%">Left
+ panel xxxx yyy zzz</div>
+ <div class="layoutPanel center" style="float: left; width: 35%">
+ <div class="layout" style="zoom: 1">
+ <div class="layoutPanel top" style="">Top</div>
+ <div class="layoutPanel left" style="float: left; width: 38%">Left
+ panel xxxx yyy zzz</div>
+ <div class="layoutPanel center" style="float: left; width: 35%">Center
+ panel dhisdf ncdl dcd</div>
+ <div class="layoutPanel right" style="float: right; width: 25%">Right
+ wersdupsdo; osajo;sca</div>
+ <div
+ style="display: block; height: 0; clear: both; visibility: hidden;">.</div>
+ <div class="layoutPanel bottom" style="">Bottom</div>
+ </div>
+ </div>
+ <div class="layoutPanel right" style="float: right; width: 25%">Right
+ wersdupsdo; osajo;sca</div>
+ <div
+ style="display: block; height: 0; clear: both; visibility: hidden;">.</div>
+ <div class="layoutPanel bottom" style="">Bottom</div>
+ </div>
-</layout:page>
\ No newline at end of file
+</rich:page>
\ No newline at end of file
Modified: trunk/ui/layout/src/main/config/component/layoutPanel.xml
===================================================================
--- trunk/ui/layout/src/main/config/component/layoutPanel.xml 2009-05-04 22:02:51 UTC (rev 14014)
+++ trunk/ui/layout/src/main/config/component/layoutPanel.xml 2009-05-05 00:24:43 UTC (rev 14015)
@@ -38,7 +38,7 @@
<property>
<name>width</name>
- <classname>java.lang.String</classname>
+ <classname>float</classname>
<description>Sets the width of the layout area
</description>
</property>
Modified: trunk/ui/layout/src/main/java/org/richfaces/component/UILayoutPanel.java
===================================================================
--- trunk/ui/layout/src/main/java/org/richfaces/component/UILayoutPanel.java 2009-05-04 22:02:51 UTC (rev 14014)
+++ trunk/ui/layout/src/main/java/org/richfaces/component/UILayoutPanel.java 2009-05-05 00:24:43 UTC (rev 14015)
@@ -33,13 +33,13 @@
* Get Panel width.
* @return
*/
- public abstract String getWidth();
+ public abstract float getWidth();
/**
* Set Panel width.
* @param newvalue
*/
- public abstract void setWidth(String newvalue);
+ public abstract void setWidth(float newvalue);
}
Added: trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutPanelRenderer.java
===================================================================
--- trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutPanelRenderer.java (rev 0)
+++ trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutPanelRenderer.java 2009-05-05 00:24:43 UTC (rev 14015)
@@ -0,0 +1,66 @@
+/**
+ *
+ */
+package org.richfaces.renderkit;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.ajax4jsf.renderkit.HeaderResourcesRendererBase;
+import org.ajax4jsf.renderkit.RendererUtils.HTML;
+import org.richfaces.component.LayoutPosition;
+import org.richfaces.component.UILayout;
+import org.richfaces.component.UILayoutPanel;
+
+/**
+ * @author asmirnov
+ *
+ */
+public abstract class AbstractLayoutPanelRenderer extends
+ HeaderResourcesRendererBase {
+
+ public String layoutStyle(FacesContext context, UILayoutPanel panel) {
+ StringBuilder style = new StringBuilder();
+ LayoutPosition position = panel.getPosition();
+ Object componentStyle = panel.getAttributes().get(HTML.style_ATTRIBUTE);
+ if(null != componentStyle){
+ style.append(componentStyle).append(";");
+ }
+ if(!LayoutPosition.top.equals(position)&&!LayoutPosition.bottom.equals(position)){
+ if(LayoutPosition.right.equals(position)){
+ style.append("float:right;");
+ } else {
+ style.append("float:left;");
+ }
+ // find siblings.
+ // get layout depth.
+ int deep = layoutDeep(panel);
+ // calculate real width.
+ float width = panel.getWidth();
+ if(width>=0.0f){
+ style.append("width:").append(width).append("%;");
+ width = width/(1.0f+(float)deep);
+ style.append("*width:").append(width).append("%;");
+ }
+ } else {
+ // top and buttom style.
+ }
+ return style.length()>0?style.toString():null;
+ }
+
+ /**
+ * Calculate deep of layout components.
+ * @param component
+ * @return
+ */
+ private int layoutDeep(UIComponent component) {
+ int deep = 0;
+ if(null != component){
+ deep = layoutDeep(component.getParent());
+ if(component instanceof UILayout){
+ deep++;
+ }
+ }
+ return deep;
+ }
+}
Property changes on: trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutPanelRenderer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutRenderer.java
===================================================================
--- trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutRenderer.java 2009-05-04 22:02:51 UTC (rev 14014)
+++ trunk/ui/layout/src/main/java/org/richfaces/renderkit/AbstractLayoutRenderer.java 2009-05-05 00:24:43 UTC (rev 14015)
@@ -4,6 +4,7 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.Map;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
@@ -86,90 +87,23 @@
}
if (columns > 0) {
// Reorder panels to fill ordeg left->center->right.
- if (null == left) {
- if (null == center) {
- left = right;
- right = null;
- } else {
- left = center;
- center = right;
- right = null;
- }
- } else if (null == center) {
- center = right;
- right = null;
- }
- if (columns > 1) {
- // Render Y! CSS Grid
- writer.startElement(HTML.DIV_ELEM, layout);
- // calculate class.
- String yahooClass = calculateLayoutClass(left, right, center);
- writer.writeAttribute(HTML.class_ATTRIBUTE, yahooClass, null);
- left.getAttributes().put("first", "first");
- center.getAttributes().remove("first");
+ if (null != left) {
left.encodeAll(context);
+ }
+ if (null != center) {
center.encodeAll(context);
- if (null != right) {
- right.getAttributes().remove("first");
- right.encodeAll(context);
- }
- writer.endElement(HTML.DIV_ELEM);
- } else {
- left.encodeAll(context);
- }
+ }
+ if (null != right) {
+ right.encodeAll(context);
+ }
}
+ // line separator.
+ writer.startElement(HTML.DIV_ELEM, layout);
+ writer.writeAttribute(HTML.style_ATTRIBUTE, "display: block; height: 0; clear: both; visibility: hidden;", null);
+ writer.writeText(".", null);
+ writer.endElement(HTML.DIV_ELEM);
if (null != bottom) {
renderChild(context, bottom);
}
}
-
- /**
- * @param left
- * @param right
- * @param center
- * @return
- */
- protected String calculateLayoutClass(UILayoutPanel left,
- UILayoutPanel right, UILayoutPanel center) {
- String yahooClass = "yui-g";
- if (null != left && null != right && null != center) {
- // We have only equal size for an three-column layout.
- yahooClass = "yui-gb";
- } else if(null != left && null != center){
- int leftPart = 0;
- String leftWidth = left.getWidth();
- if(!isEmpty(leftWidth)){
- leftPart = Integer.parseInt(leftWidth);
- }
- int rightPart = 0;
- String centerWidth = center.getWidth();
- if(!isEmpty(centerWidth)){
- rightPart = Integer.parseInt(centerWidth);
- if(0 ==leftPart && 0>rightPart && centerWidth.endsWith("%")){
- leftPart = 100 - rightPart;
- }
- }
- if(0 > leftPart && 0 == rightPart && leftWidth.endsWith("%")){
- rightPart = 100 - leftPart;
- }
- // Calculate properly class.
- if(0>leftPart && 0>rightPart){
- double ratio = (double)leftPart/(double)(leftPart+rightPart);
- if (ratio <= 0.25) {
- yahooClass = "yui-gf";
- } else if (ratio <= 0.33) {
- yahooClass = "yui-gd";
- } else if (ratio <= 0.66) {
- yahooClass = "yui-gc";
- } else {
- yahooClass = "yui-ge";
- }
- }
- }
- return yahooClass;
- }
-
- private boolean isEmpty(String leftWidth) {
- return null == leftWidth || leftWidth.length() == 0;
- }
}
Modified: trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler.java
===================================================================
--- trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler.java 2009-05-04 22:02:51 UTC (rev 14014)
+++ trunk/ui/layout/src/main/java/org/richfaces/taglib/PageTagHandler.java 2009-05-05 00:24:43 UTC (rev 14015)
@@ -45,10 +45,12 @@
if (this.contentType != null) {
String v = this.contentType.getValue(ctx);
ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.ContentType", v);
+ root.getAttributes().put("contentType", v);
}
if (this.encoding != null) {
String v = this.encoding.getValue(ctx);
ctx.getFacesContext().getExternalContext().getRequestMap().put("facelets.Encoding", v);
+ root.getAttributes().put("encoding", v);
}
}
}
Modified: trunk/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx
===================================================================
--- trunk/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx 2009-05-04 22:02:51 UTC (rev 14014)
+++ trunk/ui/layout/src/main/templates/org/richfaces/htmlLayout.jspx 2009-05-05 00:24:43 UTC (rev 14015)
@@ -11,11 +11,11 @@
baseclass="org.richfaces.renderkit.AbstractLayoutRenderer"
component="org.richfaces.component.UILayout"
>
- <h:styles>css/layout.css</h:styles>
+ <!-- h:styles>css/layout.css</h:styles-->
<f:clientid var="clientId"/>
<div id="#{clientId}"
- x:passThruWithExclusions="value,name,type,id"
- >
+ style="#{component.attributes['style']};zoom:1;"
+ x:passThruWithExclusions="value,name,type,id,style" >
<vcp:body>
<f:call name="renderLayout" />
</vcp:body>
Modified: trunk/ui/layout/src/main/templates/org/richfaces/htmlLayoutPanel.jspx
===================================================================
--- trunk/ui/layout/src/main/templates/org/richfaces/htmlLayoutPanel.jspx 2009-05-04 22:02:51 UTC (rev 14014)
+++ trunk/ui/layout/src/main/templates/org/richfaces/htmlLayoutPanel.jspx 2009-05-05 00:24:43 UTC (rev 14015)
@@ -8,13 +8,12 @@
xmlns:vcp=" http://jsf.exadel.com/vcp"
xmlns:x=" http://ajax4jsf.org/cdk/x"
class="org.richfaces.renderkit.html.LayoutPanelRenderer"
- baseclass="org.ajax4jsf.renderkit.AjaxComponentRendererBase"
+ baseclass="org.richfaces.renderkit.AbstractLayoutPanelRenderer"
component="org.richfaces.component.UILayoutPanel"
>
<f:clientid var="clientId"/>
- <c:set var="styleClass" value="#{component.attributes['styleClass']}"/>
- <div id="#{clientId}" class="yui-u #{component.attributes['first']} #{styleClass}"
- x:passThruWithExclusions="type,id, styleClass"
+ <div id="#{clientId}" x:style="#{this:layoutStyle(context,component)}"
+ x:passThruWithExclusions="type,id,style"
>
<vcp:body>
<f:call name="renderChildren" />
15 years, 8 months