You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2006/06/11 18:57:06 UTC
svn commit: r413475 - in /tapestry/tapestry4/trunk: eclipse/
examples/TimeTracker/src/context/ examples/TimeTracker/src/context/WEB-INF/
examples/TimeTracker/src/java/org/apache/tapestry/timetracker/dao/
examples/TimeTracker/src/java/org/apache/tapestr...
Author: jkuhnert
Date: Sun Jun 11 09:57:05 2006
New Revision: 413475
URL: http://svn.apache.org/viewvc?rev=413475&view=rev
Log:
Checking in before starting on client side validation replacement
Added:
tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/dao/TaskDao.java
tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/model/Task.java
Modified:
tapestry/tapestry4/trunk/eclipse/TimeTracker.launch
tapestry/tapestry4/trunk/examples/TimeTracker/src/context/Home.html
tapestry/tapestry4/trunk/examples/TimeTracker/src/context/WEB-INF/Home.properties
tapestry/tapestry4/trunk/examples/TimeTracker/src/context/WEB-INF/timetracker.dao.xml
tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
tapestry/tapestry4/trunk/framework/src/descriptor/META-INF/tapestry.services.xml
tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/impl/JSONResponseContributorImpl.java
tapestry/tapestry4/trunk/framework/src/js/tests/widget/test_datetime.js
Modified: tapestry/tapestry4/trunk/eclipse/TimeTracker.launch
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/eclipse/TimeTracker.launch?rev=413475&r1=413474&r2=413475&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/eclipse/TimeTracker.launch (original)
+++ tapestry/tapestry4/trunk/eclipse/TimeTracker.launch Sun Jun 11 09:57:05 2006
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
+<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:tapestry/examples/TimeTracker}"/>
<booleanAttribute key="org.eclipse.jdt.debug.ui.INCLUDE_EXTERNAL_JARS" value="true"/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/tapestry"/>
</listAttribute>
-<stringAttribute key="org.eclipse.jdt.launching.WORKING_DIRECTORY" value="${workspace_loc:tapestry/examples/TimeTracker}"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER" javaProject="tapestry" path="1" type="4"/> "/>
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry id="org.eclipse.jdt.launching.classpathentry.defaultClasspath"> <memento exportedEntriesOnly="false" project="tapestry"/> </runtimeClasspathEntry> "/>
Modified: tapestry/tapestry4/trunk/examples/TimeTracker/src/context/Home.html
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/examples/TimeTracker/src/context/Home.html?rev=413475&r1=413474&r2=413475&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/examples/TimeTracker/src/context/Home.html (original)
+++ tapestry/tapestry4/trunk/examples/TimeTracker/src/context/Home.html Sun Jun 11 09:57:05 2006
@@ -12,13 +12,13 @@
<table width="90%" class="form" cellpadding="2" cellspacing="0" >
<tr>
<td><label jwcid="@FieldLabel" field="component:projectChoose" /></td>
- <td><label>Description</label></td>
+ <td><label jwcid="@FieldLabel" field="component:descriptionField" /></td>
<td><label>Duration</label></td>
<td> </td>
</tr>
<tr>
<td><div class="field required"><span jwcid="projectChoose" /></div></td>
- <td><div class="field"><input name="fm-lastname" id="fm-lastname" type="text" /></div></td>
+ <td><div class="field required"><input jwcid="descriptionField" /></div></td>
<td><div jwcid="duration@Any">18 minutes</div></td>
<td> </td>
</tr>
@@ -43,7 +43,7 @@
</div>
</td>
<td>
- <input jwcid="@Submit" value="message:button.add" class="submitButton" />
+ <input jwcid="@Submit" value="message:button.add" class="submitButton" action="listener:addTask" />
</td>
</tr>
Modified: tapestry/tapestry4/trunk/examples/TimeTracker/src/context/WEB-INF/Home.properties
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/examples/TimeTracker/src/context/WEB-INF/Home.properties?rev=413475&r1=413474&r2=413475&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/examples/TimeTracker/src/context/WEB-INF/Home.properties (original)
+++ tapestry/tapestry4/trunk/examples/TimeTracker/src/context/WEB-INF/Home.properties Sun Jun 11 09:57:05 2006
@@ -7,3 +7,4 @@
task.start.time=Start
task.end.time=End
task.duration=Duration
+task.description=Description
Modified: tapestry/tapestry4/trunk/examples/TimeTracker/src/context/WEB-INF/timetracker.dao.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/examples/TimeTracker/src/context/WEB-INF/timetracker.dao.xml?rev=413475&r1=413474&r2=413475&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/examples/TimeTracker/src/context/WEB-INF/timetracker.dao.xml (original)
+++ tapestry/tapestry4/trunk/examples/TimeTracker/src/context/WEB-INF/timetracker.dao.xml Sun Jun 11 09:57:05 2006
@@ -26,4 +26,12 @@
</invoke-factory>
</service-point>
+ <service-point id="TaskDao" interface="TaskDao" >
+ <invoke-factory service-id="hivemind.BuilderFactory">
+ <construct class="TaskDao" autowire-services="false">
+ <set-service property="connection" service-id="timetracker.db.HsqlConnection" />
+ </construct>
+ </invoke-factory>
+ </service-point>
+
</module>
Added: tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/dao/TaskDao.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/dao/TaskDao.java?rev=413475&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/dao/TaskDao.java (added)
+++ tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/dao/TaskDao.java Sun Jun 11 09:57:05 2006
@@ -0,0 +1,54 @@
+// Copyright Jun 11, 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.tapestry.timetracker.dao;
+
+import java.sql.PreparedStatement;
+
+import org.apache.tapestry.timetracker.model.Task;
+
+
+/**
+ * Manages DB operations for {@link Task}s.
+ *
+ * @author jkuhnert
+ */
+public class TaskDao extends BaseDao
+{
+
+ /**
+ * Adds a new task to the project.
+ * @param task
+ * The pre-populated task to add.
+ */
+ public void addTask(Task task)
+ {
+ PreparedStatement ps = null;
+
+ try {
+ ps = _conn.prepareStatement("insert into tasks (project_id, start_dt, end_dt, "
+ + "descr_txt) values (?, ?, ?, ?) ");
+ int x=0;
+ ps.setLong(++x, task.getProjectId());
+ ps.setTimestamp(++x, new java.sql.Timestamp(task.getStartDate().getTime()));
+ ps.setTimestamp(++x, new java.sql.Timestamp(task.getEndDate().getTime()));
+ ps.setString(++x, task.getDescription());
+ ps.execute();
+
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ try { if (ps != null) ps.close(); } catch (Exception e) { }
+ }
+ }
+}
Added: tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/model/Task.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/model/Task.java?rev=413475&view=auto
==============================================================================
--- tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/model/Task.java (added)
+++ tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/model/Task.java Sun Jun 11 09:57:05 2006
@@ -0,0 +1,158 @@
+// Copyright Jun 11, 2006 The Apache Software Foundation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+package org.apache.tapestry.timetracker.model;
+
+import java.io.Serializable;
+import java.util.Date;
+
+
+/**
+ * A time entry task for a {@link Project}.
+ *
+ * @author jkuhnert
+ */
+public class Task implements Serializable
+{
+ /** generated. */
+ private static final long serialVersionUID = 7257377128183799387L;
+
+ protected long _id;
+ protected long _projectId;
+ protected Date _startDate;
+ protected Date _endDate;
+ protected String _description;
+
+ public Task() { }
+
+ /**
+ * @return the description
+ */
+ public String getDescription()
+ {
+ return _description;
+ }
+
+ /**
+ * @param description the description to set
+ */
+ public void setDescription(String description)
+ {
+ _description = description;
+ }
+
+ /**
+ * @return the endDate
+ */
+ public Date getEndDate()
+ {
+ return _endDate;
+ }
+
+ /**
+ * @param endDate the endDate to set
+ */
+ public void setEndDate(Date endDate)
+ {
+ _endDate = endDate;
+ }
+
+ /**
+ * @return the id
+ */
+ public long getId()
+ {
+ return _id;
+ }
+
+
+ /**
+ * @param id the id to set
+ */
+ public void setId(long id)
+ {
+ _id = id;
+ }
+
+ /**
+ * @return the projectId
+ */
+ public long getProjectId()
+ {
+ return _projectId;
+ }
+
+ /**
+ * @param projectId the projectId to set
+ */
+ public void setProjectId(long projectId)
+ {
+ _projectId = projectId;
+ }
+
+ /**
+ * @return the startDate
+ */
+ public Date getStartDate()
+ {
+ return _startDate;
+ }
+
+ /**
+ * @param startDate the startDate to set
+ */
+ public void setStartDate(Date startDate)
+ {
+ _startDate = startDate;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int hashCode()
+ {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((_description == null) ? 0 : _description.hashCode());
+ result = prime * result + ((_endDate == null) ? 0 : _endDate.hashCode());
+ result = prime * result + (int) (_id ^ (_id >>> 32));
+ result = prime * result + (int) (_projectId ^ (_projectId >>> 32));
+ result = prime * result + ((_startDate == null) ? 0 : _startDate.hashCode());
+ return result;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (this == obj) return true;
+ if (obj == null) return false;
+ if (getClass() != obj.getClass()) return false;
+ final Task other = (Task) obj;
+ if (_description == null) {
+ if (other._description != null) return false;
+ } else if (!_description.equals(other._description)) return false;
+ if (_endDate == null) {
+ if (other._endDate != null) return false;
+ } else if (!_endDate.equals(other._endDate)) return false;
+ if (_id != other._id) return false;
+ if (_projectId != other._projectId) return false;
+ if (_startDate == null) {
+ if (other._startDate != null) return false;
+ } else if (!_startDate.equals(other._startDate)) return false;
+ return true;
+ }
+}
Modified: tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java?rev=413475&r1=413474&r2=413475&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java (original)
+++ tapestry/tapestry4/trunk/examples/TimeTracker/src/java/org/apache/tapestry/timetracker/page/TaskEntryPage.java Sun Jun 11 09:57:05 2006
@@ -27,9 +27,12 @@
import org.apache.tapestry.dojo.form.DropdownTimePicker;
import org.apache.tapestry.form.BeanPropertySelectionModel;
import org.apache.tapestry.form.IPropertySelectionModel;
+import org.apache.tapestry.form.TextField;
import org.apache.tapestry.html.BasePage;
import org.apache.tapestry.timetracker.dao.ProjectDao;
+import org.apache.tapestry.timetracker.dao.TaskDao;
import org.apache.tapestry.timetracker.model.Project;
+import org.apache.tapestry.timetracker.model.Task;
/**
@@ -69,6 +72,15 @@
public abstract DropdownTimePicker getEndPicker();
public abstract Date getEndTime();
+ @Component(type = "TextField", id = "descriptionField",
+ bindings = { "value=description",
+ "displayName=message:task.description"})
+ public abstract TextField getDescriptionField();
+ public abstract String getDescription();
+
+ @InjectObject("service:timetracker.dao.TaskDao")
+ public abstract TaskDao getTaskDao();
+
/**
* Selection model for projects.
* @return
@@ -88,5 +100,19 @@
{
_log.debug("projectSelected() " + getSelectedProject());
cycle.getResponseBuilder().updateComponent("projectDescription");
+ }
+
+ /**
+ * Invoked by form to add a new task.
+ */
+ public void addTask()
+ {
+ Task task = new Task();
+ task.setProjectId(getSelectedProject().getId());
+ task.setDescription(getDescription());
+ task.setStartDate(getStartTime());
+ task.setEndDate(getEndTime());
+
+ getTaskDao().addTask(task);
}
}
Modified: tapestry/tapestry4/trunk/framework/src/descriptor/META-INF/tapestry.services.xml
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/descriptor/META-INF/tapestry.services.xml?rev=413475&r1=413474&r2=413475&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/descriptor/META-INF/tapestry.services.xml (original)
+++ tapestry/tapestry4/trunk/framework/src/descriptor/META-INF/tapestry.services.xml Sun Jun 11 09:57:05 2006
@@ -231,6 +231,7 @@
<set-service property="localeManager" service-id="tapestry.request.RequestLocaleManager"/>
<set-object property="markupWriterSource" value="infrastructure:markupWriterSource"/>
<set-object property="webResponse" value="infrastructure:response"/>
+ <set-object property="webRequest" value="infrastructure:request"/>
</construct>
</invoke-factory>
</service-point>
Modified: tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/impl/JSONResponseContributorImpl.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/impl/JSONResponseContributorImpl.java?rev=413475&r1=413474&r2=413475&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/impl/JSONResponseContributorImpl.java (original)
+++ tapestry/tapestry4/trunk/framework/src/java/org/apache/tapestry/services/impl/JSONResponseContributorImpl.java Sun Jun 11 09:57:05 2006
@@ -20,6 +20,7 @@
import org.apache.tapestry.services.RequestLocaleManager;
import org.apache.tapestry.services.ResponseBuilder;
import org.apache.tapestry.services.ResponseContributor;
+import org.apache.tapestry.web.WebRequest;
import org.apache.tapestry.web.WebResponse;
/**
@@ -33,11 +34,13 @@
public static final String JSON_HEADER = "json";
- protected RequestLocaleManager _localeManager;
+ private RequestLocaleManager _localeManager;
- protected MarkupWriterSource _markupWriterSource;
+ private MarkupWriterSource _markupWriterSource;
- protected WebResponse _webResponse;
+ private WebResponse _webResponse;
+
+ private WebRequest _webRequest;
/**
* {@inheritDoc}
@@ -57,6 +60,8 @@
String parm = cycle.getParameter(JSON_HEADER);
if (parm != null && Boolean.valueOf(parm).booleanValue())
return true;
+ if (_webRequest.getHeader(JSON_HEADER) != null)
+ return true;
return false;
}
@@ -74,5 +79,10 @@
public void setWebResponse(WebResponse webResponse)
{
_webResponse = webResponse;
+ }
+
+ public void setWebRequest(WebRequest webRequest)
+ {
+ _webRequest = webRequest;
}
}
Modified: tapestry/tapestry4/trunk/framework/src/js/tests/widget/test_datetime.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/framework/src/js/tests/widget/test_datetime.js?rev=413475&r1=413474&r2=413475&view=diff
==============================================================================
--- tapestry/tapestry4/trunk/framework/src/js/tests/widget/test_datetime.js (original)
+++ tapestry/tapestry4/trunk/framework/src/js/tests/widget/test_datetime.js Sun Jun 11 09:57:05 2006
@@ -12,5 +12,5 @@
dt = new Date("03:00 am");
value = dojo.date.format(dt, "%I:%M %p");
- jum.assertTrue(value, value.indexOf("NaN") < 0);
+ jum.assertFalse(value, value.indexOf("NaN") < 0);
}