KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cayenne > tutorial > tapestry > pages > ChooseGalleryPage


1 package cayenne.tutorial.tapestry.pages;
2
3 import java.util.List JavaDoc;
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 /**
14  * @author Eric Schneider
15  */

16 public abstract class ChooseGalleryPage extends ApplicationPage {
17
18     // properties are defined as abstract setters and getters
19
// and are declared in ChooseGalleryPage.page file
20
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 JavaDoc value);
27     public abstract List JavaDoc getGalleryList();
28
29     public void savePaintingToGalleryAction(IRequestCycle cycle) {
30
31         getGallery().addToPaintingArray(getPainting());
32
33         // commit to the database
34
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