[jboss-cvs] jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace ...
Shane Bryzak
Shane_Bryzak at symantec.com
Wed Jan 10 21:23:16 EST 2007
User: sbryzak2
Date: 07/01/10 21:23:16
Modified: examples/seamspace/src/org/jboss/seam/example/seamspace
BlogAction.java BlogComment.java BlogLocal.java
MemberBlog.java
Added: examples/seamspace/src/org/jboss/seam/example/seamspace
CommentAction.java CommentLocal.java
Log:
added blog comments page
Revision Changes Path
1.3 +30 -0 jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/BlogAction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BlogAction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/BlogAction.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- BlogAction.java 11 Jan 2007 00:43:53 -0000 1.2
+++ BlogAction.java 11 Jan 2007 02:23:16 -0000 1.3
@@ -5,6 +5,7 @@
import javax.ejb.Remove;
import javax.ejb.Stateful;
import javax.persistence.EntityManager;
+import javax.persistence.NoResultException;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Destroy;
@@ -23,6 +24,9 @@
@RequestParameter
private String name;
+ @RequestParameter
+ private Integer blogId;
+
@In(create=true)
private EntityManager entityManager;
@@ -32,6 +36,12 @@
@Out(required = false)
private List memberBlogs;
+ @Out(required = false)
+ private MemberBlog selectedBlog;
+
+ /**
+ * Returns the 5 latest blog entries for a member
+ */
public List getLatestBlogs()
{
return entityManager.createQuery(
@@ -41,6 +51,9 @@
.getResultList();
}
+ /**
+ * Used to read all blog entries for a member
+ */
@Factory("memberBlogs")
public void getMemberBlogs()
{
@@ -50,6 +63,23 @@
.getResultList();
}
+ /**
+ * Used to read a single blog entry for a member
+ */
+ @Factory("selectedBlog")
+ public void getBlog()
+ {
+ try
+ {
+ selectedBlog = (MemberBlog) entityManager.createQuery(
+ "from MemberBlog b where b.blogId = :blogId and b.member.name = :name")
+ .setParameter("blogId", blogId)
+ .setParameter("name", name)
+ .getSingleResult();
+ }
+ catch (NoResultException ex) { }
+ }
+
@Remove @Destroy
public void destroy() { }
}
1.2 +12 -1 jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/BlogComment.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BlogComment.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/BlogComment.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- BlogComment.java 11 Jan 2007 00:43:53 -0000 1.1
+++ BlogComment.java 11 Jan 2007 02:23:16 -0000 1.2
@@ -1,12 +1,14 @@
package org.jboss.seam.example.seamspace;
import java.io.Serializable;
+import java.text.SimpleDateFormat;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
+import javax.persistence.Transient;
import org.hibernate.validator.NotNull;
import org.jboss.seam.annotations.Name;
@@ -17,6 +19,8 @@
{
private static final long serialVersionUID = 5495139096911872039L;
+ private static SimpleDateFormat df = new SimpleDateFormat("EEEE, MMMM d, yyyy 'at' hh:mm a");
+
private Integer commentId;
private MemberBlog blog;
private Member commentor;
@@ -35,6 +39,7 @@
}
@ManyToOne
+ @JoinColumn(name = "BLOG_ID")
public MemberBlog getBlog()
{
return blog;
@@ -66,8 +71,14 @@
this.commentDate = commentDate;
}
+ @Transient
+ public String getFormattedCommentDate()
+ {
+ return df.format(commentDate);
+ }
+
@ManyToOne
- @JoinColumn(name = "MEMBER_ID")
+ @JoinColumn(name = "COMMENTOR_ID")
public Member getCommentor()
{
return commentor;
1.3 +1 -0 jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/BlogLocal.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BlogLocal.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/BlogLocal.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- BlogLocal.java 11 Jan 2007 00:43:53 -0000 1.2
+++ BlogLocal.java 11 Jan 2007 02:23:16 -0000 1.3
@@ -9,5 +9,6 @@
{
List getLatestBlogs();
void getMemberBlogs();
+ void getBlog();
void destroy();
}
1.3 +1 -1 jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberBlog.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MemberBlog.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberBlog.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- MemberBlog.java 11 Jan 2007 00:43:53 -0000 1.2
+++ MemberBlog.java 11 Jan 2007 02:23:16 -0000 1.3
@@ -90,7 +90,7 @@
this.title = title;
}
- @OneToMany
+ @OneToMany(mappedBy = "blog")
public List<BlogComment> getComments()
{
return comments;
1.1 date: 2007/01/11 02:23:16; author: sbryzak2; state: Exp;jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/CommentAction.java
Index: CommentAction.java
===================================================================
package org.jboss.seam.example.seamspace;
import javax.ejb.Remove;
import javax.ejb.Stateful;
import org.jboss.seam.annotations.Destroy;
import org.jboss.seam.annotations.Name;
@Name("commentAction")
@Stateful
public class CommentAction implements CommentLocal
{
@Remove @Destroy
public void destroy() { }
}
1.1 date: 2007/01/11 02:23:16; author: sbryzak2; state: Exp;jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/CommentLocal.java
Index: CommentLocal.java
===================================================================
package org.jboss.seam.example.seamspace;
import javax.ejb.Local;
@Local
public interface CommentLocal
{
void destroy();
}
More information about the jboss-cvs-commits
mailing list