1 package org.apache.velocity.demo.action; 2 3 18 19 import java.util.*; 21 22 import javax.servlet.http.HttpServlet ; 24 import javax.servlet.http.HttpServletRequest ; 25 import javax.servlet.http.HttpServletResponse ; 26 27 import org.apache.velocity.context.Context; 29 30 import org.apache.velocity.demo.om.*; 32 33 40 public class PostReplyCommand extends Command 41 { 42 public PostReplyCommand( HttpServletRequest req, HttpServletResponse resp ) 43 { 44 super( req, resp ); 45 } 46 47 52 public String exec( Context ctx ) 53 { 54 String name = request.getParameter("name"); 55 String subject = request.getParameter("subject"); 56 String email = request.getParameter("email"); 57 String content = request.getParameter("content"); 58 String parent = request.getParameter("id"); 59 60 Message message = new Message(); 62 message.setName( name ); 63 message.setSubject( subject ); 64 message.setEmail( email ); 65 message.setContents( content ); 66 67 ForumDatabase.postReply( message, parent ); 69 70 Message m = ForumDatabase.getMessage( parent ); 72 ctx.put("message", m ); 73 ctx.put("id", parent); 74 75 if ( m.numberOfReplies() > 0 ) 77 { 78 ctx.put("hasReplies", Boolean.TRUE); 79 ctx.put("replies", m.getReplies()); 80 } 81 else 82 { 83 ctx.put("hasReplies", Boolean.FALSE); 84 } 85 return ViewCommand.VIEW; 86 } 87 } 88 89 90 91 92 | Popular Tags |