incubator-isis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From danhayw...@apache.org
Subject svn commit: r1231662 [1/11] - in /incubator/isis/trunk/examples/onlinedemo: dom/src/main/java/org/apache/isis/examples/onlinedemo/dom/items/ webapp/src/main/webapp/generic/ webapp/src/main/webapp/jqmobile/ webapp/src/main/webapp/jquery.mobile/ webapp/s...
Date Sun, 15 Jan 2012 12:54:24 GMT
Author: danhaywood
Date: Sun Jan 15 12:54:23 2012
New Revision: 1231662

URL: http://svn.apache.org/viewvc?rev=1231662&view=rev
Log:
ISIS-170: started work on jqmobile demo for onlinedemo

Added:
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/generic/
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/generic/index.html
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery/
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/ajax-loader.png
  (with props)
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-18-black.png
  (with props)
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-18-white.png
  (with props)
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-36-black.png
  (with props)
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-36-white.png
  (with props)
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/jquery.mobile-1.0.css
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/jquery.mobile-1.0.js
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/jquery.mobile-1.0.min.css
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/jquery.mobile-1.0.min.js
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/jquery.mobile.structure-1.0.css
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/jquery.mobile.structure-1.0.min.css
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.tmpl/
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.tmpl/jquery.tmpl-vBeta1.0.0.js
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.tmpl/jquery.tmpl-vBeta1.0.0.min.js
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery/jquery-1.6.4.js
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery/jquery-1.6.4.min.js
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery/jquery-1.7.1.js
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery/jquery-1.7.1.min.js
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/mobile/
      - copied from r1228331, incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jqmobile/
Removed:
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jqmobile/
Modified:
    incubator/isis/trunk/examples/onlinedemo/dom/src/main/java/org/apache/isis/examples/onlinedemo/dom/items/Categories.java
    incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/mobile/index.html

Modified: incubator/isis/trunk/examples/onlinedemo/dom/src/main/java/org/apache/isis/examples/onlinedemo/dom/items/Categories.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/onlinedemo/dom/src/main/java/org/apache/isis/examples/onlinedemo/dom/items/Categories.java?rev=1231662&r1=1231661&r2=1231662&view=diff
==============================================================================
--- incubator/isis/trunk/examples/onlinedemo/dom/src/main/java/org/apache/isis/examples/onlinedemo/dom/items/Categories.java
(original)
+++ incubator/isis/trunk/examples/onlinedemo/dom/src/main/java/org/apache/isis/examples/onlinedemo/dom/items/Categories.java
Sun Jan 15 12:54:23 2012
@@ -33,6 +33,7 @@ import org.apache.isis.applib.annotation
  * The implementation depends on the configured object store.
  */
 @Hidden
