Author: amarkhel
Date: 2009-03-04 08:20:50 -0500 (Wed, 04 Mar 2009)
New Revision: 12822
Added:
trunk/test-applications/realworld2/web/src/main/webapp/includes/tag.xhtml
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/modalpanel/test.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/navigation/NavigationEnum.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/servlet/PictureServlet.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ConversationState.java
trunk/test-applications/realworld2/web/src/main/webapp/includes/tagCloud/tagCloud.xhtml
Log:
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java 2009-03-04
12:49:02 UTC (rev 12821)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/IImageAction.java 2009-03-04
13:20:50 UTC (rev 12822)
@@ -24,6 +24,7 @@
import org.richfaces.realworld.domain.Comment;
import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.MetaTag;
@Local
public interface IImageAction {
@@ -38,4 +39,6 @@
public void addComment(Comment comment);
+ public abstract MetaTag getTagByName(String tag);
+
}
\ No newline at end of file
Modified:
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java
===================================================================
---
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java 2009-03-04
12:49:02 UTC (rev 12821)
+++
trunk/test-applications/realworld2/ejb/src/main/java/org/richfaces/realworld/service/ImageAction.java 2009-03-04
13:20:50 UTC (rev 12822)
@@ -97,4 +97,8 @@
comment.getImage().addComment(comment);
em.flush();
}
+
+ public MetaTag getTagByName(String tag) {
+ return (MetaTag)em.createQuery("from MetaTag m where m.tag
=:tag").setParameter("tag", tag).getSingleResult();
+ }
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/modalpanel/test.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/modalpanel/test.java 2009-03-04
12:49:02 UTC (rev 12821)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/modalpanel/test.java 2009-03-04
13:20:50 UTC (rev 12822)
@@ -4,10 +4,13 @@
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
+import java.io.BufferedWriter;
import java.io.File;
+import java.io.FileWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
+import java.util.Random;
import javax.imageio.ImageIO;
import javax.imageio.stream.FileImageInputStream;
@@ -26,9 +29,10 @@
* @throws IOException
*/
public static void main(String[] args) throws IOException {
- String directory ="C:\\Documents and
Settings\\Administrator\\Desktop\\amarkhel\\Sport";
+ /*String directory ="C:\\Documents and
Settings\\Administrator\\Desktop\\amarkhel\\Sport";
writeFiles(directory, "_mini", 150);
- writeFiles(directory, "_medium", 600);
+ writeFiles(directory, "_medium", 600);*/
+ generateTags();
}
/*public static void renameAllImagesFromAlbumAndChilds(Album album, String replace,
@@ -90,6 +94,23 @@
return begin + substitute + end;
}
+ private static void generateTags(){
+ try {
+ BufferedWriter out = new BufferedWriter(new
FileWriter("C:\\1114.txt"));
+ //String a ="INSERT INTO comments(comment_id, date, message,
image_comment_id, from_user_id) VALUES ("+commentId+", '1985-01-08',
'Hello I am user',"+ imageId+", 2);\n"+ "INSERT INTO
comments(comment_id, date, message, image_comment_id, from_user_id) VALUES
("+commentId2+", '1985-01-08', 'Hello I am user2',"+
imageId+", 3);\n";
+
+ //out.write("INSERT INTO IMAGES_METATAGS(CI_IMAGE_ID, CI_METATAG_ID)
VALUES("+"1"+"," +"1"+ ");\n");
+ for(int i =2; i<84; i++){
+ String imageId =(new Integer(i)).toString();
+ String commentId = (new Integer(i*2 -1)).toString();
+ String commentId2 = (new Integer(i*2)).toString();
+ out.append("INSERT INTO comments(comment_id, date, message, image_comment_id,
from_user_id) VALUES ("+commentId +", '1985-01-08', 'Hello I am
user',"+ imageId+", 2);\n"+ "INSERT INTO comments(comment_id,
date, message, image_comment_id, from_user_id) VALUES ("+commentId2+",
'1985-01-08', 'Hello I am user2',"+ imageId+", 3);\n");
+ }
+ out.close();
+ } catch (IOException e) {
+ }
+
+ }
/*private static void transform() throws IOException{
File temp = new
File("E:\\richfaces\\test-applications\\realworld\\Upload\\galleries\\Nature\\1.jpg");
BufferedImage bsrc =null;
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/navigation/NavigationEnum.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/navigation/NavigationEnum.java 2009-03-04
12:49:02 UTC (rev 12821)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/navigation/NavigationEnum.java 2009-03-04
13:20:50 UTC (rev 12822)
@@ -29,7 +29,7 @@
ALBUM_PREVIEW("includes/userImage.xhtml"),
SHELF_PREVIEW("/includes/userAlbum.xhtml"),
ALL_SHELFS("/includes/userShelfs.xhtml"),
- TAGS("includes/tags.xhtml"),
+ TAGS("includes/tag.xhtml"),
ALL_ALBUMS("includes/albums.xhtml"),
ALL_IMAGES("includes/images.xhtml");
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/servlet/PictureServlet.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/servlet/PictureServlet.java 2009-03-04
12:49:02 UTC (rev 12821)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/servlet/PictureServlet.java 2009-03-04
13:20:50 UTC (rev 12822)
@@ -46,11 +46,8 @@
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException, IOException {
String pathInfo = request.getPathInfo();
- if(pathInfo.startsWith("/")){
- pathInfo = pathInfo.substring(1);
- }
String fileName = URLDecoder.decode(WebUtil.getFileName(pathInfo), "UTF8");
- if(!isAccessGranted(request, response, pathInfo)){
+ if(!isAccessGranted(request, response, fileName)){
sendToErrorPage(request, response);
return;
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java 2009-03-04
12:49:02 UTC (rev 12821)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/tagClound/TagCloudBean.java 2009-03-04
13:20:50 UTC (rev 12822)
@@ -9,9 +9,13 @@
import javax.faces.event.ActionEvent;
import org.jboss.seam.ScopeType;
+import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.core.Events;
+import org.richfaces.realworld.navigation.NavigationEnum;
+import org.richfaces.realworld.service.IImageAction;
/**
@@ -23,7 +27,7 @@
@Name("tagCloudBean")
@Scope(ScopeType.CONVERSATION)
public class TagCloudBean {
-
+ @In(create=true) IImageAction imageAction;
/** Min possible rank for tag */
static final int MIN_RANK = 0;
@@ -54,15 +58,9 @@
int i = rank / RANK_LEVEL_STEP;
return TAG_CSS_CLASSSES[i];
}
-
-
-
- /**
- * Action listener for tag click
- * @param event
- */
- public void processTagClick(ActionEvent event) {
- // TODO: implement this
- }
+ public void selectTag(String tag){
+ Events.instance().raiseEvent("updateMainArea", NavigationEnum.TAGS);
+ Events.instance().raiseEvent("updateSelectedTag",imageAction.getTagByName(tag));
+ }
}
Modified:
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ConversationState.java
===================================================================
---
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ConversationState.java 2009-03-04
12:49:02 UTC (rev 12821)
+++
trunk/test-applications/realworld2/web/src/main/java/org/richfaces/realworld/util/ConversationState.java 2009-03-04
13:20:50 UTC (rev 12822)
@@ -42,6 +42,7 @@
import org.richfaces.model.TreeRowKey;
import org.richfaces.realworld.domain.Album;
import org.richfaces.realworld.domain.Image;
+import org.richfaces.realworld.domain.MetaTag;
import org.richfaces.realworld.domain.Shelf;
import org.richfaces.realworld.domain.User;
import org.richfaces.realworld.navigation.NavigationEnum;
@@ -71,6 +72,8 @@
private User secondSelectedUser;
+ private MetaTag selectedTag;
+
private NavigationEnum mainArea;
//@In
@@ -363,4 +366,14 @@
public User getUser() {
return user;
}
+
+
+
+ public MetaTag getSelectedTag() {
+ return selectedTag;
+ }
+ @Observer("updateSelectedTag")
+ public void setSelectedTag(MetaTag selectedTag) {
+ this.selectedTag = selectedTag;
+ }
}
Added: trunk/test-applications/realworld2/web/src/main/webapp/includes/tag.xhtml
===================================================================
(Binary files differ)
Property changes on:
trunk/test-applications/realworld2/web/src/main/webapp/includes/tag.xhtml
___________________________________________________________________
Name: svn:mime-type
+ application/xhtml+xml
Modified:
trunk/test-applications/realworld2/web/src/main/webapp/includes/tagCloud/tagCloud.xhtml
===================================================================
---
trunk/test-applications/realworld2/web/src/main/webapp/includes/tagCloud/tagCloud.xhtml 2009-03-04
12:49:02 UTC (rev 12821)
+++
trunk/test-applications/realworld2/web/src/main/webapp/includes/tagCloud/tagCloud.xhtml 2009-03-04
13:20:50 UTC (rev 12822)
@@ -8,8 +8,8 @@
<a4j:outputPanel layout="block" style="width: 200px">
<h:form>
<c:forEach items="#{tagList}" var="tag">
- <a4j:commandLink value="#{tag.key}"
- actionListener="#{tagCloudBean.processTagClick(tag.key)}"
+ <a4j:commandLink value="#{tag.key}" reRender="mainArea"
+ actionListener="#{tagCloudBean.selectTag(tag.key)}"
styleClass="#{tagCloudBean.getTagCssClass(tag.value)}"></a4j:commandLink>
</c:forEach>
</h:form>