KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > blandware > atleap > webapp > action > testimonials > RandomTestimonialController


1 package com.blandware.atleap.webapp.action.testimonials;
2
3 import com.blandware.atleap.common.TestimonialModuleConstants;
4 import com.blandware.atleap.model.testimonials.Testimonial;
5 import com.blandware.atleap.service.testimonials.TestimonialManager;
6 import org.apache.commons.logging.Log;
7 import org.apache.commons.logging.LogFactory;
8 import org.apache.struts.tiles.ComponentContext;
9 import org.apache.struts.tiles.ControllerSupport;
10 import org.springframework.context.ApplicationContext;
11 import org.springframework.web.context.support.WebApplicationContextUtils;
12
13 import javax.servlet.ServletContext JavaDoc;
14 import javax.servlet.http.HttpServletRequest JavaDoc;
15 import javax.servlet.http.HttpServletResponse JavaDoc;
16
17
18 /**
19  * <p>RandomTestimonialController class. This class is used to display a
20  * random testimonial item.
21  * </p>
22  * <p><a HREF="RandomTestimonialController.java.htm"><i>View Source</i></a></p>
23  *
24  * @author Andrey Grebnev <a HREF="mailto:andrey.grebnev@blandware.com">&lt;andrey.grebnev@blandware.com&gt;</a>
25  * @version $Revision: 1.4 $ $Date: 2005/08/05 17:48:26 $
26  */

27 public final class RandomTestimonialController extends ControllerSupport {
28
29     protected transient final Log log = LogFactory.getLog(RandomTestimonialController.class);
30
31     //~ Methods ================================================================
32
/**
33      * Retrieves all menu items and puts them into request
34      *
35      * @param tilesContext Current tile context
36      * @param request Current request
37      * @param response Current response
38      * @param servletContext Current Servlet Context
39      */

40     public void execute(ComponentContext tilesContext,
41                         HttpServletRequest JavaDoc request,
42                         HttpServletResponse JavaDoc response,
43                         ServletContext JavaDoc servletContext) throws Exception JavaDoc {
44
45         ApplicationContext applicationContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
46         TestimonialManager testimonialManager = (TestimonialManager) applicationContext.getBean(TestimonialModuleConstants.TESTIMONIAL_MANAGER_BEAN);
47         Testimonial testimonial = testimonialManager.getRandomTestimonial();
48         request.setAttribute("randomTestimonial", testimonial);
49     }
50 }
51
Popular Tags