Author: jharting
Date: 2009-05-05 10:28:40 -0400 (Tue, 05 May 2009)
New Revision: 10788
Added:
branches/community/Seam_2_1/examples/tasks/view/contexts.js
branches/community/Seam_2_1/examples/tasks/view/contexts.xhtml
branches/community/Seam_2_1/examples/tasks/view/img/
branches/community/Seam_2_1/examples/tasks/view/img/bg.png
branches/community/Seam_2_1/examples/tasks/view/img/task-delete.png
branches/community/Seam_2_1/examples/tasks/view/img/task-done.png
branches/community/Seam_2_1/examples/tasks/view/img/task-edit.png
branches/community/Seam_2_1/examples/tasks/view/img/task-undo.png
branches/community/Seam_2_1/examples/tasks/view/img/tasks-logo.png
branches/community/Seam_2_1/examples/tasks/view/index.html
branches/community/Seam_2_1/examples/tasks/view/login.xhtml
branches/community/Seam_2_1/examples/tasks/view/resolved.js
branches/community/Seam_2_1/examples/tasks/view/resolved.xhtml
branches/community/Seam_2_1/examples/tasks/view/style.css
branches/community/Seam_2_1/examples/tasks/view/tasks.js
branches/community/Seam_2_1/examples/tasks/view/tasks.xhtml
branches/community/Seam_2_1/examples/tasks/view/template.xhtml
Log:
seam tasks example client part
Added: branches/community/Seam_2_1/examples/tasks/view/contexts.js
===================================================================
--- branches/community/Seam_2_1/examples/tasks/view/contexts.js
(rev 0)
+++ branches/community/Seam_2_1/examples/tasks/view/contexts.js 2009-05-05 14:28:40 UTC
(rev 10788)
@@ -0,0 +1,30 @@
+$(document).ready(function() {
+ // load context list
+ getContexts(function(data) {
+ $(data).find('context').each(function() {
+ var contextName = $(this).find('name').text();
+ addContext(contextName);
+ });
+ });
+ // create new context on submit
+ $('#editContextSubmit').click(function(event) {
+ event.preventDefault();
+ var contextName = $('#editContextName').attr('value');
+ putContext(contextName, function() {
+ addContext(contextName);
+ $('#editContextName').attr('value', '');
+ });
+ });
+});
+
+function addContext(contextName) {
+ var nameCell = $('<td/>').addClass('name').text(contextName);
+ var deleteButton = $('<img/>').attr('src',
'img/task-delete.png').attr('title', 'Delete this
context').click(function(event) {
+ event.preventDefault();
+ deleteContext(contextName, function() {
+ $('#' + contextName).remove();
+ });
+ });
+ var buttonCell = $('<td/>').append(deleteButton);
+ $('<tr/>').attr('id',
contextName).append(buttonCell).append(nameCell).appendTo('#contexts tbody');
+}
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/view/contexts.js
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/view/contexts.xhtml
===================================================================
--- branches/community/Seam_2_1/examples/tasks/view/contexts.xhtml
(rev 0)
+++ branches/community/Seam_2_1/examples/tasks/view/contexts.xhtml 2009-05-05 14:28:40 UTC
(rev 10788)
@@ -0,0 +1,27 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
template="template.xhtml">
+
+ <ui:define name="head">
+ <script src="contexts.js" type="text/javascript" />
+ </ui:define>
+ <ui:define name="body">
+ <table id="contexts">
+ <thead>
+ <tr><td
colspan="2"><h2>Contexts</h2></td></tr>
+ </thead>
+ <tbody/>
+ </table>
+
+ <hr />
+
+ <form action="" id="newContextForm">
+ <h2>Care for a new context?</h2>
+ <input id="editContextName" type="text" />
+ <input id="editContextSubmit" type="button"
value="Create" />
+ </form>
+ </ui:define>
+</ui:composition>
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/view/contexts.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/view/img/bg.png
===================================================================
(Binary files differ)
Property changes on: branches/community/Seam_2_1/examples/tasks/view/img/bg.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/community/Seam_2_1/examples/tasks/view/img/task-delete.png
===================================================================
(Binary files differ)
Property changes on: branches/community/Seam_2_1/examples/tasks/view/img/task-delete.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/community/Seam_2_1/examples/tasks/view/img/task-done.png
===================================================================
(Binary files differ)
Property changes on: branches/community/Seam_2_1/examples/tasks/view/img/task-done.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/community/Seam_2_1/examples/tasks/view/img/task-edit.png
===================================================================
(Binary files differ)
Property changes on: branches/community/Seam_2_1/examples/tasks/view/img/task-edit.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/community/Seam_2_1/examples/tasks/view/img/task-undo.png
===================================================================
(Binary files differ)
Property changes on: branches/community/Seam_2_1/examples/tasks/view/img/task-undo.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/community/Seam_2_1/examples/tasks/view/img/tasks-logo.png
===================================================================
(Binary files differ)
Property changes on: branches/community/Seam_2_1/examples/tasks/view/img/tasks-logo.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/community/Seam_2_1/examples/tasks/view/index.html
===================================================================
--- branches/community/Seam_2_1/examples/tasks/view/index.html
(rev 0)
+++ branches/community/Seam_2_1/examples/tasks/view/index.html 2009-05-05 14:28:40 UTC
(rev 10788)
@@ -0,0 +1,5 @@
+<html>
+<head>
+ <meta http-equiv="Refresh" content="0; URL=tasks.seam">
+</head>
+</html>
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/view/index.html
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/view/login.xhtml
===================================================================
--- branches/community/Seam_2_1/examples/tasks/view/login.xhtml
(rev 0)
+++ branches/community/Seam_2_1/examples/tasks/view/login.xhtml 2009-05-05 14:28:40 UTC
(rev 10788)
@@ -0,0 +1,25 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+ template="template.xhtml">
+
+ <ui:define name="body">
+ <h:form id="login">
+ <h2>Welcome to Seam Tasks.</h2>
+ <div>
+ <h:outputLabel value="Username" for="username" />
+ <h:inputText id="username" value="#{credentials.username}"
/>
+ </div>
+ <div>
+ <h:outputLabel value="Password" for="password" />
+ <h:inputSecret id="password" value="#{credentials.password}"
/>
+ </div>
+ <div><h:messages/></div>
+ <div><h:commandButton action="#{identity.login}"
value="Login" /></div>
+ </h:form>
+ <div id="rightPanel">Welcome to Seam Tasks application. This
application demonstrates integration of Seam and RESTEasy. Please log in to see more. You
can use demo/demo for user account or admin/password for admin account.</div>
+ </ui:define>
+</ui:composition>
Property changes on: branches/community/Seam_2_1/examples/tasks/view/login.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/view/resolved.js
===================================================================
--- branches/community/Seam_2_1/examples/tasks/view/resolved.js
(rev 0)
+++ branches/community/Seam_2_1/examples/tasks/view/resolved.js 2009-05-05 14:28:40 UTC
(rev 10788)
@@ -0,0 +1,68 @@
+var firstTask = 0;
+var maxResults = 25;
+var username;
+
+
+$(document).ready(function() {
+ username = $('#username').text();
+
+ // next and previous buttons
+ $('.next').click(function(event) {
+ event.preventDefault();
+ firstTask += maxResults;
+ loadTasks();
+ });
+ $('.previous').click(function(event) {
+ event.preventDefault();
+ firstTask -= maxResults;
+ loadTasks();
+ });
+
+ loadTasks();
+});
+
+function loadTasks() {
+ $('#tasks tbody').empty();
+ getResolvedTasks(username, firstTask, maxResults, function(data) {
+ var tasks = $(data).find('task');
+ tasks.each(function() {
+ addTask($(this));
+ })
+ // pagination handling
+ if (tasks.size() == maxResults) {
+ $('.next').show();
+ } else {
+ $('.next').hide();
+ }
+ if (firstTask >= maxResults) {
+ $('.previous').show();
+ } else {
+ $('.previous').hide();
+ }
+ });
+}
+
+function addTask(task) {
+ var taskId = $(task).find('id').text();
+ var taskName = $(task).find('name').text();
+ var contextName = $(task).find('context').text();
+ var taskCompleted = $(task).find('completed').text();
+
+ var parent = $('#tasks tbody');
+ var nameCell = $('<td/>').addClass('name').text(taskName);
+ var completedCell =
$('<td/>').addClass('completed').text(taskCompleted);
+ var undoButton = $('<img/>').attr('src',
'img/task-undo.png').attr('title', 'Undo this
task').click(function(event) {
+ event.preventDefault();
+ putTask(contextName, taskId, taskName, false, function() {
+ $('#' + taskId).remove();
+ });
+ });
+ var deleteButton = $('<img/>').attr('src',
'img/task-delete.png').attr('title', 'Delete this
task').click(function(event) {
+ event.preventDefault();
+ deleteTask(contextName, taskId, true, function() {
+ $('#' + taskId).remove();
+ });
+ });
+ var buttonCell = $('<td/>').append(undoButton).append(deleteButton);
+ $('<tr/>').attr('id',
taskId).append(buttonCell).append(nameCell).append(completedCell).appendTo(parent);
+}
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/view/resolved.js
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/view/resolved.xhtml
===================================================================
--- branches/community/Seam_2_1/examples/tasks/view/resolved.xhtml
(rev 0)
+++ branches/community/Seam_2_1/examples/tasks/view/resolved.xhtml 2009-05-05 14:28:40 UTC
(rev 10788)
@@ -0,0 +1,27 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+ template="template.xhtml">
+
+<ui:define name="head">
+ <script src="resolved.js" type="text/javascript" />
+</ui:define>
+<ui:define name="body">
+ <table id="tasks">
+ <thead>
+ <tr>
+ <td colspan="3"><h2>Hooray, resolved
tasks!</h2></td>
+ </tr>
+ </thead>
+ <tbody/>
+ <tfoot>
+ <tr>
+ <td class="previous">Previous</td><td
class="next">Next</td>
+ </tr>
+ </tfoot>
+ </table>
+</ui:define>
+</ui:composition>
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/view/resolved.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/view/style.css
===================================================================
--- branches/community/Seam_2_1/examples/tasks/view/style.css (rev
0)
+++ branches/community/Seam_2_1/examples/tasks/view/style.css 2009-05-05 14:28:40 UTC (rev
10788)
@@ -0,0 +1,129 @@
+body {
+ background: white url(img/bg.png) repeat scroll center;
+ font-family: Verdana, Arial;
+ margin: 0;
+ padding: 0;
+}
+
+div.container
+{
+ background: white url(img/tasks-logo.png) no-repeat left top;
+ background-position:20px 20px;
+ width: 666px;
+ margin: 0 auto;
+ padding: 0;
+}
+
+/* header */
+div.header {
+ padding: 0;
+ height: 140px;
+}
+
+/* image replacemement header */
+div.header h1 {
+ display: none;
+}
+
+#menu {
+ display: block;
+ margin: 110px 0 0 100px;
+ float:left;
+}
+
+#menu li
+{
+ margin-left: 10px;
+ margin-right: 10px;
+ float:left;
+ display: inline;
+ font-size: 14px;
+}
+
+#menu a {
+ color: #899ea6;
+ text-decoration:none;
+ font-weight: bold;
+}
+
+#menu a:hover {
+ color:#99ccff;
+ text-decoration:none;
+ font-weight: bold;
+}
+
+
+/* content */
+
+hr {
+ width: 626px;
+ border: solid #dedede 1px;
+ border-bottom: none;
+}
+
+table
+{
+ border: none;
+ margin: 20px;
+ width: 626px;
+}
+
+#login
+{
+ float: left;
+ margin: 20px;
+ width: 326px;
+}
+
+#login div {
+ margin: 10px;
+}
+
+#login label {
+ display: block;
+}
+
+#rightPanel {
+ width: 280px;
+ margin-top: 30px;
+ margin-right: 20px;
+ float: right;
+}
+
+table td.name {
+ color: #99ccff;
+ font-weight: bold;
+}
+
+h2
+{
+ margin: 0;
+ padding:0;
+ color: #899ea6;
+}
+
+#newTask, #newContextForm {
+ margin: 10px 20px 10px 20px;
+}
+
+/* footer */
+#footer a
+{
+ color: #99ccff;
+ text-decoration:none;
+ font-weight: bold;
+}
+
+#footer {
+ width: 646px;
+ height: 35px;
+ text-align: center;
+ margin: 0 auto;
+ padding: 0;
+ clear: both;
+}
+
+#footer div {
+ font-size: 11px;
+ margin: 0 20px 2px 0;
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/view/style.css
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/view/tasks.js
===================================================================
--- branches/community/Seam_2_1/examples/tasks/view/tasks.js (rev
0)
+++ branches/community/Seam_2_1/examples/tasks/view/tasks.js 2009-05-05 14:28:40 UTC (rev
10788)
@@ -0,0 +1,97 @@
+$(document).ready(function() {
+ printContexts();
+ $('#editTaskSubmit').click(function() {
+ var name = $('#editTaskName').val();
+ var contextName = $('#editTaskContext').val()
+ postTask(contextName, name, function(location) {
+ $('#editTaskName').val('');
+ $.get(location, function(data) {
+ addTask($(data).find('task'), contextName);
+ });
+ });
+ });
+});
+
+function showTaskEditForm(contextName, taskId) {
+ var contexts = $('#editTaskContext').clone();
+ $(contexts).find('[value=' + contextName + ']').attr('selected',
'selected');
+ var taskName = $('#' + taskId + " .name").text();
+ var name = $('<input/>').attr('type',
'text').addClass('nameField').val(taskName);
+
+ var update = $('<input/>').attr('type',
'button').attr('id',
'update').val('Update').click(function() {
+ var newContextName = $(contexts).val();
+ var callback = function(data) {
+ removeTaskEditForm(taskId, taskName);
+ if (contextName == newContextName) {
+ updateTaskNameOnUI(taskId, data); // just update the name
+ } else {
+ $('#' + taskId).remove(); // add the task into new context
+ addTask(data, newContextName);
+ }
+ }
+ putTask(newContextName, taskId, $(name).val(), false, callback);
+ });
+ var form = $('<form/>').attr('id',
'updateTask').append(contexts).append(name).append(update);
+ $('#' + taskId + ' .name').replaceWith(form);
+}
+
+function removeTaskEditForm(taskId, taskName) {
+ $('#' + taskId + '
form').replaceWith($('<span/>').addClass('name').text(taskName));
+}
+
+function printContexts() {
+ getContexts(function(data) {
+ $(data).find('context').each(function() {
+ addContext($(this));
+ });
+ });
+}
+
+function addContext(context) {
+ var contextName = $(context).find('name').text();
+ var escapedContextName = escape(contextName);
+ var contextCell = $('<td/>').attr('colspan',
'2').addClass('name').text(contextName);
+ var contextRow = $('<tr/>').attr('id',
contextName).append(contextCell);
+ $('#contexts tbody').append(contextRow).appendTo('#contexts');
+ $('<option/>').attr('value',
contextName).text(contextName).appendTo('#editTaskContext');
+ getTasksForContext(contextName, false, function(data) {
+ $(data).find('task').each(function() {
+ addTask($(this), contextName);
+ });
+ });
+}
+
+function addTask(task, contextName) {
+ var taskId = $(task).find('id').text();
+ var taskName = $(task).find('name').text();
+
+ var parent = $('[id=' + contextName + ']');
+ var nameCell =
$('<td/>').append($('<span/>').addClass('name').text(taskName));
+ var doneButton = $('<img/>').attr('src',
'img/task-done.png').attr('title', 'Resolve this
task').click(function(event) {
+ event.preventDefault();
+ putTask(contextName, taskId, taskName, true, function() {
+ $('#' + taskId).remove();
+ });
+ });
+ var editButton = $('<img/>').attr('src',
'img/task-edit.png').attr('title', 'Edit this
task').click(function(event) {
+ event.preventDefault();
+ if ($('#' + taskId + ' #updateTask').size() == 0) {
+ showTaskEditForm(contextName, taskId);
+ } else {
+ removeTaskEditForm(taskId, taskName);
+ }
+ });
+ var deleteButton = $('<img/>').attr('src',
'img/task-delete.png').attr('title', 'Delete this
task').click(function(event) {
+ event.preventDefault();
+ deleteTask(contextName, taskId, false, function() {
+ $('#' + taskId).remove();
+ });
+ });
+ var buttonCell =
$('<td/>').append(doneButton).append(editButton).append(deleteButton);
+ $('<tr/>').attr('id',
taskId).append(buttonCell).append(nameCell).insertAfter('[id=' + contextName +
']');
+}
+
+function updateTaskNameOnUI(taskId, task) {
+ var taskName = $(task).find('name').text();
+ $('#' + taskId + " .name").text(taskName);
+}
Property changes on: branches/community/Seam_2_1/examples/tasks/view/tasks.js
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/view/tasks.xhtml
===================================================================
--- branches/community/Seam_2_1/examples/tasks/view/tasks.xhtml
(rev 0)
+++ branches/community/Seam_2_1/examples/tasks/view/tasks.xhtml 2009-05-05 14:28:40 UTC
(rev 10788)
@@ -0,0 +1,29 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+ template="template.xhtml">
+
+ <ui:define name="head">
+ <script src="tasks.js" type="text/javascript" />
+ </ui:define>
+
+ <ui:define name="body">
+ <table id="contexts">
+ <thead>
+ <tr>
+ <td colspan="2"><h2>Yet, unresolved
tasks.</h2></td>
+ </tr>
+ </thead>
+ <tbody/>
+ </table>
+ <hr/>
+ <form id="newTask">
+ <h2>Create new task</h2>
+ <select id="editTaskContext" /> <input
id="editTaskName" type="text" />
+ <input id="editTaskSubmit" type="button"
value="Create" />
+ </form>
+ </ui:define>
+</ui:composition>
\ No newline at end of file
Property changes on: branches/community/Seam_2_1/examples/tasks/view/tasks.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: branches/community/Seam_2_1/examples/tasks/view/template.xhtml
===================================================================
--- branches/community/Seam_2_1/examples/tasks/view/template.xhtml
(rev 0)
+++ branches/community/Seam_2_1/examples/tasks/view/template.xhtml 2009-05-05 14:28:40 UTC
(rev 10788)
@@ -0,0 +1,45 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<f:view
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:s="http://jboss.com/products/seam/taglib"
contentType="text/html">
+ <html>
+ <head>
+ <meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
+ <title>Seam Tasks</title>
+ <script
+
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js&q...
+ type="text/javascript" />
+ <script src="seam-tasks-client.js"
type="text/javascript" />
+ <link href="style.css" rel="stylesheet"
type="text/css" />
+ <ui:insert name="head" />
+ </head>
+ <body >
+ <div class="container">
+ <div class="header">
+ <h1>Seam Tasks</h1>
+ <s:div rendered="#{identity.loggedIn}">
+ <ul id="menu">
+ <li><a
href="tasks.seam">Tasks</a></li>
+ <li><a
href="contexts.seam">Contexts</a></li>
+ <li><a href="resolved.seam">Resolved
tasks</a></li>
+ <li>
+ <s:link id="menuLogoutId"
action="#{identity.logout}" value="Logout"
propagation="none" />
+ </li>
+ <li>Logged as: <h:outputText id="username"
value="#{credentials.username}" /></li>
+ </ul>
+ </s:div>
+ </div>
+ <div id="content">
+ <ui:insert name="body" />
+ </div>
+ <div id="footer">
+ <hr/>
+ <div>Powered by Seam 2.1, RESTEasy, Hibernate, Facelets and jQuery.
Find more at <span><a
href="http://seamframework.org">seamframework.org</a></span></div>
+ </div>
+ </div>
+ </body>
+ </html>
+</f:view>
Property changes on: branches/community/Seam_2_1/examples/tasks/view/template.xhtml
___________________________________________________________________
Name: svn:mime-type
+ text/plain