Author: amarkhel
Date: 2009-05-08 12:41:25 -0400 (Fri, 08 May 2009)
New Revision: 14084
Modified:
trunk/examples/photoalbum/source/web/pom.xml
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/resources/messages_en.properties
trunk/examples/photoalbum/source/web/src/main/resources/org/richfaces/photoalbum/editor/advanced.properties
trunk/examples/photoalbum/source/web/src/main/webapp/includes/album/albumEditInfo.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/album/albumInfo.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageEditInfo.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageInfo.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageScroller.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/shelf/shelfEditInfo.xhtml
trunk/examples/photoalbum/source/web/src/main/webapp/includes/shelf/shelfInfo.xhtml
Log:
Modified: trunk/examples/photoalbum/source/web/pom.xml
===================================================================
--- trunk/examples/photoalbum/source/web/pom.xml 2009-05-08 16:41:10 UTC (rev 14083)
+++ trunk/examples/photoalbum/source/web/pom.xml 2009-05-08 16:41:25 UTC (rev 14084)
@@ -66,6 +66,12 @@
<scope>provided</scope>
</dependency>
<dependency>
+ <groupId>org.hibernate</groupId>
+ <artifactId>hibernate-commons-annotations</artifactId>
+ <version>3.3.0.ga</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>1.0</version>
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-08
16:41:10 UTC (rev 14083)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/AlbumManager.java 2009-05-08
16:41:25 UTC (rev 14084)
@@ -26,6 +26,8 @@
*/
import java.io.Serializable;
+import org.hibernate.validator.ClassValidator;
+import org.hibernate.validator.InvalidValue;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
@@ -72,7 +74,7 @@
return;
}
//Album name must be unique in shelf
- if(user.hasAlbumWithName(album.getName())){
+ if(user.hasAlbumWithName(album)){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.SAME_ALBUM_EXIST_ERROR);
return;
}
@@ -117,11 +119,31 @@
/**
* Method, that invoked when user click 'Edit album' button. Only registered
users can edit albums.
* @param album - edited album
- *
+ * @param editFromInplace - indicate whether edit process was initiated by inplaceInput
component
*/
@Restrict("#{s:hasRole('admin')}")
- public void editAlbum(Album album){
+ public void editAlbum(Album album, boolean editFromInplace){
try{
+ if(user.hasAlbumWithName(album)){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.SAME_ALBUM_EXIST_ERROR);
+ if(editFromInplace){
+ albumAction.resetAlbum(album);
+ }
+ return;
+ }
+ if(editFromInplace){
+ //We need validate album name manually
+ ClassValidator<Album> shelfValidator = new
ClassValidator<Album>(Album.class );
+ InvalidValue[] validationMessages = shelfValidator.getInvalidValues(album,
"name");
+ if(validationMessages.length > 0 ){
+ for(InvalidValue i : validationMessages){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, i.getMessage());
+ }
+ //If error occured we need refresh album to display correct value in
inplaceInput
+ albumAction.resetAlbum(album);
+ return;
+ }
+ }
albumAction.editAlbum(album);
}catch(Exception e){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.ALBUM_SAVING_ERROR);
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-08
16:41:10 UTC (rev 14083)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/Controller.java 2009-05-08
16:41:25 UTC (rev 14084)
@@ -97,6 +97,7 @@
}
public void showImage(Image image){
+ pushEvent(Constants.CLEAR_EDITOR_EVENT);
if(!canViewImage(image)){
pushEvent(Constants.ADD_ERROR_EVENT, Constants.HAVENT_ACCESS);
return;
@@ -280,6 +281,10 @@
return index / 5 + 1;
}
+ public void setPage(Integer page){
+
+ }
+
public boolean isUserImage(Image image){
if(image == null || image.getOwner() == null) {
return false;
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-08
16:41:10 UTC (rev 14083)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ImageManager.java 2009-05-08
16:41:25 UTC (rev 14084)
@@ -31,6 +31,8 @@
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
+import org.hibernate.validator.ClassValidator;
+import org.hibernate.validator.InvalidValue;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
@@ -41,6 +43,7 @@
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;
import org.richfaces.photoalbum.service.Constants;
import org.richfaces.photoalbum.service.IImageAction;
@@ -77,12 +80,32 @@
/**
* Method, that invoked when user click 'Edit image' button. Only registered
users can edit images.
* @param image - image to edit
- *
+ * @param editFromInplace - indicate whether edit process was initiated by inplaceInput
component
*/
@Restrict("#{s:hasRole('admin')}")
- public void editImage(Image image, boolean metatagsChanged) {
+ public void editImage(Image image, boolean editFromInplace) {
try{
- imageAction.editImage(image, metatagsChanged);
+ if(user.hasImageWithName(image)){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.SAME_IMAGE_EXIST_ERROR);
+ if(editFromInplace){
+ imageAction.resetImage(image);
+ }
+ return;
+ }
+ if(editFromInplace){
+ //We need validate image name manually
+ ClassValidator<Image> shelfValidator = new
ClassValidator<Image>(Image.class );
+ InvalidValue[] validationMessages = shelfValidator.getInvalidValues(image,
"name");
+ if(validationMessages.length > 0 ){
+ for(InvalidValue i : validationMessages){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, i.getMessage());
+ }
+ //If error occured we need refresh image to display correct value in
inplaceInput
+ imageAction.resetImage(image);
+ return;
+ }
+ }
+ imageAction.editImage(image, editFromInplace);
}catch(Exception e){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.IMAGE_SAVING_ERROR);
imageAction.resetImage(image);
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-08
16:41:10 UTC (rev 14083)
+++
trunk/examples/photoalbum/source/web/src/main/java/org/richfaces/photoalbum/manager/ShelfManager.java 2009-05-08
16:41:25 UTC (rev 14084)
@@ -28,6 +28,8 @@
import java.io.Serializable;
import java.util.List;
+import org.hibernate.validator.ClassValidator;
+import org.hibernate.validator.InvalidValue;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.AutoCreate;
import org.jboss.seam.annotations.In;
@@ -73,7 +75,7 @@
*/
@Restrict("#{s:hasRole('admin')}")
public void addShelf(Shelf shelf) {
- if(user.hasShelfWithName(shelf.getName())){
+ if(user.hasShelfWithName(shelf)){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.SAME_SHELF_EXIST_ERROR);
return;
}
@@ -88,13 +90,34 @@
}
/**
- * Method, that invoked when user click 'Edit shelf' button. Only registered
users can edit shelves.
+ * Method, that invoked when user click 'Edit shelf' button or by inplaceInput
component. Only registered users can edit shelves.
* @param shelf - shelf to edit
+ * @param editFromInplace - indicate whether edit process was initiated by inplaceInput
component
*
*/
@Restrict("#{s:hasRole('admin')}")
- public void editShelf(Shelf shelf) {
+ public void editShelf(Shelf shelf, boolean editFromInplace) {
try{
+ if(user.hasShelfWithName(shelf)){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.SAME_SHELF_EXIST_ERROR);
+ if(editFromInplace){
+ shelfAction.resetShelf(shelf);
+ }
+ return;
+ }
+ if(editFromInplace){
+ //We need validate shelf name manually
+ ClassValidator<Shelf> shelfValidator = new
ClassValidator<Shelf>(Shelf.class );
+ InvalidValue[] validationMessages = shelfValidator.getInvalidValues(shelf,
"name");
+ if(validationMessages.length > 0 ){
+ for(InvalidValue i : validationMessages){
+ Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT, i.getMessage());
+ }
+ //If error occured we need refresh shelf to display correct value in
inplaceInput
+ shelfAction.resetShelf(shelf);
+ return;
+ }
+ }
shelfAction.editShelf(shelf);
}catch(Exception e){
Events.instance().raiseEvent(Constants.ADD_ERROR_EVENT,
Constants.SHELF_SAVING_ERROR);
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-08
16:41:10 UTC (rev 14083)
+++
trunk/examples/photoalbum/source/web/src/main/resources/messages_en.properties 2009-05-08
16:41:25 UTC (rev 14084)
@@ -264,7 +264,7 @@
all_new_images=All new images
in_album=in album
public_shelves=Pre-defined Shelves
-all_images=All images
+all_images=All images
related_to_tag=related to tag
my_all_albums=My all albums
my_all_photos=My all images
Modified:
trunk/examples/photoalbum/source/web/src/main/resources/org/richfaces/photoalbum/editor/advanced.properties
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/resources/org/richfaces/photoalbum/editor/advanced.properties 2009-05-08
16:41:10 UTC (rev 14083)
+++
trunk/examples/photoalbum/source/web/src/main/resources/org/richfaces/photoalbum/editor/advanced.properties 2009-05-08
16:41:25 UTC (rev 14084)
@@ -1,7 +1,7 @@
theme="advanced"
-plugins="save,insertdatetime,paste"
+plugins="insertdatetime"
theme_advanced_buttons1 : "bold,italic,underline,strikethrough"
-theme_advanced_buttons2 :
"cut,copy,paste,pastetext,pasteword,separator,bullist,numlist,separator,undo,redo,separator,cleanup,help,code,separator,insertdate,inserttime,separator,forecolor,backcolor"
+theme_advanced_buttons2 :
"bullist,numlist,separator,undo,redo,separator,cleanup,help,code,separator,insertdate,inserttime,separator,forecolor,backcolor"
theme_advanced_buttons3 : "hr,sub,sup"
theme_advanced_toolbar_location : "top"
theme_advanced_toolbar_align : "left"
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/album/albumEditInfo.xhtml
===================================================================
(Binary files differ)
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/image/imageEditInfo.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageInfo.xhtml
===================================================================
(Binary files differ)
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageScroller.xhtml
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageScroller.xhtml 2009-05-08
16:41:10 UTC (rev 14083)
+++
trunk/examples/photoalbum/source/web/src/main/webapp/includes/image/imageScroller.xhtml 2009-05-08
16:41:25 UTC (rev 14084)
@@ -34,7 +34,7 @@
</a4j:outputPanel>
</a4j:repeat>
- <rich:datascroller page="#{controller.getPage()}"
styleClass="image-scroller" lastPageMode="full"
+ <rich:datascroller page="#{controller.page}"
styleClass="image-scroller" lastPageMode="full"
for="repeat" reRender="imagesTable"
boundaryControls="hide"
stepControls="hide">
<f:facet name="pages">
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/shelf/shelfEditInfo.xhtml
===================================================================
---
trunk/examples/photoalbum/source/web/src/main/webapp/includes/shelf/shelfEditInfo.xhtml 2009-05-08
16:41:10 UTC (rev 14083)
+++
trunk/examples/photoalbum/source/web/src/main/webapp/includes/shelf/shelfEditInfo.xhtml 2009-05-08
16:41:25 UTC (rev 14084)
@@ -76,7 +76,7 @@
<td valign="top">
</td>
<td valign="top" align="right" colspan="2"
style="padding : 10px;">
- <richx:commandButton id="saveButton" style="float: left"
value="#{messages['save']}"
actionListener="#{shelfManager.editShelf(model.selectedShelf)}"
reRender="treePanel, mainArea" />
+ <richx:commandButton id="saveButton" style="float: left"
value="#{messages['save']}"
actionListener="#{shelfManager.editShelf(model.selectedShelf, false)}"
reRender="treePanel, mainArea" />
<richx:commandButton id="cancelButton"
value="#{messages['cancel']}" immediate="true"
actionListener="#{controller.cancelEditShelf()}" reRender="mainArea"
/>
</td>
</tr>
Modified:
trunk/examples/photoalbum/source/web/src/main/webapp/includes/shelf/shelfInfo.xhtml
===================================================================
(Binary files differ)