[seam-commits] Seam SVN: r7616 - in trunk/src/main/org/jboss/seam: navigation and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Tue Mar 18 15:10:20 EDT 2008


Author: norman.richards at jboss.com
Date: 2008-03-18 15:10:20 -0400 (Tue, 18 Mar 2008)
New Revision: 7616

Modified:
   trunk/src/main/org/jboss/seam/navigation/Header.java
   trunk/src/main/org/jboss/seam/navigation/Page.java
   trunk/src/main/org/jboss/seam/navigation/Pages.java
   trunk/src/main/org/jboss/seam/pages-2.1.xsd
Log:
JBSEAM-273

Modified: trunk/src/main/org/jboss/seam/navigation/Header.java
===================================================================
--- trunk/src/main/org/jboss/seam/navigation/Header.java	2008-03-18 18:46:20 UTC (rev 7615)
+++ trunk/src/main/org/jboss/seam/navigation/Header.java	2008-03-18 19:10:20 UTC (rev 7616)
@@ -22,7 +22,7 @@
     }
     
     public void sendHeader(HttpServletResponse response) {
-        response.addHeader(name, evaluateValue());
+        sendHeader(response, name, evaluateValue());
     }
     
     private String evaluateValue() {
@@ -38,4 +38,14 @@
         
         return result;
     }
+    
+    
+    public static void sendHeader(HttpServletResponse response, 
+                                  String name,
+                                  String value)
+    {
+        if (response !=null && name !=null && value != null) {
+            response.addHeader(name, value);
+        }
+    }
 }

Modified: trunk/src/main/org/jboss/seam/navigation/Page.java
===================================================================
--- trunk/src/main/org/jboss/seam/navigation/Page.java	2008-03-18 18:46:20 UTC (rev 7615)
+++ trunk/src/main/org/jboss/seam/navigation/Page.java	2008-03-18 19:10:20 UTC (rev 7616)
@@ -1,6 +1,8 @@
 package org.jboss.seam.navigation;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -21,6 +23,8 @@
  */
 public final class Page
 {
+   public static final String RFC_1123_DATE = "EEE, dd MMM yyyy HH:mm:ss zzz";
+
    private final String viewId;
    private String description;
    private Integer timeout;
@@ -42,6 +46,8 @@
    private List<Pattern> rewritePatterns = new ArrayList<Pattern>();
    private List<Header> httpHeaders = new ArrayList<Header>();
    
+   private Integer expires;
+
    /**
     * The scheme (http/https) required by this page.
     */
@@ -299,8 +305,20 @@
         for (Header header: httpHeaders) {
             header.sendHeader(response);
         }
+        
+        if (expires != null) {
+            Header.sendHeader(response, 
+                              "Expires", 
+                              rfc1123Date(new Date(System.currentTimeMillis()+expires)));
+        }
     }
    
+    private String rfc1123Date(Date when) {
+        SimpleDateFormat format = new SimpleDateFormat(RFC_1123_DATE);
+       
+        return format.format(when);
+    }
+
    public List<Input> getInputs()
    {
       return inputs;
@@ -399,4 +417,8 @@
         return httpHeaders;
     }
 
+    public void setExpires(Integer expires) {
+        this.expires = expires;   
+    }
+
 }

Modified: trunk/src/main/org/jboss/seam/navigation/Pages.java
===================================================================
--- trunk/src/main/org/jboss/seam/navigation/Pages.java	2008-03-18 18:46:20 UTC (rev 7615)
+++ trunk/src/main/org/jboss/seam/navigation/Pages.java	2008-03-18 19:10:20 UTC (rev 7616)
@@ -1053,11 +1053,16 @@
          page.setTimeout(Integer.parseInt(timeoutString));
       }
       
-      page.setNoConversationViewId( element.attributeValue("no-conversation-view-id") );
-      page.setConversationRequired( "true".equals( element.attributeValue("conversation-required") ) );
-      page.setLoginRequired( "true".equals( element.attributeValue("login-required") ) );
-      page.setScheme( element.attributeValue("scheme") );
+      page.setNoConversationViewId(element.attributeValue("no-conversation-view-id"));
+      page.setConversationRequired("true".equals(element.attributeValue("conversation-required")));
+      page.setLoginRequired("true".equals(element.attributeValue("login-required")));
+      page.setScheme(element.attributeValue("scheme"));
       
+      String expiresValue = element.attributeValue("expires");
+      if (expiresValue != null) {
+           page.setExpires(Integer.parseInt(expiresValue));
+      }
+      
       ConversationIdParameter param = conversations.get( element.attributeValue("conversation") );
       if (param != null) page.setConversationIdParameter(param);
       

Modified: trunk/src/main/org/jboss/seam/pages-2.1.xsd
===================================================================
--- trunk/src/main/org/jboss/seam/pages-2.1.xsd	2008-03-18 18:46:20 UTC (rev 7615)
+++ trunk/src/main/org/jboss/seam/pages-2.1.xsd	2008-03-18 19:10:20 UTC (rev 7616)
@@ -100,6 +100,7 @@
         <xs:attribute name="timeout"/>
         <xs:attribute name="bundle"/>
         <xs:attribute name="conversation"/>
+        <xs:attribute name="expires" /> 
     </xs:attributeGroup>
     <xs:element name="param">
         <xs:complexType>




More information about the seam-commits mailing list