[jboss-cvs] jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace ...
Shane Bryzak
Shane_Bryzak at symantec.com
Fri Dec 22 01:53:47 EST 2006
User: sbryzak2
Date: 06/12/22 01:53:47
Modified: examples/seamspace/src/org/jboss/seam/example/seamspace
Member.java ProfileAction.java ProfileLocal.java
Log:
added member card
Revision Changes Path
1.10 +87 -0 jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/Member.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: Member.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/Member.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- Member.java 21 Dec 2006 13:05:01 -0000 1.9
+++ Member.java 22 Dec 2006 06:53:46 -0000 1.10
@@ -1,6 +1,9 @@
package org.jboss.seam.example.seamspace;
import java.io.Serializable;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.GregorianCalendar;
import java.util.Set;
import javax.persistence.Entity;
@@ -12,10 +15,12 @@
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
+import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;
import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;
+import org.hibernate.validator.Pattern;
import org.jboss.seam.annotations.Name;
/**
@@ -30,11 +35,30 @@
{
private static final long serialVersionUID = 5179242727836683375L;
+ public enum Gender {
+ male("Male"),
+ female("Female");
+
+ private String descr;
+ Gender(String descr) {
+ this.descr = descr;
+ }
+ public String getDescr() {
+ return descr;
+ }
+ };
+
private Integer memberId;
private String username;
private String password;
private String name;
private MemberImage picture;
+
+ private String tagline;
+ private Gender gender;
+ private Date dob;
+ private String location;
+
private Set<MemberRole> roles;
private Set<MemberImage> images;
@@ -75,6 +99,8 @@
@NotNull
@Length(min = 3, max = 40)
+ @Pattern(regex="[a-zA-Z]?[a-zA-Z0-9_]+",
+ message="Member name must start with a letter, and only contain letters, numbers or underscores")
public String getName()
{
return name;
@@ -109,6 +135,48 @@
this.picture = picture;
}
+ @NotNull
+ public Date getDob()
+ {
+ return dob;
+ }
+
+ public void setDob(Date dob)
+ {
+ this.dob = dob;
+ }
+
+ @NotNull
+ public Gender getGender()
+ {
+ return gender;
+ }
+
+ public void setGender(Gender gender)
+ {
+ this.gender = gender;
+ }
+
+ public String getLocation()
+ {
+ return location;
+ }
+
+ public void setLocation(String location)
+ {
+ this.location = location;
+ }
+
+ public String getTagline()
+ {
+ return tagline;
+ }
+
+ public void setTagline(String tagline)
+ {
+ this.tagline = tagline;
+ }
+
@OneToMany(mappedBy = "member", fetch = FetchType.LAZY)
public Set<MemberImage> getImages()
{
@@ -119,4 +187,23 @@
{
this.images = images;
}
+
+ @Transient
+ public String getAge()
+ {
+ Calendar birthday = new GregorianCalendar();
+ birthday.setTime(dob);
+ int by = birthday.get(Calendar.YEAR);
+ int bm = birthday.get(Calendar.MONTH);
+ int bd = birthday.get(Calendar.DATE);
+
+ Calendar now = new GregorianCalendar();
+ now.setTimeInMillis(System.currentTimeMillis());
+ int ny = now.get(Calendar.YEAR);
+ int nm = now.get(Calendar.MONTH);
+ int nd = now.get(Calendar.DATE);
+
+ int age = ny - by + (nm > bm || (nm == bm && nd >= bd) ? 0 : -1);
+ return String.format("%d years old", age);
+ }
}
1.5 +13 -6 jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/ProfileAction.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ProfileAction.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/ProfileAction.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- ProfileAction.java 22 Dec 2006 02:04:48 -0000 1.4
+++ ProfileAction.java 22 Dec 2006 06:53:46 -0000 1.5
@@ -1,19 +1,23 @@
package org.jboss.seam.example.seamspace;
-import javax.ejb.Stateless;
+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;
import org.jboss.seam.annotations.Factory;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.RequestParameter;
-import org.jboss.seam.core.FacesMessages;
+import org.jboss.seam.annotations.Scope;
import org.jboss.seam.security.Identity;
- at Stateless
+ at Stateful
@Name("profile")
+ at Scope(ScopeType.EVENT)
public class ProfileAction implements ProfileLocal
{
@RequestParameter
@@ -47,4 +51,7 @@
catch (NoResultException ex) { }
}
}
+
+ @Remove @Destroy
+ public void destroy() { }
}
1.2 +1 -0 jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/ProfileLocal.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ProfileLocal.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/examples/seamspace/src/org/jboss/seam/example/seamspace/ProfileLocal.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ProfileLocal.java 20 Dec 2006 11:40:25 -0000 1.1
+++ ProfileLocal.java 22 Dec 2006 06:53:46 -0000 1.2
@@ -6,4 +6,5 @@
public interface ProfileLocal
{
void display();
+ void destroy();
}
More information about the jboss-cvs-commits
mailing list