[seam-commits] Seam SVN: r12336 - in modules/security/trunk/examples/seamspace: src/main/java/org/jboss/seam/security/examples/seamspace/action and 3 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Tue Mar 30 22:58:12 EDT 2010
Author: shane.bryzak at jboss.com
Date: 2010-03-30 22:58:12 -0400 (Tue, 30 Mar 2010)
New Revision: 12336
Added:
modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/MemberSearch.java
Modified:
modules/security/trunk/examples/seamspace/pom.xml
modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/ContentAction.java
modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/PictureSearch.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/java/org/jboss/seam/security/examples/seamspace/util/AuthenticationEvents.java
modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/util/EntityManagerProducer.java
modules/security/trunk/examples/seamspace/src/main/webapp/WEB-INF/web.xml
modules/security/trunk/examples/seamspace/src/main/webapp/home.xhtml
modules/security/trunk/examples/seamspace/src/main/webapp/profile.xhtml
modules/security/trunk/examples/seamspace/src/main/webapp/template.xhtml
Log:
fix jsf tags, links, fix new member search, fix content servlet, temporarily disable security for content servlet, other misc
Modified: modules/security/trunk/examples/seamspace/pom.xml
===================================================================
--- modules/security/trunk/examples/seamspace/pom.xml 2010-03-31 01:35:01 UTC (rev 12335)
+++ modules/security/trunk/examples/seamspace/pom.xml 2010-03-31 02:58:12 UTC (rev 12336)
@@ -98,27 +98,27 @@
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
-
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-war-plugin</artifactId>
- <version>2.0</version>
- <configuration>
- <warName>${pom.artifactId}</warName>
- </configuration>
- </plugin>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.0</version>
+ <configuration>
+ <warName>seam-space</warName>
+ </configuration>
+ </plugin>
- </plugins>
+ </plugins>
</build>
</project>
Modified: modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/ContentAction.java
===================================================================
--- modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/ContentAction.java 2010-03-31 01:35:01 UTC (rev 12335)
+++ modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/ContentAction.java 2010-03-31 02:58:12 UTC (rev 12336)
@@ -1,5 +1,6 @@
package org.jboss.seam.security.examples.seamspace.action;
+import javax.enterprise.context.Dependent;
import javax.inject.Inject;
import javax.inject.Named;
import javax.persistence.EntityManager;
@@ -7,7 +8,7 @@
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.examples.seamspace.model.MemberImage;
- at Named
+ at Dependent @Named
public class ContentAction
{
@Inject EntityManager entityManager;
@@ -17,9 +18,9 @@
{
MemberImage img = entityManager.find(MemberImage.class, imageId);
- if (img == null || !identity.hasPermission(img, "view"))
+ /* if (img == null || !identity.hasPermission(img, "view"))
return null;
- else
+ else*/
return img;
}
}
Added: modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/MemberSearch.java
===================================================================
--- modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/MemberSearch.java (rev 0)
+++ modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/MemberSearch.java 2010-03-31 02:58:12 UTC (rev 12336)
@@ -0,0 +1,43 @@
+package org.jboss.seam.security.examples.seamspace.action;
+
+import java.util.List;
+import java.util.Random;
+
+import javax.enterprise.inject.Model;
+import javax.inject.Inject;
+import javax.persistence.EntityManager;
+
+import org.jboss.seam.security.examples.seamspace.model.Member;
+
+ at Model
+public class MemberSearch
+{
+ @Inject EntityManager entityManager;
+
+ private List<Member> newMembers;
+
+ /**
+ * Returns a random selection of 3 members out of the latest 10 new members
+ *
+ * @return A List<Member> containing 3 random members
+ */
+ @SuppressWarnings("unchecked")
+ public List<Member> getNewMembers()
+ {
+ if (newMembers == null)
+ {
+ newMembers = entityManager.createQuery(
+ "from Member order by memberSince desc")
+ .setMaxResults(10)
+ .getResultList();
+
+ // Randomly select 3 of the latest 10 members
+ Random rnd = new Random(System.currentTimeMillis());
+ while (newMembers.size() > 3)
+ {
+ newMembers.remove(rnd.nextInt(newMembers.size()));
+ }
+ }
+ return newMembers;
+ }
+}
Modified: modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/PictureSearch.java
===================================================================
--- modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/PictureSearch.java 2010-03-31 01:35:01 UTC (rev 12335)
+++ modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/PictureSearch.java 2010-03-31 02:58:12 UTC (rev 12336)
@@ -7,7 +7,6 @@
import javax.enterprise.inject.Model;
import javax.inject.Inject;
import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
import org.jboss.seam.security.Identity;
import org.jboss.seam.security.annotations.Delete;
@@ -20,7 +19,7 @@
private String memberName;
- /*@PersistenceContext */EntityManager entityManager;
+ @Inject EntityManager entityManager;
@Inject Identity identity;
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 01:35:01 UTC (rev 12335)
+++ modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/action/ProfileAction.java 2010-03-31 02:58:12 UTC (rev 12336)
@@ -86,24 +86,7 @@
.setParameter("memberName", name)
.getResultList();
}
-
- @SuppressWarnings("unchecked")
- //@Factory("newMembers")
- public void newMembers()
- {
- newMembers = entityManager.createQuery(
- "from Member order by memberSince desc")
- .setMaxResults(10)
- .getResultList();
- // Randomly select 3 of the latest 10 members
- Random rnd = new Random(System.currentTimeMillis());
- while (newMembers.size() > 3)
- {
- newMembers.remove(rnd.nextInt(newMembers.size()));
- }
- }
-
@SuppressWarnings("unchecked")
public List<Member> getFriends()
{
Modified: modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/util/AuthenticationEvents.java
===================================================================
--- modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/util/AuthenticationEvents.java 2010-03-31 01:35:01 UTC (rev 12335)
+++ modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/util/AuthenticationEvents.java 2010-03-31 02:58:12 UTC (rev 12336)
@@ -10,7 +10,7 @@
import org.jboss.seam.security.examples.seamspace.model.MemberAccount;
@SessionScoped
-public class AuthenticationEvents implements Serializable
+class AuthenticationEvents implements Serializable
{
private static final long serialVersionUID = -2747242953250092889L;
Modified: modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/util/EntityManagerProducer.java
===================================================================
--- modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/util/EntityManagerProducer.java 2010-03-31 01:35:01 UTC (rev 12335)
+++ modules/security/trunk/examples/seamspace/src/main/java/org/jboss/seam/security/examples/seamspace/util/EntityManagerProducer.java 2010-03-31 02:58:12 UTC (rev 12336)
@@ -2,19 +2,18 @@
import java.io.Serializable;
-import javax.enterprise.context.ConversationScoped;
+import javax.enterprise.context.Dependent;
import javax.enterprise.inject.Produces;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
- at ConversationScoped
public class EntityManagerProducer implements Serializable
{
private static final long serialVersionUID = 8654896806568473010L;
@PersistenceContext EntityManager entityManager;
- public @Produces EntityManager getEntityManager()
+ public @Produces @Dependent EntityManager getEntityManager()
{
return entityManager;
}
Modified: modules/security/trunk/examples/seamspace/src/main/webapp/WEB-INF/web.xml
===================================================================
--- modules/security/trunk/examples/seamspace/src/main/webapp/WEB-INF/web.xml 2010-03-31 01:35:01 UTC (rev 12335)
+++ modules/security/trunk/examples/seamspace/src/main/webapp/WEB-INF/web.xml 2010-03-31 02:58:12 UTC (rev 12336)
@@ -22,7 +22,7 @@
<!-- Content Servlet -->
- <!--servlet>
+ <servlet>
<servlet-name>Content Servlet</servlet-name>
<servlet-class>org.jboss.seam.security.examples.seamspace.util.ContentServlet</servlet-class>
</servlet>
@@ -30,6 +30,6 @@
<servlet-mapping>
<servlet-name>Content Servlet</servlet-name>
<url-pattern>/content/*</url-pattern>
- </servlet-mapping-->
+ </servlet-mapping>
</web-app>
Modified: modules/security/trunk/examples/seamspace/src/main/webapp/home.xhtml
===================================================================
--- modules/security/trunk/examples/seamspace/src/main/webapp/home.xhtml 2010-03-31 01:35:01 UTC (rev 12335)
+++ modules/security/trunk/examples/seamspace/src/main/webapp/home.xhtml 2010-03-31 02:58:12 UTC (rev 12336)
@@ -17,7 +17,7 @@
been put together to demonstrate the various features of the Seam Security API.
</p>
- <p><b>New!</b> You can now use the <h:link view="/hashgen.xhtml" value="Password Hash Generator"/>
+ <p><b>New!</b> You can now use the <h:link outcome="/hashgen.xhtml" value="Password Hash Generator"/>
page to generate password hashes for your own application.
</p>
@@ -73,7 +73,7 @@
<div class="newMembers">
<div class="newMembersHeader">Cool new members</div>
- <ui:repeat value="#{newMembers}" var="newMember">
+ <ui:repeat value="#{memberSearch.newMembers}" var="newMember">
<div class="newMember">
<h:link view="/profile.seam" propagation="none">
Modified: modules/security/trunk/examples/seamspace/src/main/webapp/profile.xhtml
===================================================================
--- modules/security/trunk/examples/seamspace/src/main/webapp/profile.xhtml 2010-03-31 01:35:01 UTC (rev 12335)
+++ modules/security/trunk/examples/seamspace/src/main/webapp/profile.xhtml 2010-03-31 02:58:12 UTC (rev 12336)
@@ -2,26 +2,26 @@
<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">
<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}">
-
- <s:div id="memberCard">
+ <ui:fragment rendered="#{selectedMember != null}">
+ <div id="memberCard">
<h1>#{selectedMember.memberName}'s profile</h1>
-
- <s:div id="memberCardPicture" rendered="#{selectedMember.picture ne null}">
- <h:graphicImage value="/content/images?id=#{selectedMember.picture.imageId}&width=170"/>
- </s:div>
+
+ <ui:fragment rendered="#{selectedMember.picture ne null}">
+ <div id="memberCardPicture">
+ <h:graphicImage value="/content/images?id=#{selectedMember.picture.imageId}&width=170"/>
+ </div>
+ </ui:fragment>
<div id="memberCardText">
<span class="tagline">"#{selectedMember.tagline}"</span><br/><br/>
@@ -33,83 +33,89 @@
<br style="clear:both"/>
View My:
- <s:link view="/pictures.xhtml" value="Pics">
+ <h:link outcome="/pictures.xhtml" value="Pics">
<f:param name="name" value="#{selectedMember.memberName}"/>
- </s:link>
-
- </s:div>
-
- <s:div id="memberBlog">
+ </h:link>
+ </div>
+
+ <div id="memberBlog">
<div class="sectionHeader">#{selectedMember.memberName}'s latest blog entries</div>
<ui:repeat value="#{profile.latestBlogs}" var="latestBlog">
<div class="blogSummary">#{latestBlog.title}
- (<s:link view="/blogentry.xhtml" value="view more">
+ (<h:link outcome="/blogentry.xhtml" value="view more">
<f:param name="name" value="#{selectedMember.memberName}"/>
<f:param name="blogId" value="#{latestBlog.blogId}"/>
- </s:link>)
+ </h:link>)
</div>
</ui:repeat>
- [<s:link id="viewBlog" view="/blog.xhtml" value="View all blog entries" propagation="none">
+ [<h:link id="viewBlog" outcome="/blog.xhtml" value="View all blog entries" propagation="none">
<f:param name="name" value="#{selectedMember.memberName}"/>
- </s:link>]
+ </h:link>]
- <s:span rendered="#{s:hasPermission(selectedMember, 'createBlog')}">
- [<s:link id="createBlog" action="#{blog.createEntry}" value="Create new blog entry" propagation="none"/>]
- </s:span>
- </s:div>
+ <ui:fragment rendered="#{identity.hasPermission(selectedMember, 'createBlog')}">
+ <span>
+ [<h:link id="createBlog" action="#{blog.createEntry}" value="Create new blog entry"/>]
+ </span>
+ </ui:fragment>
+ </div>
- <s:div id="memberFriends">
+ <div id="memberFriends">
<div class="sectionHeader">#{selectedMember.memberName}'s friends</div>
<ui:repeat value="#{profile.friends}" var="f">
<div class="friend">
- <s:link view="/profile.xhtml" propagation="none">
+ <h:link outcome="/profile.xhtml">
<f:param name="name" value="#{f.memberName}"/>
#{f.memberName}<br/>
<h:graphicImage value="/content/images?id=#{f.picture.imageId}&width=90"/>
- </s:link>
+ </h:link>
</div>
</ui:repeat>
<br class="clear"/>
- <s:span rendered="#{selectedMember.memberId != authenticatedMember.memberId and s:hasPermission(selectedMember, 'createFriendRequest')}">
- [<s:link view="/friendrequest.xhtml" action="#{friendAction.createRequest}" value="Send a friend request"/>]
- </s:span>
+ <ui:fragment rendered="#{selectedMember.memberId != authenticatedMember.memberId and identity.hasPermission(selectedMember, 'createFriendRequest')}">
+ <span>
+ [<h:link outcome="/friendrequest.xhtml" action="#{friendAction.createRequest}" value="Send a friend request"/>]
+ </span>
+ </ui:fragment>
- </s:div>
+ </div>
- <s:div id="friendComments">
+ <div id="friendComments">
<div class="sectionHeader">#{selectedMember.memberName}'s friend's comments</div>
<ui:repeat value="#{profile.friendComments}" var="c">
<table class="friendComments">
<tr>
<td class="friendCommentor">
- <s:link view="/profile.xhtml">
+ <h:link outcome="/profile.xhtml">
<f:param name="name" value="#{c.friend.memberName}"/>
#{c.friend.memberName}<br/>
<h:graphicImage value="/content/images?id=#{c.friend.picture.imageId}&width=90"/>
- </s:link>
+ </h:link>
</td>
<td style="text-align: left">
<b>#{c.formattedCommentDate}</b><br/>
- <p><s:formattedText value="#{c.comment}"/></p>
+ <p><h:outputText value="#{c.comment}"/></p>
</td>
</tr>
</table>
</ui:repeat>
- <s:span rendered="#{s:hasPermission(selectedMember, 'createFriendComment')}">
- [<s:link view="/friendcomment.xhtml" value="Add Comment"/>]
- </s:span>
- </s:div>
- </s:div>
+ <ui:fragment rendered="#{identity.hasPermission(selectedMember, 'createFriendComment')}">
+ <span>
+ [<h:link outcome="/friendcomment.xhtml" value="Add Comment"/>]
+ </span>
+ </ui:fragment>
+ </div>
+
+ </ui:fragment>
</ui:define>
Modified: modules/security/trunk/examples/seamspace/src/main/webapp/template.xhtml
===================================================================
--- modules/security/trunk/examples/seamspace/src/main/webapp/template.xhtml 2010-03-31 01:35:01 UTC (rev 12335)
+++ modules/security/trunk/examples/seamspace/src/main/webapp/template.xhtml 2010-03-31 02:58:12 UTC (rev 12336)
@@ -19,7 +19,7 @@
<div class="headerMenu">
<ui:fragment rendered="#{identity.loggedIn}">
- <h:link id="profile" view="/profile.xhtml" value="My Profile" propagation="none">
+ <h:link id="profile" outcome="/profile.xhtml" value="My Profile" propagation="none">
<f:param name="name" value="#{authenticatedMember.memberName}"/>
</h:link>
<h:outputText styleClass="divider" value=" | "/>
@@ -50,7 +50,7 @@
</div>
<div id="menubar">
- <h:link view="/home.xhtml" value="Home" propagation="none"/><h:outputText styleClass="divider" value=" | "/>
+ <h:link outcome="/home.xhtml" value="Home"/><h:outputText styleClass="divider" value=" | "/>
<h:link value="Browse" onclick="javascript:alert('This feature coming soon!');return false"/><h:outputText styleClass="divider" value=" | "/>
<h:link value="Blog" onclick="javascript:alert('This feature coming soon!');return false"/><h:outputText styleClass="divider" value=" | "/>
<h:link value="Music" onclick="javascript:alert('This feature coming soon!');return false"/>
More information about the seam-commits
mailing list