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 ; 14 import javax.servlet.http.HttpServletRequest ; 15 import javax.servlet.http.HttpServletResponse ; 16 17 18 27 public final class RandomTestimonialController extends ControllerSupport { 28 29 protected transient final Log log = LogFactory.getLog(RandomTestimonialController.class); 30 31 40 public void execute(ComponentContext tilesContext, 41 HttpServletRequest request, 42 HttpServletResponse response, 43 ServletContext servletContext) throws Exception { 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 |