-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathPublicline.java
More file actions
108 lines (102 loc) · 3.93 KB
/
Publicline.java
File metadata and controls
108 lines (102 loc) · 3.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
package example;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import example.models.Timeline;
import example.models.Tweet;
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.PropertyModel;
import org.wyki.cassandra.pelops.UuidHelper;
/**
* This is the default home page when not logged in.
* It contains the 40 most recent global tweets.
*/
public class Publicline extends HomePage {
private String username;
private Long nextpage;
public Publicline(final PageParameters parameters) {
super(parameters);
nextpage = parameters.getAsLong("nextpage");
username = parameters.getString("username");
if (username == null) {
username = "!PUBLIC!";
add(new Label("h2name", "Public"));
}
else {
add(new Label("h2name", username + "'s"));
}
Timeline timeline = getUserline(username, nextpage);
List<Tweet> tweets = timeline.getView();
if (tweets.size() > 0) {
add(new ListView<Tweet>("tweetlist", tweets) {
@Override
public void populateItem(final ListItem<Tweet> listitem) {
listitem.add(new Link("link") {
@Override
public void onClick() {
PageParameters p = new PageParameters();
p.put("username", listitem.getModel().getObject().getUname());
setResponsePage(Publicline.class, p);
}
}.add(new Label("tuname",listitem.getModel().getObject().getUname())));
listitem.add(new Label("tbody", ": " + listitem.getModel().getObject().getBody()));
}
}).setVersioned(false);
Long linktopaginate = timeline.getNextview();
if (linktopaginate != null) {
nextpage = linktopaginate;
WebMarkupContainer pagediv = new WebMarkupContainer("pagedown");
PageForm pager = new PageForm("pageform");
pagediv.add(pager);
add(pagediv);
}
else {
add(new WebMarkupContainer("pagedown") {
@Override
public boolean isVisible() {
return false;
}
});
}
}
else {
ArrayList<String> hack = new ArrayList<String>(1);
hack.add("There are no tweets yet. Log in and post one!");
add(new ListView<String>("tweetlist", hack ) {
@Override
public void populateItem(final ListItem<String> listitem) {
listitem.add(new Link("link") {
@Override
public void onClick() {
}
}.add(new Label("tuname","")));
listitem.add(new Label("tbody", listitem.getModel().getObject()));
}
}).setVersioned(false);
add(new WebMarkupContainer("pagedown") {
@Override
public boolean isVisible() {
return false;
}
});
}
}
private class PageForm extends Form {
public PageForm(String id) {
super(id);
}
@Override
public void onSubmit() {
PageParameters p = new PageParameters();
p.put("nextpage", nextpage);
setResponsePage(getPage().getClass(), p);
}
}
}