1 package org.apache.velocity.demo.action; 2 3 18 19 import javax.servlet.http.HttpServlet ; 21 import javax.servlet.http.HttpServletRequest ; 22 import javax.servlet.http.HttpServletResponse ; 23 24 import org.apache.velocity.context.Context; 26 27 import org.apache.velocity.demo.om.*; 29 30 37 public class ViewCommand extends Command 38 { 39 40 public static final String VIEW = "view.vm"; 41 42 public ViewCommand( HttpServletRequest req, HttpServletResponse resp ) 43 { 44 super( req, resp ); 45 } 46 47 50 public String exec( Context ctx ) 51 { 52 String value = request.getParameter("id"); 53 Message m = ForumDatabase.getMessage( value ); 54 55 ctx.put("message", m ); 57 ctx.put("id", value); 58 59 if ( m.numberOfReplies() > 0 ) 61 { 62 ctx.put("hasReplies", Boolean.TRUE); 63 ctx.put("replies", m.getReplies()); 64 } 65 else 66 { 67 ctx.put("hasReplies", Boolean.FALSE); 68 } 69 70 return VIEW; 71 } 72 } 73 74 75 | Popular Tags |