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 16 public abstract class ChooseGalleryPage extends ApplicationPage { 17 18 public abstract void setGallery(Gallery value); 21 public abstract Gallery getGallery(); 22 23 public abstract void setPainting(Painting value); 24 public abstract Painting getPainting(); 25 26 public abstract void setGalleryList(List value); 27 public abstract List getGalleryList(); 28 29 public void savePaintingToGalleryAction(IRequestCycle cycle) { 30 31 getGallery().addToPaintingArray(getPainting()); 32 33 getVisitDataContext().commitChanges(); 35 36 BrowseArtistsPage nextPage = 37 (BrowseArtistsPage) cycle.getPage("BrowseArtistsPage"); 38 cycle.activate(nextPage); 39 } 40 41 public void pageBeginRender(PageEvent event) { 42 SelectQuery query = new SelectQuery(Gallery.class); 43 Ordering ordering = new Ordering(Gallery.GALLERY_NAME_PROPERTY, Ordering.ASC); 44 query.addOrdering(ordering); 45 46 setGalleryList(getVisitDataContext().performQuery(query)); 47 } 48 } 49 | Popular Tags |