1 25 26 package com.j2biz.blogunity.web.actions.exec; 27 28 import java.util.List ; 29 30 import javax.servlet.http.HttpServletRequest ; 31 import javax.servlet.http.HttpServletResponse ; 32 33 import org.apache.commons.lang.StringUtils; 34 35 import com.j2biz.blogunity.dao.BlogDAO; 36 import com.j2biz.blogunity.exception.BlogunityException; 37 import com.j2biz.blogunity.web.ActionResultFactory; 38 import com.j2biz.blogunity.web.FormError; 39 import com.j2biz.blogunity.web.FormErrorList; 40 import com.j2biz.blogunity.web.IActionResult; 41 import com.j2biz.blogunity.web.actions.AbstractAction; 42 43 50 public class SearchBlogExecAction extends AbstractAction { 51 52 private static final IActionResult SEARCH_FORM_FORWARD = ActionResultFactory.buildForward("/jsp/searchBlogForm.jsp"); 53 54 60 public IActionResult execute(HttpServletRequest request, 61 HttpServletResponse response) throws BlogunityException{ 62 63 String blogname = request.getParameter("blogname"); 64 FormErrorList errors = new FormErrorList(); 65 66 if (StringUtils.isEmpty(blogname)) { 67 errors.add(new FormError("blogname", 68 "Blogname cannot be empty")); 69 request.setAttribute("errors", errors); 70 return SEARCH_FORM_FORWARD; 71 } 72 73 List foundedBlogs = ( new BlogDAO()).getBlogsWithNameLike(blogname); 74 request.setAttribute("likeBlogname", blogname); 75 request.setAttribute("foundedBlogs", foundedBlogs); 76 77 return SEARCH_FORM_FORWARD; 78 } 79 80 } | Popular Tags |