1 package cayenne.tutorial.tapestry.pages; 2 3 import java.util.List ; 4 5 import org.apache.tapestry.IRequestCycle; 6 import org.apache.tapestry.event.PageEvent; 7 import org.objectstyle.cayenne.query.Ordering; 8 import org.objectstyle.cayenne.query.SelectQuery; 9 10 import cayenne.tutorial.tapestry.domain.Gallery; 11 import cayenne.tutorial.tapestry.domain.Painting; 12 13 18 public abstract class BrowseGalleriesPage extends ApplicationPage { 19 20 public abstract void setGallery(Gallery value); 23 public abstract Gallery getGallery(); 24 25 public abstract void setPainting(Painting value); 26 public abstract Painting getPainting(); 27 28 public abstract void setGalleryList(List value); 29 public abstract List getGalleryList(); 30 31 public void removePaintingAction(IRequestCycle cycle) { 32 getGallery().removeFromPaintingArray(getPainting()); 33 34 getVisitDataContext().commitChanges(); 36 } 37 38 public void pageBeginRender(PageEvent event) { 39 if (getGalleryList() == null) { 41 SelectQuery query = new SelectQuery(Gallery.class); 42 query.addOrdering(new Ordering(Gallery.GALLERY_NAME_PROPERTY, Ordering.ASC)); 43 44 query.addPrefetch(Gallery.PAINTING_ARRAY_PROPERTY); 47 query.addPrefetch( 48 Gallery.PAINTING_ARRAY_PROPERTY + "." + Painting.TO_ARTIST_PROPERTY); 49 50 setGalleryList(getVisitDataContext().performQuery(query)); 51 } 52 } 53 } 54 | Popular Tags |