Author: olamy
Date: Tue Feb 28 20:47:29 2012
New Revision: 1294822

URL: http://svn.apache.org/viewvc?rev=1294822&view=rev
Log:
add expiresIn sample

Modified:
    
incubator/directmemory/trunk/examples/server-example/src/main/webapp/index.html
    
incubator/directmemory/trunk/examples/server-example/src/main/webapp/js/sample.js

Modified: 
incubator/directmemory/trunk/examples/server-example/src/main/webapp/index.html
URL: 
http://svn.apache.org/viewvc/incubator/directmemory/trunk/examples/server-example/src/main/webapp/index.html?rev=1294822&r1=1294821&r2=1294822&view=diff
==============================================================================
--- 
incubator/directmemory/trunk/examples/server-example/src/main/webapp/index.html 
(original)
+++ 
incubator/directmemory/trunk/examples/server-example/src/main/webapp/index.html 
Tue Feb 28 20:47:29 2012
@@ -49,6 +49,7 @@
 
               Wine Name:&nbsp<input type="text" id="wine_name" 
name="wine_name">
               Wine Description:&nbsp<input type="text" id="wine_description" 
name="wine_description">
+              ExpiresIn:&nbsp<input type="text" id="expires-in" 
name="expires-in">
               <br/>
               <button class="btn" id="put-cache-btn">Put</button>
 

Modified: 
incubator/directmemory/trunk/examples/server-example/src/main/webapp/js/sample.js
URL: 
http://svn.apache.org/viewvc/incubator/directmemory/trunk/examples/server-example/src/main/webapp/js/sample.js?rev=1294822&r1=1294821&r2=1294822&view=diff
==============================================================================
--- 
incubator/directmemory/trunk/examples/server-example/src/main/webapp/js/sample.js
 (original)
+++ 
incubator/directmemory/trunk/examples/server-example/src/main/webapp/js/sample.js
 Tue Feb 28 20:47:29 2012
@@ -41,14 +41,15 @@ $(function() {
     clearResultContent();
     $("#result-content" 
).html($("#alert-message-warning").tmpl({message:msg}));
   }
+
   // X-DirectMemory-ExpiresIn
-  putWineInCache=function(wine){
+  putWineInCache=function(wine,expiresIn){
     $.ajax({
       url: 'cache/'+encodeURIComponent(wine.name),
       data:$.toJSON( wine ),
       cache: false,
-      type: 'POST',
-      //dataType: 'text',
+      type: 'PUT',
+      headers:{'X-DirectMemory-ExpiresIn':expiresIn},
       contentType: "text/plain",
       statusCode: {
         204: function() {
@@ -92,7 +93,12 @@ $(function() {
         displayError("name mandatory");
         return;
       }
-      putWineInCache(wine);
+      var expiresIn=$("#expires-in").val()?$("#expires-in").val():0;
+      if( $.trim(expiresIn).length>0 && !$.isNumeric($.trim(expiresIn))){
+        displayError("expiresIn must be a number");
+        return;
+      }
+      putWineInCache(wine,expiresIn);
 
     });
 


Reply via email to