Get tracks directly from artist.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 14:01:25 +0000 (16:01 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 19 Apr 2012 14:01:25 +0000 (16:01 +0200)
src/main/java/net/pterodactylus/demoscenemusic/page/ArtistPage.java
src/main/resources/templates/artist

index e92726f..45ef5c9 100644 (file)
 
 package net.pterodactylus.demoscenemusic.page;
 
-import java.util.Collection;
-
 import net.pterodactylus.demoscenemusic.core.Core;
 import net.pterodactylus.demoscenemusic.data.Artist;
-import net.pterodactylus.demoscenemusic.data.Track;
 import net.pterodactylus.util.database.DatabaseException;
 import net.pterodactylus.util.template.Template;
 import net.pterodactylus.util.template.TemplateContext;
@@ -56,11 +53,7 @@ public class ArtistPage extends BasePage {
        protected void processTemplate(TemplateContext templateContext, ServletRequest request) throws RedirectException {
                try {
                        Artist artist = getCore().getDataManager().getArtistById(request.getServletRequest().getParameter("id"));
-                       if (artist != null) {
-                               Collection<Track> tracks = getCore().getDataManager().getTracksByArtist(artist.id());
-                               templateContext.set("artist", artist);
-                               templateContext.set("tracks", tracks);
-                       }
+                       templateContext.set("artist", artist);
                } catch (DatabaseException de1) {
                        /* TODO */
                }
index 655c4d8..9429468 100644 (file)
@@ -8,7 +8,7 @@
 
 <h2>Tracks by <% artist.name|html></h2>
 
-<%foreach tracks track|sort>
+<%foreach artist.tracks track|sort>
 <%first><ul><%/first>
 <li><a href="track?id=<% track.id|html>"><% track.name|html></a></li>
 <%last></ul><%/last>