Author: shane.bryzak(a)jboss.com
Date: 2010-03-31 05:11:02 -0400 (Wed, 31 Mar 2010)
New Revision: 12339
Modified:
modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/BlogAction.java
modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/ProfileAction.java
modules/security/trunk/examples/seamspace/src/main/webapp/WEB-INF/classes/seam-beans.xml
modules/security/trunk/examples/seamspace/src/main/webapp/blog.xhtml
modules/security/trunk/examples/seamspace/src/main/webapp/blogentry.xhtml
modules/security/trunk/examples/seamspace/src/main/webapp/profile.xhtml
Log:
fixed profile page, blog entry page, minor
Modified:
modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/BlogAction.java
===================================================================
---
modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/BlogAction.java 2010-03-31
04:16:47 UTC (rev 12338)
+++
modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/BlogAction.java 2010-03-31
09:11:02 UTC (rev 12339)
@@ -6,7 +6,6 @@
import javax.enterprise.context.Conversation;
import javax.enterprise.context.ConversationScoped;
-import javax.enterprise.inject.Produces;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
@@ -16,7 +15,7 @@
import org.jboss.seam.security.examples.seamspace.model.Member;
import org.jboss.seam.security.examples.seamspace.model.MemberBlog;
-@Named("blog")
+@Named
@ConversationScoped
public class BlogAction implements Serializable
{
@@ -27,21 +26,26 @@
@Inject EntityManager entityManager;
- /*@Inject*/ MemberBlog selectedBlog;
+ private MemberBlog selectedBlog;
@Inject Member authenticatedMember;
@Inject Conversation conversation;
+ public MemberBlog getSelectedBlog()
+ {
+ return selectedBlog;
+ }
+
/**
* Used to read a single blog entry for a member
*/
- public @Produces @Named("selectedBlog") MemberBlog getBlog()
+ public void loadBlog()
{
conversation.begin();
try
{
- return (MemberBlog) entityManager.createQuery(
+ selectedBlog = (MemberBlog) entityManager.createQuery(
"from MemberBlog b where b.blogId = :blogId and b.member.memberName =
:memberName")
.setParameter("blogId", blogId)
.setParameter("memberName", name)
@@ -49,7 +53,7 @@
}
catch (NoResultException ex)
{
- return null;
+
}
}
Modified:
modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/ProfileAction.java
===================================================================
---
modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/ProfileAction.java 2010-03-31
04:16:47 UTC (rev 12338)
+++
modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/ProfileAction.java 2010-03-31
09:11:02 UTC (rev 12339)
@@ -2,31 +2,27 @@
import java.util.List;
-import java.util.Random;
-import javax.enterprise.context.RequestScoped;
+import javax.enterprise.inject.Model;
import javax.inject.Inject;
-import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import org.jboss.seam.security.examples.seamspace.model.FriendComment;
import org.jboss.seam.security.examples.seamspace.model.Member;
+import org.jboss.seam.security.examples.seamspace.model.MemberAccount;
import org.jboss.seam.security.examples.seamspace.model.MemberBlog;
+import org.jboss.seam.security.examples.seamspace.util.Authenticated;
-@RequestScoped
-@Named
+@Model
public class ProfileAction
{
- //@RequestParameter
private String name;
- @Inject Member selectedMember;
+ private Member selectedMember;
+
+ private @Inject @Authenticated MemberAccount authenticatedAccount;
-
- @Inject
- private Member authenticatedMember;
-
//@Out(required = false)
List<Member> newMembers;
@@ -35,25 +31,29 @@
@Inject EntityManager entityManager;
- //@Factory("selectedMember")
- public void display()
- {
- if (name == null && authenticatedMember != null)
+ public Member getSelectedMember()
+ {
+ if (selectedMember == null)
{
- selectedMember = (Member) entityManager.find(Member.class,
- authenticatedMember.getMemberId());
- }
- else if (name != null)
- {
- try
+ if (name == null && authenticatedAccount != null)
{
- selectedMember = (Member) entityManager.createQuery(
- "from Member where memberName = :memberName")
- .setParameter("memberName", name)
- .getSingleResult();
+ selectedMember = (Member) entityManager.find(Member.class,
+ authenticatedAccount.getMember().getMemberId());
}
- catch (NoResultException ex) { }
+ else if (name != null)
+ {
+ try
+ {
+ selectedMember = (Member) entityManager.createQuery(
+ "from Member where memberName = :memberName")
+ .setParameter("memberName", name)
+ .getSingleResult();
+ }
+ catch (NoResultException ex) { }
+ }
}
+
+ return selectedMember;
}
/**
@@ -76,9 +76,9 @@
//@Factory("memberBlogs")
public void getMemberBlogs()
{
- if (name == null && authenticatedMember != null)
+ if (name == null && authenticatedAccount != null)
{
- name = authenticatedMember.getMemberName();
+ name = authenticatedAccount.getMember().getMemberName();
}
memberBlogs = entityManager.createQuery(
Modified:
modules/security/trunk/examples/seamspace/src/main/webapp/WEB-INF/classes/seam-beans.xml
===================================================================
---
modules/security/trunk/examples/seamspace/src/main/webapp/WEB-INF/classes/seam-beans.xml 2010-03-31
04:16:47 UTC (rev 12338)
+++
modules/security/trunk/examples/seamspace/src/main/webapp/WEB-INF/classes/seam-beans.xml 2010-03-31
09:11:02 UTC (rev 12339)
@@ -4,6 +4,7 @@
xmlns:s="urn:java:seam:core"
xmlns:security="urn:java:org.jboss.seam.security"
xmlns:idm="urn:java:org.jboss.seam.security.management"
+ xmlns:pm="urn:java:org.jboss.seam.security.permission"
xmlns:seamspace="urn:java:org.jboss.seam.security.examples.seamspace"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
@@ -24,4 +25,9 @@
<idm:roleEntityClass>org.jboss.seam.security.examples.seamspace.model.MemberRole</idm:roleEntityClass>
</idm:JpaIdentityStore>
+ <pm:JpaPermissionStore>
+ <s:extends/>
+
<pm:userPermissionClass>org.jboss.seam.security.examples.seamspace.model.AccountPermission</pm:userPermissionClass>
+ </pm:JpaPermissionStore>
+
</beans>
\ No newline at end of file
Modified: modules/security/trunk/examples/seamspace/src/main/webapp/blog.xhtml
===================================================================
--- modules/security/trunk/examples/seamspace/src/main/webapp/blog.xhtml 2010-03-31
04:16:47 UTC (rev 12338)
+++ modules/security/trunk/examples/seamspace/src/main/webapp/blog.xhtml 2010-03-31
09:11:02 UTC (rev 12339)
@@ -2,56 +2,58 @@
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
-
xmlns:h="http://java.sun.com/jsf/html"
-
xmlns:s="http://jboss.com/products/seam/taglib">
+
xmlns:h="http://java.sun.com/jsf/html">
<ui:composition template="template.xhtml">
<ui:define name="content">
<div class="errors"><h:messages
globalOnly="true"/></div>
- <s:div rendered="#{selectedMember == null}">
- Sorry, but this member does not exist.
- </s:div>
+ <ui:fragment rendered="#{selectedMember == null}">
+ <div>Sorry, but this member does not exist.</div>
+ </ui:fragment>
- <s:div rendered="#{selectedMember != null}">
+ <ui:fragment rendered="#{selectedMember != null}">
+ <div>
+ <div id="blogMemberCard">
+ <h:link outcome="/profile.seam">
+ #{selectedMember.memberName}<br/>
+ <h:graphicImage
value="/content/images?id=#{selectedMember.picture.imageId}&width=90"/>
+ </h:link>
+
+ <br style="clear:both"/>
+ </div>
+
+ <div id="blog">
+ <ui:repeat value="#{memberBlogs}" var="memberBlog">
+ <div class="blogEntry">
+ <div
class="blogDate">#{memberBlog.formattedEntryDate}</div>
+ <div class="blogTitle">#{memberBlog.title}</div>
+ <div class="blogText"><s:formattedText
value="#{memberBlog.text}"/></div>
+ <div class="blogFooter">
+
+ [<h:link outcome="/blogentry.seam">
+ <f:param name="name"
value="#{selectedMember.memberName}"/>
+ <f:param name="blogId"
value="#{memberBlog.blogId}"/>
+ #{memberBlog.commentCount} Comment#{memberBlog.commentCount != 1 ?
"s" : ""}
+ </h:link>]
+
+ <ui:fragment
rendered="#{s:hasPermission('blog','createComment')}">
+ <span>
+ [<h:link outcome="/comment.seam" value="Add
Comment">
+ <f:param name="name"
value="#{selectedMember.memberName}"/>
+ <f:param name="blogId"
value="#{memberBlog.blogId}"/>
+ </h:link>]
+ </span>
+ </ui:fragment>
+ </div>
+ </div>
+ </ui:repeat>
+ </div>
+
+ </div>
+ </ui:fragment>
- <s:div id="blogMemberCard">
- <s:link view="/profile.seam" propagation="none">
- #{selectedMember.memberName}<br/>
- <h:graphicImage
value="/content/images?id=#{selectedMember.picture.imageId}&width=90"/>
- </s:link>
-
- <br style="clear:both"/>
- </s:div>
-
- <s:div id="blog">
- <ui:repeat value="#{memberBlogs}" var="memberBlog">
- <div class="blogEntry">
- <div
class="blogDate">#{memberBlog.formattedEntryDate}</div>
- <div class="blogTitle">#{memberBlog.title}</div>
- <div class="blogText"><s:formattedText
value="#{memberBlog.text}"/></div>
- <div class="blogFooter">
-
- [<s:link view="/blogentry.seam"
propagation="none">
- <f:param name="name"
value="#{selectedMember.memberName}"/>
- <f:param name="blogId"
value="#{memberBlog.blogId}"/>
- #{memberBlog.commentCount} Comment#{memberBlog.commentCount != 1 ?
"s" : ""}
- </s:link>]
-
- <s:span
rendered="#{s:hasPermission('blog','createComment')}">
- [<s:link view="/comment.seam" value="Add Comment"
propagation="none">
- <f:param name="name"
value="#{selectedMember.memberName}"/>
- <f:param name="blogId"
value="#{memberBlog.blogId}"/>
- </s:link>]
- </s:span>
- </div>
- </div>
- </ui:repeat>
- </s:div>
-
- </s:div>
-
<br class="clear"/>
</ui:define>
Modified: modules/security/trunk/examples/seamspace/src/main/webapp/blogentry.xhtml
===================================================================
--- modules/security/trunk/examples/seamspace/src/main/webapp/blogentry.xhtml 2010-03-31
04:16:47 UTC (rev 12338)
+++ modules/security/trunk/examples/seamspace/src/main/webapp/blogentry.xhtml 2010-03-31
09:11:02 UTC (rev 12339)
@@ -2,69 +2,79 @@
<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:s="http://jboss.com/products/seam/taglib">
+
xmlns:f="http://java.sun.com/jsf/core">
<ui:composition template="template.xhtml">
<ui:define name="content">
+ <f:metadata>
+ <f:viewParam name="name" value="#{blogAction.name}"/>
+ <f:viewParam name="blogId"
value="#{blogAction.blogId}"/>
+ </f:metadata>
+ <f:event type="preRenderView"
listener="#{blogAction.loadBlog}"/>
+
<div class="errors"><h:messages
globalOnly="true"/></div>
- <s:div rendered="#{selectedBlog == null}">
- Sorry, but this blog entry does not exist.
- </s:div>
+ <ui:fragment rendered="#{blogAction.selectedBlog == null}">
+ <div>
+ Sorry, but this blog entry does not exist.
+ </div>
+ </ui:fragment>
- <s:div rendered="#{selectedBlog != null}">
-
- <s:div id="blogMemberCard">
- <s:link view="/profile.seam" propagation="none">
- #{selectedMember.memberName}<br/>
- <h:graphicImage
value="/content/images?id=#{selectedMember.picture.imageId}&width=90"/>
- </s:link>
-
- <br style="clear:both"/>
- </s:div>
-
- <s:div id="blog">
- <div class="blogEntry">
- <div
class="blogDate">#{selectedBlog.formattedEntryDate}</div>
- <div class="blogTitle">#{selectedBlog.title}</div>
- <div class="blogText"><s:formattedText
value="#{selectedBlog.text}"/></div>
- <div class="blogFooter">
- <s:span rendered="#{s:hasPermission(selectedBlog,
'create')}">
- [<s:link action="#{commentAction.createComment}"
value="Add Comment"/>]
- </s:span>
- [<s:link view="/blog.seam" value="View all blog
entries" propagation="none">
- <f:param name="name"
value="#{selectedMember.memberName}"/>
- </s:link>]
+ <ui:fragment rendered="#{blogAction.selectedBlog != null}">
+ <div>
+ <div id="blogMemberCard">
+ <h:link outcome="/profile.seam">
+ #{blogAction.selectedBlog.member.memberName}<br/>
+ <h:graphicImage
value="/content/images?id=#{blogAction.selectedBlog.member.picture.imageId}&width=90"/>
+ </h:link>
+
+ <br style="clear:both"/>
+ </div>
+
+ <div id="blog">
+ <div class="blogEntry">
+ <div
class="blogDate">#{blogAction.selectedBlog.formattedEntryDate}</div>
+ <div
class="blogTitle">#{blogAction.selectedBlog.title}</div>
+ <div class="blogText"><h:outputText
value="#{blogAction.selectedBlog.text}"/></div>
+ <div class="blogFooter">
+ <ui:fragment rendered="#{identity.hasPermission(selectedBlog,
'create')}">
+ <span>
+ [<h:link action="#{commentAction.createComment}"
value="Add Comment"/>]
+ </span>
+ </ui:fragment>
+ [<h:link outcome="/blog.seam" value="View all blog
entries">
+ <f:param name="name"
value="#{blogAction.selectedBlog.member.memberName}"/>
+ </h:link>]
+ </div>
</div>
- </div>
-
- <ui:repeat value="#{selectedBlog.sortedComments}"
var="comment">
- <table class="blogComment">
- <tr>
- <td class="blogCommentor">
- <s:link view="/profile.seam" propagation="none">
- <f:param name="name"
value="#{comment.commentor.memberName}"/>
- #{comment.commentor.memberName}<br/>
- <h:graphicImage
value="/content/images?id=#{comment.commentor.picture.imageId}&width=90"/>
- </s:link>
- </td>
-
- <td class="blogCommentText">
- <p><s:formattedText
value="#{comment.comment}"/></p>
- <p>Posted by
- <s:link view="/profile.seam"
value="#{comment.commentor.memberName}" propagation="none">
- <f:param name="name"
value="#{comment.commentor.memberName}"/>
- </s:link> on #{comment.formattedCommentDate}
- </p>
- </td>
- </tr>
- </table>
- </ui:repeat>
- </s:div>
-
- </s:div>
+
+ <ui:repeat value="#{blogAction.selectedBlog.sortedComments}"
var="comment">
+ <table class="blogComment">
+ <tr>
+ <td class="blogCommentor">
+ <h:link outcome="/profile.seam">
+ <f:param name="name"
value="#{comment.commentor.memberName}"/>
+ #{comment.commentor.memberName}<br/>
+ <h:graphicImage
value="/content/images?id=#{comment.commentor.picture.imageId}&width=90"/>
+ </h:link>
+ </td>
+
+ <td class="blogCommentText">
+ <p><h:outputText
value="#{comment.comment}"/></p>
+ <p>Posted by
+ <h:link outcome="/profile.seam"
value="#{comment.commentor.memberName}">
+ <f:param name="name"
value="#{comment.commentor.memberName}"/>
+ </h:link> on #{comment.formattedCommentDate}
+ </p>
+ </td>
+ </tr>
+ </table>
+ </ui:repeat>
+ </div>
+
+ </div>
+ </ui:fragment>
<br class="clear"/>
Modified: modules/security/trunk/examples/seamspace/src/main/webapp/profile.xhtml
===================================================================
--- modules/security/trunk/examples/seamspace/src/main/webapp/profile.xhtml 2010-03-31
04:16:47 UTC (rev 12338)
+++ modules/security/trunk/examples/seamspace/src/main/webapp/profile.xhtml 2010-03-31
09:11:02 UTC (rev 12339)
@@ -9,52 +9,52 @@
<div class="errors"><h:messages
globalOnly="true"/></div>
- <ui:fragment rendered="#{selectedMember == null}">
+ <ui:fragment rendered="#{profileAction.selectedMember == null}">
<div>Sorry, but this member does not exist.</div>
</ui:fragment>
- <ui:fragment rendered="#{selectedMember != null}">
+ <ui:fragment rendered="#{profileAction.selectedMember != null}">
<div id="memberCard">
- <h1>#{selectedMember.memberName}'s profile</h1>
+ <h1>#{profileAction.selectedMember.memberName}'s profile</h1>
- <ui:fragment rendered="#{selectedMember.picture ne null}">
+ <ui:fragment rendered="#{profileAction.selectedMember.picture ne
null}">
<div id="memberCardPicture">
- <h:graphicImage
value="/content/images?id=#{selectedMember.picture.imageId}&width=170"/>
+ <h:graphicImage
value="/content/images?id=#{profileAction.selectedMember.picture.imageId}&width=170"/>
</div>
</ui:fragment>
<div id="memberCardText">
- <span
class="tagline">"#{selectedMember.tagline}"</span><br/><br/>
- #{selectedMember.gender.descr}<br/>
- #{selectedMember.age}<br/>
- #{selectedMember.location}<br/>
+ <span
class="tagline">"#{profileAction.selectedMember.tagline}"</span><br/><br/>
+ #{profileAction.selectedMember.gender.descr}<br/>
+ #{profileAction.selectedMember.age}<br/>
+ #{profileAction.selectedMember.location}<br/>
</div>
<br style="clear:both"/>
View My:
<h:link outcome="/pictures.xhtml" value="Pics">
- <f:param name="name"
value="#{selectedMember.memberName}"/>
+ <f:param name="name"
value="#{profileAction.selectedMember.memberName}"/>
</h:link>
</div>
<div id="memberBlog">
- <div class="sectionHeader">#{selectedMember.memberName}'s
latest blog entries</div>
+ <div
class="sectionHeader">#{profileAction.selectedMember.memberName}'s latest
blog entries</div>
- <ui:repeat value="#{profile.latestBlogs}"
var="latestBlog">
+ <ui:repeat value="#{profileAction.latestBlogs}"
var="latestBlog">
<div class="blogSummary">#{latestBlog.title}
(<h:link outcome="/blogentry.xhtml" value="view
more">
- <f:param name="name"
value="#{selectedMember.memberName}"/>
+ <f:param name="name"
value="#{profileAction.selectedMember.memberName}"/>
<f:param name="blogId"
value="#{latestBlog.blogId}"/>
</h:link>)
</div>
</ui:repeat>
[<h:link id="viewBlog" outcome="/blog.xhtml"
value="View all blog entries" propagation="none">
- <f:param name="name"
value="#{selectedMember.memberName}"/>
+ <f:param name="name"
value="#{profileAction.selectedMember.memberName}"/>
</h:link>]
- <ui:fragment rendered="#{identity.hasPermission(selectedMember,
'createBlog')}">
+ <ui:fragment
rendered="#{identity.hasPermission(profileAction.selectedMember,
'createBlog')}">
<span>
[<h:link id="createBlog"
action="#{blog.createEntry}" value="Create new blog entry"/>]
</span>
@@ -62,7 +62,7 @@
</div>
<div id="memberFriends">
- <div class="sectionHeader">#{selectedMember.memberName}'s
friends</div>
+ <div
class="sectionHeader">#{profileAction.selectedMember.memberName}'s
friends</div>
<ui:repeat value="#{profile.friends}" var="f">
<div class="friend">
@@ -78,7 +78,7 @@
<br class="clear"/>
- <ui:fragment rendered="#{selectedMember.memberId !=
authenticatedMember.memberId and identity.hasPermission(selectedMember,
'createFriendRequest')}">
+ <ui:fragment rendered="#{profileAction.selectedMember.memberId !=
authenticatedMember.memberId and identity.hasPermission(selectedMember,
'createFriendRequest')}">
<span>
[<h:link outcome="/friendrequest.xhtml"
action="#{friendAction.createRequest}" value="Send a friend
request"/>]
</span>
@@ -87,7 +87,7 @@
</div>
<div id="friendComments">
- <div class="sectionHeader">#{selectedMember.memberName}'s
friend's comments</div>
+ <div
class="sectionHeader">#{profileAction.selectedMember.memberName}'s
friend's comments</div>
<ui:repeat value="#{profile.friendComments}" var="c">
<table class="friendComments">
@@ -108,7 +108,7 @@
</table>
</ui:repeat>
- <ui:fragment rendered="#{identity.hasPermission(selectedMember,
'createFriendComment')}">
+ <ui:fragment
rendered="#{identity.hasPermission(profileAction.selectedMember,
'createFriendComment')}">
<span>
[<h:link outcome="/friendcomment.xhtml" value="Add
Comment"/>]
</span>