Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

MessageBoard Submission #7

Closed
wants to merge 2 commits into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 26, 2012
  1. @TimKrippner

    first try

    TimKrippner authored
Commits on Mar 27, 2012
  1. @TimKrippner

    Final Submission with completed work.

    TimKrippner authored
    Tim and Max.
This page is out of date. Refresh to see the latest.
View
8 MessageBoard/src/edu/gac/mcs270/messageboard/client/MessageBoard.java
@@ -1,5 +1,6 @@
package edu.gac.mcs270.messageboard.client;
+import java.util.Date;
import java.util.List;
import edu.gac.mcs270.messageboard.shared.Message;
@@ -75,9 +76,7 @@ public void onModuleLoad() {
@Override
public void onClick(ClickEvent event) {
messageStore.storeMessage(
- new Message(
- authorField.getText(),
- textField.getText()),
+ new Message(authorField.getText(), textField.getText(), new Date()),
new AsyncCallback<Void>(){
@Override
public void onFailure(Throwable caught) {
@@ -136,6 +135,9 @@ public void onSuccess(List<Message> result) {
Label body = new Label(m.getText());
body.addStyleName("messageBody");
messagesPanel.insert(body, position++);
+ Label date = new Label(m.getDate());
+ body.addStyleName("messageDate");
+ messagesPanel.insert(date, position++);
}
if(!result.isEmpty()){
nextID = result.get(0).getId() + 1;
View
4 MessageBoard/src/edu/gac/mcs270/messageboard/server/MessageStoreImpl.java
@@ -37,9 +37,9 @@ public void storeMessage(Message msg) {
PersistenceManager pm = pmf.getPersistenceManager();
Query query = pm.newQuery(Message.class);
query.declareParameters("Long minimumID");
- query.setFilter("id >= minimumID");
+ query.setFilter("id >= minimumID"); //limit to new messages
query.setOrdering("id descending");
- if(minimumID == 1){
+ if(minimumID == 1){ //keeps initial updates fast
query.setRange(0, MessageStore.INITIAL_LIMIT);
}
@SuppressWarnings("unchecked")
View
10 MessageBoard/src/edu/gac/mcs270/messageboard/shared/Message.java
@@ -1,6 +1,7 @@
package edu.gac.mcs270.messageboard.shared;
import java.io.Serializable;
+import java.util.Date;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
@@ -21,6 +22,9 @@
@Persistent
private String text;
+
+ @Persistent
+ private Date date;
@PrimaryKey
@Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
@@ -30,9 +34,10 @@
* @param author the name of the Message's author
* @param text the body of the Message
*/
- public Message(String author, String text) {
+ public Message(String author, String text, Date date) {
this.author = author;
this.text = text;
+ this.date = date;
}
/**
@@ -49,6 +54,9 @@ public String getText() {
return text;
}
+ public String getDate(){
+ return date.toString();
+ }
/**
* @return the id of this Message
*/
View
4 MessageBoard/war/WEB-INF/appengine-generated/datastore-indexes-auto.xml
@@ -1,8 +1,8 @@
-<!-- Indices written at Sat, 24 Mar 2012 19:02:37 UTC -->
+<!-- Indices written at Tue, 27 Mar 2012 16:51:37 UTC -->
<datastore-indexes>
- <!-- Used 6 times in query history -->
+ <!-- Used 104 times in query history -->
<datastore-index kind="Message" ancestor="false" source="auto">
<property name="__key__" direction="desc"/>
</datastore-index>
View
BIN  MessageBoard/war/WEB-INF/appengine-generated/local_db.bin
Binary file not shown
Something went wrong with that request. Please try again.