1 package org.apache.velocity.demo.action; 2 3 18 19 import java.util.*; 20 21 import javax.servlet.http.HttpServlet ; 22 import javax.servlet.http.HttpServletRequest ; 23 import javax.servlet.http.HttpServletResponse ; 24 25 import org.apache.velocity.context.Context; 26 import org.apache.velocity.app.tools.*; 27 28 import org.apache.velocity.demo.om.*; 29 30 37 public class ListCommand extends Command 38 { 39 40 public static final String LIST = "list.vm"; 41 42 public ListCommand( HttpServletRequest req, HttpServletResponse resp ) 43 { 44 super( req, resp ); 45 } 46 47 51 public String exec( Context ctx ) 52 { 53 Object [] list = ForumDatabase.listAll(); 54 55 if ( list == null || list.length == 0 ) 56 { 57 ctx.put("hasMessages", Boolean.FALSE ); 58 } 59 else 60 { 61 ctx.put("hasMessages", Boolean.TRUE ); 62 ctx.put("listall", list ); 63 } 64 65 return LIST; 66 } 67 } 68 69 | Popular Tags |