Abspielen! Framework 2.0: Wie werden mehrere Bilder angezeigt?
Ich muss eine Fotogalerie anzeigen. Also hier ist meine Vorlage:
@(photos: List[Photo])
@title = {
<bold>Gallery</bold>
}
@main(title,"photo"){
<ul class="thumbnails">
@for(photo <- photos) {
<li class="span3">
<a href="#" class="thumbnail">
<img src="@photo.path" alt="">
</a>
</li>
}
</ul>
}
Und hier ist meine Controller-Methode:
public static Result getPhotos() {
return ok(views.html.photo.gallery.render(Photo.get()));
}
Und hier ist meine Fotobohne:
@Entity
public class Photo extends Model {
@Id
public Long id;
@Required
public String label;
public String path;
public Photo(String path, String label) {
this.path = path;
this.label = label;
}
private static Finder<Long, Photo> find = new Finder<Long, Photo>(
Long.class, Photo.class);
public static List<Photo> get() {
return find.all();
}
public static Photo get(Long id) {
return find.byId(id);
}
public static void create(Photo photo) {
photo.save();
}
public static void delete(Long id) {
find.ref(id).delete();
}
}
Ich habe den absoluten Pfad des Fotos in das src-Attribut des img-Knotens eingetragen, aber es funktioniert nicht. Was ist der beste Weg, um dies zu erreichen?
PS: Bild befinden sich außerhalb der Spielanwendung.