+@Named("Categories")
 public interface Categories {
 
     @QueryOnly // no side-effects

Added: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/generic/index.html
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/generic/index.html?rev=1231662&view=auto
==============================================================================
--- incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/generic/index.html (added)
+++ incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/generic/index.html Sun
Jan 15 12:54:23 2012
@@ -0,0 +1,471 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+
+<html> 
+<head> 
+   <script type="text/javascript" src="../jquery/jquery-1.6.4.js"></script>
+   <script type="text/javascript" src="../jquery.tmpl/jquery.tmpl-vBeta1.0.0.js"></script>
+
+   <style>
+       ul 
+       {
+           padding: 0;
+       }
+       
+       div.actions 
+       {
+	        float: left;
+	        width: 400px;
+       }
+       
+       .actions li 
+       {
+           list-style-type: none;
+       }
+
+       dl.properties-and-collections
+        {
+	        float: left;
+	        width: 780px;
+	        margin: 1em 0;
+	        padding: 0;
+	        border-bottom: 1px solid #999;
+        }
+
+        .properties-and-collections dt
+        {
+	        clear: left;
+	        float: left;
+	        width: 300px;
+	        margin: 0;
+	        padding: 5px;
+	        border-top: 1px solid #999;
+            text-align: right;
+	        font-weight: bold;
+	        color: green;
+        }
+
+        .properties-and-collections dt:after
+        {
+            content: ":";
+        }
+
+        .properties-and-collections dd
+        {
+	        float: left;
+	        width: 300px;
+	        margin: 0;
+	        padding: 5px;
+	        border-top: 1px solid #999;
+        }
+        
+        .clear 
+        {
+            clear: both;
+        }
+   </style>
+  <script type="text/javascript"> 
+  
+  // [START] Code specific to this app
+$(function () { $('#Find').submit(findObject) });
+
+$(function () { $('#serviceMenu').click(getServices) });
+  
+  getServices = function() {
+    var div = $('#objects').empty();
+	var server = $('#Find input#server').val(); 
+	var url = 'http://'+server+'/services/';
+
+    var username = $('#Find input#username').val(); 
+    var password = $('#Find input#password').val(); 
+
+	//TODO: Factor out function below
+    $.ajax({
+      url: url,
+      dataType: 'json',
+      username: username,
+      password: password,
+      success: function(data) { 
+          var html = listRepAsHtml(data);
+          div.append(html);
+      }
+    });
+	
+
+
+	return false; //To stop event bubbling up
+  }
+  
+  findObject = function() {
+	var server = $('#Find input#server').val();
+	var oid = $('#Find input#oid').val();
+	getObject('http://'+server+'/objects/'+oid);
+	return false; //To stop event bubbling up
+  }
+// [END] Code specific to this app
+
+// Generic library methods below
+
+  bindLinks = function () {
+      $(".property a").click(linkToObject);
+      $(".collection a").click(linkToCollection);
+      $(".action a").click(linkToAction);
+  };
+
+
+  createLink = function(href, label, onClick) {
+    var link = $('<a href="' + href + '">'+label+'</a>');
+	link.click(onClick);
+	return link;
+  }
+  
+  linkToObject = function() {
+	getObject($(this)[0].href);
+	return false; //To stop event bubbling up
+  }
+  
+  linkToCollection = function () {
+    getCollection($(this)[0].href);
+    return false; //To stop event bubbling up
+  }
+
+  linkToAction = function() {
+    getAction($(this)[0].href);
+    return false; //To stop event bubbling up
+  }
+  
+  //TODO: Factor out common logic between this and linkToActionInvokePost
+  //Ideally, we could store the method (GET/POST/PUT) as an Html 5 attribute on the
+  //<a> link and use that.
+  linkToActionInvokeGet = function() {
+	//TODO: See comment within linkToActionInvokePost (below)
+
+	var arguments = $('#objects form').serialize(); //TODO:  Use $.param() instead of serialize?
+	var button = $('#objects form button');
+    invokeActionWithGet(button[0].href, '?'+arguments);
+    return false; //To stop event bubbling up
+  }
+  
+  linkToActionInvokePost = function() {
+	//TODO: Not the intended design!  We really want to pass in the actual
+	// form that was submitted, and extract the button/href from there, but
+	// I couldn't get that to work.  This (naive) approach assumes there is only one
+	// form & one button in the objects div.
+	var button = $('#objects form button');
+	var input = $('#objects form input');
+	var arguments = {};
+	if (input.length > 0) {
+		for (var j = 0; j < input.length; j++) {
+			var value = input.val();
+			arguments[input[j].name] = value;
+		}
+	}
+    invokeActionWithPost(button[0].href, arguments);
+    return false; //To stop event bubbling up
+  }
+ 
+  getObject = function(url) {
+
+    var username = $('#Find input#username').val(); 
+    var password = $('#Find input#password').val(); 
+	
+    $.ajax({
+      url: url,
+      dataType: 'json',
+      username: username,
+      password: password,
+      success: function (data) {
+            renderObject(data)
+        }
+    });
+	
+  }
+
+  renderObject = function (objectRep) {
+      var objects = $("#objects").empty();
+      objects.append(objectRepAsHtml(objectRep, true, true));
+      bindLinks();
+  }
+  
+  getCollection = function (url) {
+    var username = $('#Find input#username').val(); 
+    var password = $('#Find input#password').val(); 
+
+	$.ajax({
+      url: url,
+      dataType: 'json',
+      username: username,
+      password: password,
+      success: function (data) {
+            var objects = $("#objects").empty();
+            objects.append(collectionRepAsHtml(data));
+        }
+    });
+  }
+  
+  getAction = function (url) {
+
+    var username = $('#Find input#username').val(); 
+    var password = $('#Find input#password').val(); 
+
+    $.ajax({
+      url: url,
+      username: username,
+      password: password,
+      success: function (data) { 
+            if (data.parameters.length == 0) { //Zero-parameter actions invoked immediately
+            var invokeLink = getLinkRep(data, 'invoke');
+                var url = invokeLink.href;
+                switch (invokeLink.method)
+                {
+                    case 'GET':
+                        invokeActionWithGet(url);
+                        break;
+                    case 'POST':
+                        invokeActionWithPost(url);
+                        break;
+                    case 'PUT':
+                        alert('PUT method not currently supported in this context');
+                        break;
+                }   
+            } else { //Actions with params rendered as a dialog
+                var objects = $("#objects").empty();
+                objects.append(actionRepAsHtml(data));
+            }
+        } 
+    });
+	
+  } 
+  
+  //TODO: This and next method could be merged, with the type (method) passed in as a 
+  //param (values defined on an Enum). Would be better to always treat arguments as a
+  //map, and url-encode it for the GET case.
+  //See also comment on linkToActionInvokeGet.
+  invokeActionWithGet = function (url, arguments) {
+
+    var username = $('#Find input#username').val(); 
+    var password = $('#Find input#password').val(); 
+
+    $.ajax( {
+	    type: 'GET',
+		url: url+arguments, 
+        username: username,
+        password: password,
+		success: function (data) { 
+			var objects = $("#objects").empty();
+			objects.append(actionResultRepAsHtml(data));
+		},
+		dataType:'json'
+	});
+  }
+  
+  invokeActionWithPost = function (url, arguments) {
+    if (arguments != null) {
+		alert("POST actions with parameters not yet supported");
+	}
+	
+	var username = $('#Find input#username').val(); 
+    var password = $('#Find input#password').val(); 
+	
+    $.ajax( { 
+			type: 'POST',
+			url: url,
+			data: arguments,
+            username: username,
+            password: password,
+			success: function (data) { 
+				var objects = $("#objects").empty();
+				objects.append(actionResultRepAsHtml(data));
+			}, 
+			dataType:'json'
+	});
+  }
+  
+  actionResultRepAsHtml = function (data) {
+	var html = $('<div>');
+	//TODO:  Make more use of the other information in links
+	switch (data.resulttype) {
+		case 'list':
+			html.append(listRepAsHtml(data.result));
+			break;
+		case 'object':
+			html.append(objectRepAsHtml(data.result, true, true));
+			break;
+		default:
+			alert(data.resulttype +' result type not supported at present');
+			break;
+	}
+	html.append('</div>');
+    return html;	
+  }
+ 
+  listRepAsHtml = function (data) {
+	var html = $('<div>');
+	var items = data.value;
+    for (var j = 0; j < items.length; j++) {
+        html.append(createLink(items[j].href, items[j].title, linkToObject));
+        html.append("<br>");
+    }   
+	html.append('</div>');
+    return html;	
+  }
+
+  objectRepAsHtml = function (data, includeProperties, includeActions) {
+
+      var result = $('<div>');
+      var objectRep = {
+          title: data.title,
+          members: data.members,
+          includeProperties: includeProperties,
+          includeActions: includeActions
+      };
+
+      $("#objectRepAsHtml-tmpl").tmpl(objectRep).appendTo(result);
+
+      return result;
+  }
+
+  collectionRepAsHtml = function (data) {
+      var result = $('<div>');
+      //TODO: Factor out next two lines into createParentLink -  used in next method also
+      var parentLink = getLinkRep(data, 'up');
+      if (!parentLink) {
+          parentLink = getLinkRep(data, 'parent'); // HACK: remove this.
+      }
+      result.append(createLink(parentLink.href, 'Back To Parent', linkToObject));
+      result.append('<br><h3>' + data.id + '</h3>');
+      result.append(listRepAsHtml(data));
+      result.append('</div>');
+      return result;
+  }
+
+  actionRepAsHtml = function (data) {
+	var form = $('<form id="'+data.id+'"></form>'); //TODO:  Form id needs to be
improved
+	var parentLink = getLinkRep(data, 'up');
+	if (!parentLink) {
+	    parentLink = getLinkRep(data, 'parent'); // HACK: remove this.
+	}
+	form.append(createLink(parentLink.href, 'Back To Parent', linkToObject));
+	form.append('<br><h3>' + data.id + '</h3>');
+	var params = data.parameters;
+    for (var j = 0; j < params.length; j++) {
+        form.append(params[j].name+' ');
+		form.append('<input type="text" name="'+params[j].name+'">');
+        form.append('<br>');
+    }    
+	var invokeLink = getLinkRep(data, 'invoke');
+	var button = $('<button href="'+invokeLink.href +'">OK</button>');
+	form.append(button);
+	switch (invokeLink.method)
+	{
+		//TODO: Refactor so that method is held as an Html attribute on the <a> link
+		case 'GET':
+			form.submit(linkToActionInvokeGet);
+			break;
+		case 'POST':
+			form.submit(linkToActionInvokePost);
+			break;
+		default:
+			alert(invokeLink.method+' method not currently supported by this viewer');
+		    break;
+	}	
+	return form;
+  }
+
+  actionMemberAsHtml = function (member) {
+    var result = $('<dt class="action">');
+    result.append(member.id);
+    result.append('<\dt>');
+
+    result.append('<dd class="action">')
+    result.append(createLink(member.links[0].href, member.id, linkToAction));
+    return result.append('<\dd>');
+  }
+  
+  getLinkRep = function(objectWithLinks, rel) {
+    var result;
+	var links = objectWithLinks.links;
+     for (var j = 0; j < links.length; j++) {
+	   if (links[j].rel == rel) {
+	     result = links[j];
+	   }
+	 }
+	 return result;
+  }
+  </script> 
+</head> 
+
+<body> 
+
+ <form id="Find" action="#">
+  <h3>Navigate directly to an object:</h3>
+  User:<input type = "text" id="username" value="sven">
+  Password: <input type = "text" id="password" value="pass">
+  <br>
+  Server:<input type = "text" id="server" value="localhost:8080">
+  OId: <input type = "text" id="oid" value="OID:1" size="50">
+  <br>
+  <button id ="ok">OK</button>
+  </form>
+
+  <br/>
+  <h3><a href="" id="serviceMenu">Main Menu</a></h3>
+  <div id="objects"></div>
+
+    <script id="objectRepAsHtml-tmpl" type="text/x-jquery-tmpl">
+        <div>
+            <br><h3>${title}</h3></br>
+
+        {{if includeActions}}
+            <div class="actions">
+            <ul>
+              {{each members}}
+                {{if $value.memberType == 'action' }}
+                  {{tmpl($value) "#actionMemberAsHtml-tmpl" }}
+                {{/if}}
+              {{/each}}
+            </ul>
+            </div>
+        {{/if}}
+
+        {{if includeProperties}}
+            <dl class="properties-and-collections">
+
+              {{each members }}
+                {{if $value.memberType == 'property'}}
+                    {{tmpl($value) "#propertyMemberAsHtml-tmpl" }}
+                {{/if}}
+                {{if $value.memberType == 'collection'}}
+                    {{tmpl($value) "#collectionMemberAsHtml-tmpl" }}
+                {{/if}}
+              {{/each}}
+
+            </dl>
+            <div class="clear"/>
+        {{/if}}
+
+        </div>
+    </script>
+
+    <script id="propertyMemberAsHtml-tmpl" type="text/x-jquery-tmpl">
+        <dt class='property'>${id}</dt>
+        <dd class='property'>
+            {{if value.href}}
+              <a href="${value.href}">${value.title}</a>
+            {{else}}
+              ${value}
+            {{/if}}
+        </dd>
+    </script>
+
+    <script id="collectionMemberAsHtml-tmpl" type="text/x-jquery-tmpl">
+        <dt class='collection'>${id}</dt>
+        <dd class='collection'><a href="${links[0].href}">Collection Contents</a></dd>
+    </script>
+
+    <script id="actionMemberAsHtml-tmpl" type="text/x-jquery-tmpl">
+        <li class='action'><a href="${links[0].href}">${id}</a></li>
+    </script>
+
+</body> 
+
+</html>

Added: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/ajax-loader.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/ajax-loader.png?rev=1231662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/ajax-loader.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-18-black.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-18-black.png?rev=1231662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-18-black.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-18-white.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-18-white.png?rev=1231662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-18-white.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-36-black.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-36-black.png?rev=1231662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-36-black.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-36-white.png
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-36-white.png?rev=1231662&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/isis/trunk/examples/onlinedemo/webapp/src/main/webapp/jquery.mobile/images/icons-36-white.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message