KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > action > ArtistPageAction


1 package action;
2
3 import java.util.List JavaDoc;
4
5 import javax.servlet.http.HttpServletRequest JavaDoc;
6 import javax.servlet.http.HttpServletResponse JavaDoc;
7
8 import org.apache.struts.action.Action;
9 import org.apache.struts.action.ActionForm;
10 import org.apache.struts.action.ActionForward;
11 import org.apache.struts.action.ActionMapping;
12 import org.objectstyle.cayenne.access.DataContext;
13 import org.objectstyle.cayenne.conf.ServletUtil;
14 import org.objectstyle.cayenne.query.Ordering;
15 import org.objectstyle.cayenne.query.SelectQuery;
16
17 import webtest.Artist;
18
19 public class ArtistPageAction extends Action {
20
21     public ActionForward execute(
22         ActionMapping mapping,
23         ActionForm form,
24         HttpServletRequest JavaDoc request,
25         HttpServletResponse JavaDoc response)
26         throws Exception JavaDoc {
27
28         DataContext ctxt =
29             ServletUtil.getSessionContext(request.getSession());
30
31         SelectQuery query = new SelectQuery(Artist.class);
32         Ordering ordering = new Ordering("artistName", Ordering.ASC);
33         query.addOrdering(ordering);
34
35         List JavaDoc artists = ctxt.performQuery(query);
36         request.setAttribute("artists", artists);
37
38         return mapping.findForward("success");
39     }
40 }
Popular Tags