[seam-commits] Seam SVN: r8108 - in trunk/examples/seamspace: resources/WEB-INF and 3 other directories.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Sat May 3 11:00:24 EDT 2008
Author: shane.bryzak at jboss.com
Date: 2008-05-03 11:00:23 -0400 (Sat, 03 May 2008)
New Revision: 8108
Added:
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/PictureAction.java
trunk/examples/seamspace/view/pictureupload.xhtml
trunk/examples/seamspace/view/style/padlock.png
trunk/examples/seamspace/view/style/trash.png
Modified:
trunk/examples/seamspace/resources/META-INF/security-rules.drl
trunk/examples/seamspace/resources/WEB-INF/pages.xml
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberImage.java
trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java
trunk/examples/seamspace/view/pictures.xhtml
trunk/examples/seamspace/view/style/seamspace.css
Log:
support for image uploads
Modified: trunk/examples/seamspace/resources/META-INF/security-rules.drl
===================================================================
--- trunk/examples/seamspace/resources/META-INF/security-rules.drl 2008-05-03 11:52:07 UTC (rev 8107)
+++ trunk/examples/seamspace/resources/META-INF/security-rules.drl 2008-05-03 15:00:23 UTC (rev 8108)
@@ -91,6 +91,8 @@
check.grant();
end
+
+# This rule grants permission for users to create their own blog entries
rule CreateBlog
no-loop
activation-group "permissions"
@@ -102,6 +104,18 @@
check.grant();
end
+# This rule grants permission for users to upload pictures to their profile
+rule UploadImage
+ no-loop
+ activation-group "permissions"
+when
+ mbr: Member()
+ acct: MemberAccount(member.memberId == mbr.memberId)
+ check: PermissionCheck(target.memberId == mbr.memberId, action == "uploadImage", granted == false)
+then
+ check.grant();
+end
+
rule InsertMemberBlog
no-loop
activation-group "permissions"
Modified: trunk/examples/seamspace/resources/WEB-INF/pages.xml
===================================================================
--- trunk/examples/seamspace/resources/WEB-INF/pages.xml 2008-05-03 11:52:07 UTC (rev 8107)
+++ trunk/examples/seamspace/resources/WEB-INF/pages.xml 2008-05-03 15:00:23 UTC (rev 8108)
@@ -111,6 +111,14 @@
</navigation>
</page>
+ <page view-id="/pictureupload.xhtml">
+ <navigation from-action="#{pictureAction.savePicture}">
+ <redirect view-id="/pictures.xhtml">
+ <param name="name" value="#{authenticatedMember.memberName}"/>
+ </redirect>
+ </navigation>
+ </page>
+
<page view-id="/friendcomment.xhtml">
<param name="name" value="#{selectedMember.memberName}"/>
@@ -138,9 +146,9 @@
</page>
<page view-id="*">
- <!--navigation from-action="#{identity.logout}">
+ <navigation from-action="#{identity.logout}">
<redirect view-id="/home.xhtml"/>
- </navigation-->
+ </navigation>
<navigation from-action="#{blog.createComment}">
<redirect view-id="/comment.xhtml"/>
Modified: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberImage.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberImage.java 2008-05-03 11:52:07 UTC (rev 8107)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/MemberImage.java 2008-05-03 15:00:23 UTC (rev 8108)
@@ -8,8 +8,10 @@
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
+import javax.persistence.PostLoad;
import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.security.Restrict;
@Entity
@Name("memberImage")
@@ -76,4 +78,5 @@
{
this.data = data;
}
+
}
Added: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/PictureAction.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/PictureAction.java (rev 0)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/PictureAction.java 2008-05-03 15:00:23 UTC (rev 8108)
@@ -0,0 +1,41 @@
+package org.jboss.seam.example.seamspace;
+
+import static org.jboss.seam.ScopeType.CONVERSATION;
+
+import javax.persistence.EntityManager;
+
+import org.jboss.seam.annotations.Begin;
+import org.jboss.seam.annotations.In;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.Scope;
+import org.jboss.seam.core.Conversation;
+
+ at Scope(CONVERSATION)
+ at Name("pictureAction")
+public class PictureAction
+{
+ private MemberImage memberImage;
+
+ @In(required = false)
+ private Member authenticatedMember;
+
+ @In EntityManager entityManager;
+
+ @Begin
+ public void uploadPicture()
+ {
+ memberImage = new MemberImage();
+ memberImage.setMember(authenticatedMember);
+ }
+
+ public void savePicture()
+ {
+ entityManager.persist(memberImage);
+ Conversation.instance().end();
+ }
+
+ public MemberImage getMemberImage()
+ {
+ return memberImage;
+ }
+}
Modified: trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java
===================================================================
--- trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java 2008-05-03 11:52:07 UTC (rev 8107)
+++ trunk/examples/seamspace/src/org/jboss/seam/example/seamspace/RegisterAction.java 2008-05-03 15:00:23 UTC (rev 8108)
@@ -52,7 +52,6 @@
private byte[] picture;
private String pictureContentType;
- private String pictureFileName;
private boolean verified;
@@ -196,16 +195,6 @@
this.pictureContentType = contentType;
}
- public String getPictureFileName()
- {
- return pictureFileName;
- }
-
- public void setPictureFileName(String filename)
- {
- this.pictureFileName = filename;
- }
-
public boolean isVerified()
{
return verified;
Modified: trunk/examples/seamspace/view/pictures.xhtml
===================================================================
--- trunk/examples/seamspace/view/pictures.xhtml 2008-05-03 11:52:07 UTC (rev 8107)
+++ trunk/examples/seamspace/view/pictures.xhtml 2008-05-03 15:00:23 UTC (rev 8108)
@@ -24,15 +24,34 @@
<s:div rendered="#{selectedMember != null}">
<h1>#{selectedMember.memberName}'s pictures</h1>
-
- <ui:repeat value="#{memberImages}" var="img">
- <a href="content/images?id=#{img.imageId}" rel="lightbox[pictureset]" title="#{img.caption}">
- <h:graphicImage value="/content/images?id=#{img.imageId}&width=170"/>
- </a>
-
- </ui:repeat>
+ <div class="memberPictureCard">
+ <s:link view="/profile.seam" propagation="none">
+ #{selectedMember.memberName}<br/>
+ <h:graphicImage value="/content/images?id=#{selectedMember.picture.imageId}&width=90"/>
+ </s:link>
+
+ <s:span rendered="#{s:hasPermission(selectedMember, 'uploadImage')}">
+ [<s:link view="/pictureupload.xhtml" action="#{pictureAction.uploadPicture}" value="Upload picture" propagation="none"/>]
+ </s:span>
+
+ <br style="clear:both"/>
+ </div>
+ <div class="memberPictures">
+ <ui:repeat value="#{memberImages}" var="img">
+
+ <div class="thumbnail">
+ <a href="content/images?id=#{img.imageId}" rel="lightbox[pictureset]" title="#{img.caption}">
+ <h:graphicImage value="/content/images?id=#{img.imageId}&width=90" border="0"/>
+ </a>
+ <s:button view="/permissions.seam" styleClass="padlock"/>
+ <s:button styleClass="trash"/>
+ </div>
+
+ </ui:repeat>
+ </div>
+
</s:div>
</ui:define>
Added: trunk/examples/seamspace/view/pictureupload.xhtml
===================================================================
--- trunk/examples/seamspace/view/pictureupload.xhtml (rev 0)
+++ trunk/examples/seamspace/view/pictureupload.xhtml 2008-05-03 15:00:23 UTC (rev 8108)
@@ -0,0 +1,52 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<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">
+
+ <ui:composition template="template.xhtml">
+ <ui:define name="content">
+ <div id="contentMain">
+ <div class="errors"><h:messages globalOnly="true"/></div>
+
+ <h3>Upload Picture</h3>
+
+ <div>
+
+ <h:form styleClass="register" enctype="multipart/form-data">
+ <s:validateAll>
+
+ <div class="formRow">
+ <h:outputLabel for="caption">Caption</h:outputLabel>
+ <h:inputText id="caption" value="#{pictureAction.memberImage.caption}"/>
+ <div class="validationError"><h:message for="caption"/></div>
+ </div>
+
+
+ <div class="formRow">
+ <h:outputLabel for="picture">Picture</h:outputLabel>
+ <s:fileUpload id="picture" data="#{pictureAction.memberImage.data}"
+ contentType="#{pictureAction.memberImage.contentType}" />
+ <div class="validationError"><h:message for="picture"/></div>
+ </div>
+
+ </s:validateAll>
+
+ <div class="buttons">
+ <h:commandButton value="Upload" action="#{pictureAction.savePicture}" styleClass="formButton"/>
+ <s:button value="Cancel" propagation="end" view="/pictures.xhtml" styleClass="formButton">
+ <f:param name="name" value="#{authenticatedMember.memberName}"/>
+ </s:button>
+ </div>
+
+ </h:form>
+
+ <br class="clear"/>
+ </div>
+ </div>
+
+ </ui:define>
+
+ </ui:composition>
+</html>
Added: trunk/examples/seamspace/view/style/padlock.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/seamspace/view/style/padlock.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/examples/seamspace/view/style/seamspace.css
===================================================================
--- trunk/examples/seamspace/view/style/seamspace.css 2008-05-03 11:52:07 UTC (rev 8107)
+++ trunk/examples/seamspace/view/style/seamspace.css 2008-05-03 15:00:23 UTC (rev 8108)
@@ -557,3 +557,49 @@
float: right;
padding: 4px 8px 16px 2px;
}
+
+div.memberPictures {
+ float: right;
+ width: 600px;
+ margin-right: 10px;
+ padding: 2px;
+ background-color: #000000;
+ border: 1px solid #aaaaaa;
+ padding: 8px 8px 8px 8px;
+}
+
+div.memberPictureCard {
+ width: 140px;
+ float: left;
+ margin-left: 10px;
+ border: 2px solid #eeeeee;
+ background-color: #f5f5f5;
+ padding: 2px;
+ text-align: center;
+}
+
+div.thumbnail {
+ width: 110px;
+ background-color: #333333;
+ padding: 10px 10px 10px 10px;
+ margin: 8px 8px 8px 8px;
+ float: left;
+ text-align: center;
+}
+
+input.padlock {
+ background: url(padlock.png) top left no-repeat;
+ width: 14px;
+ height: 20px;
+ float: left;
+ border: 0px;
+ margin-left: 10px;
+}
+
+input.trash {
+ background: url(trash.png) top left no-repeat;
+ width: 20px;
+ height: 20px;
+ float: left;
+ border: 0px;
+}
\ No newline at end of file
Added: trunk/examples/seamspace/view/style/trash.png
===================================================================
(Binary files differ)
Property changes on: trunk/examples/seamspace/view/style/trash.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
More information about the seam-commits
mailing list