FileDocCategorySizeDatePackage
LookupMovieAction.javaAPI DocExample1863Sun Mar 02 09:25:10 GMT 2003com.mediamania.appserver

LookupMovieAction

public class LookupMovieAction extends org.apache.struts.action.Action

Fields Summary
PersistenceManagerFactory
pmf
PersistenceManager
pm
Constructors Summary
Methods Summary
public org.apache.struts.action.ActionForwardexecute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

       
         
         
         
          
        try {
            ServletContext ctx = getServlet().getServletContext();
            pmf = (PersistenceManagerFactory)ctx.getAttribute("jdo.Movies");
            pm = pmf.getPersistenceManager();
            Query q = pm.newQuery(Movie.class, "title == param1");
            q.declareParameters ("String param1");
            String movieName = request.getParameter("movieName");
            Collection movies = (Collection)q.execute(movieName);
            Movie movie = (Movie)movies.iterator().next();
            String description = movie.getDescription();
            ctx.setAttribute("movieDescription", description);
        } catch (JDOException e) {
        } finally {
            if (pm != null) {
                pm.close();
            }
            pm = null;
        }
        return (mapping.findForward("success"));