Last active
December 13, 2015 16:58
-
-
Save tgrall/4944142 to your computer and use it in GitHub Desktop.
View call for blog on collated views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
View view = client.getView("brewery", "all_with_beers"); | |
Query query = new Query(); | |
query.setIncludeDocs(true).setLimit(100); | |
ViewResponse result = client.query(view, query); | |
ArrayList<HashMap<String, String>> items = | |
new ArrayList<HashMap<String, String>>(); | |
for(ViewRow row : result) { | |
HashMap<String, String> parsedDoc = gson.fromJson( | |
(String)row.getDocument(), HashMap.class); | |
HashMap<String, String> item = new HashMap<String, String>(); | |
item.put("id", row.getId()); | |
item.put("name", parsedDoc.get("name")); | |
item.put("type", parsedDoc.get("type")); | |
items.add(item); | |
} | |
request.setAttribute("items", items); | |
request.getRequestDispatcher("/WEB-INF/breweries/all.jsp") | |
.forward(request, response); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment