Database Reference
In-Depth Information
Figure 12-9.
The Friends page
Listing 12-26.
The HTML Code Snippet for Displaying the List of Friends
<div class="col-md-3">
<h3>Current Friends</h3>
<table class="table" id="following">
{{#graphStory.following}}
<tr>
<td>{{firstname}} {{lastname}}</td>
<td><a href="#" id="{{username}}" class="removefriend">Remove</a></td>
</tr>
{{/graphStory.following}}
{{^graphStory.following}}
No friends :(
{{/graphStory.following}}
</table>
</div>
To search for users to follow, the
searchByUsername
method contains a
GET
route
/searchbyusername
and passes
in a username value as part of the path. This route executes the
searchNotFollowing
method found in
UserDAO
class,
showing the second section of Listing 12-27.
The first part of the
WHERE
clause in
searchNotFollowing
returns users whose username matches on a wildcard
String value. The second part of the
WHERE
clause in
searchNotFollowing
checks to make sure that the users in the
MATCH
clause are not already being followed by the current user.
Listing 12-27.
The
searchByUsername
Route and Service Method
@Action(value = "searchbyusername/{username}",
results = {@Result(name = "success", type = "json")})
public String searchByUsername() {
try {