[seam-commits] Seam SVN: r10876 - in modules/trunk: view and 7 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Mon May 11 20:19:10 EDT 2009


Author: shane.bryzak at jboss.com
Date: 2009-05-11 20:19:10 -0400 (Mon, 11 May 2009)
New Revision: 10876

Added:
   modules/trunk/view/
   modules/trunk/view/pom.xml
   modules/trunk/view/src/
   modules/trunk/view/src/main/
   modules/trunk/view/src/main/java/
   modules/trunk/view/src/main/java/org/
   modules/trunk/view/src/main/java/org/jboss/
   modules/trunk/view/src/main/java/org/jboss/seam/
   modules/trunk/view/src/main/java/org/jboss/seam/view/
   modules/trunk/view/src/main/java/org/jboss/seam/view/Selector.java
Log:
add view module

Added: modules/trunk/view/pom.xml
===================================================================
--- modules/trunk/view/pom.xml	                        (rev 0)
+++ modules/trunk/view/pom.xml	2009-05-12 00:19:10 UTC (rev 10876)
@@ -0,0 +1,39 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+   <modelVersion>4.0.0</modelVersion>
+   
+   <parent>
+      <artifactId>seam-parent</artifactId>
+      <groupId>org.jboss.seam</groupId>
+      <version>3.0.0-SNAPSHOT</version>
+   </parent>
+
+   <artifactId>seam-view</artifactId>
+   <packaging>jar</packaging>
+   <version>3.0.0-SNAPSHOT</version>
+   <name>Seam View Module</name>
+
+   <dependencies>
+
+      <dependency>
+         <groupId>${webbeans.groupId}</groupId>
+         <artifactId>jsr299-api</artifactId>
+         <scope>provided</scope>
+      </dependency>
+
+      <dependency>
+         <groupId>${webbeans.groupId}</groupId>
+         <artifactId>webbeans-logging</artifactId>
+         <scope>provided</scope>
+      </dependency>
+      
+      <dependency>
+         <groupId>javax.servlet</groupId>
+         <artifactId>servlet-api</artifactId>
+         <scope>provided</scope>
+      </dependency>
+
+   </dependencies>
+
+</project>

Added: modules/trunk/view/src/main/java/org/jboss/seam/view/Selector.java
===================================================================
--- modules/trunk/view/src/main/java/org/jboss/seam/view/Selector.java	                        (rev 0)
+++ modules/trunk/view/src/main/java/org/jboss/seam/view/Selector.java	2009-05-12 00:19:10 UTC (rev 10876)
@@ -0,0 +1,138 @@
+package org.jboss.seam.view;
+
+import java.io.Serializable;
+
+import javax.servlet.http.Cookie;
+
+/**
+ * Support for selector objects which remember their selection as a cookie
+ * 
+ * @author Gavin King
+ * @author Shane Bryzak
+ */
+public abstract class Selector implements Serializable
+{
+   private static final long serialVersionUID = 8851522639722586279L;
+
+   /**
+    * 1 Year, in seconds
+    */
+   public static final int DEFAULT_MAX_AGE = 31536000;
+   
+   /**
+    * Is the cookie enabled
+    */
+   private boolean cookieEnabled;
+   
+   /**
+    * The maximum age of the cookie
+    */
+   private int cookieMaxAge = DEFAULT_MAX_AGE;
+   
+   /**
+    * The path of the cookie
+    */
+   private String cookiePath= "/";
+   
+   /**
+    * Is the cookie enabled?
+    * 
+    * @return false by default
+    */
+   public boolean isCookieEnabled()
+   {
+      return cookieEnabled;
+   }
+   
+   /**
+    * Sets the enabled status of the cookie 
+    * 
+    * @param cookieEnabled
+    */
+   public void setCookieEnabled(boolean cookieEnabled)
+   {
+      this.cookieEnabled = cookieEnabled;
+   }
+   
+   /**
+    * The max age of the cookie
+    * @return 1 year by default
+    */
+   public int getCookieMaxAge()
+   {
+      return cookieMaxAge;
+   }
+   
+   /**
+    * Sets the maximum age of the cookie
+    * 
+    * @param cookieMaxAge The maximum age of the cookie, in seconds
+    */
+   public void setCookieMaxAge(int cookieMaxAge)
+   {
+      this.cookieMaxAge = cookieMaxAge;
+   }
+   
+   /**
+    * Returns the path of the cookie.
+    * 
+    * @return String The cookie path 
+    */
+   public String getCookiePath()
+   {
+      return cookiePath;
+   }
+   
+   /**
+    * Sets the path of the cookie.
+    * 
+    * @param cookiePath The cookie path
+    */
+   public void setCookiePath(String cookiePath)
+   {
+      this.cookiePath = cookiePath;
+   }
+   
+   /**
+    * Override to define the cookie name
+    */
+   protected abstract String getCookieName();
+   
+   /**
+    * Get the value of the cookie, if this selector is enabled
+    * 
+    * @return String The value of the cookie if this selector is enabled, otherwise null.
+    */
+   protected String getCookieValueIfEnabled()
+   {
+      return isCookieEnabled() ? getCookieValue() : null;
+   }
+   
+   /**
+    * Returns the Cookie instance.
+    * 
+    * @return Cookie The cookie instance.
+    */
+   protected abstract Cookie getCookie();
+   
+   /**
+    * Returns the cookie value.
+    * 
+    * @return String The current value of the cookie.
+    */
+   protected String getCookieValue()
+   {
+      Cookie cookie = getCookie();
+      return cookie == null ? null : cookie.getValue();
+   }
+   
+   /**
+    * Clears the cookie value.
+    */
+   protected abstract void clearCookieValue();
+   
+   /**
+    * Sets the cookie value.
+    */
+   protected abstract void setCookieValueIfEnabled(String value);
+}
\ No newline at end of file




More information about the seam-commits mailing list