1 15 package org.apache.tapestry.portlet; 16 17 import java.io.IOException ; 18 import java.util.HashMap ; 19 import java.util.Map ; 20 21 import org.apache.tapestry.IRequestCycle; 22 import org.apache.tapestry.Tapestry; 23 import org.apache.tapestry.engine.EngineMessages; 24 import org.apache.tapestry.engine.IEngineService; 25 import org.apache.tapestry.engine.ILink; 26 import org.apache.tapestry.services.LinkFactory; 27 import org.apache.tapestry.services.ResponseRenderer; 28 import org.apache.tapestry.services.ServiceConstants; 29 30 38 public class PortletHomeService implements IEngineService 39 { 40 private PortletRenderer _portletRenderer; 41 42 private PortletRequestGlobals _requestGlobals; 43 44 private ResponseRenderer _responseRenderer; 45 46 private LinkFactory _linkFactory; 47 48 private PortletPageResolver _pageResolver; 49 50 public String getName() 51 { 52 return Tapestry.HOME_SERVICE; 53 } 54 55 public ILink getLink(IRequestCycle cycle, Object parameter) 56 { 57 if (parameter != null) 58 throw new IllegalArgumentException (EngineMessages.serviceNoParameter(this)); 59 60 Map parameters = new HashMap (); 61 62 parameters.put(ServiceConstants.SERVICE, Tapestry.HOME_SERVICE); 63 64 return _linkFactory.constructLink(cycle, parameters, true); 65 } 66 67 public void setLinkFactory(LinkFactory linkFactory) 68 { 69 _linkFactory = linkFactory; 70 } 71 72 public void setResponseRenderer(ResponseRenderer responseRenderer) 73 { 74 _responseRenderer = responseRenderer; 75 } 76 77 public void service(IRequestCycle cycle) throws IOException 78 { 79 String pageName = _pageResolver.getPageNameForRequest(cycle); 80 81 if (_requestGlobals.isRenderRequest()) 82 { 83 _portletRenderer.renderPage(cycle, pageName); 84 return; 85 } 86 87 cycle.activate(pageName); 88 89 _responseRenderer.renderResponse(cycle); 90 } 91 92 public void setPortletRenderer(PortletRenderer portletRenderer) 93 { 94 _portletRenderer = portletRenderer; 95 } 96 97 public void setRequestGlobals(PortletRequestGlobals requestGlobals) 98 { 99 _requestGlobals = requestGlobals; 100 } 101 102 public void setPageResolver(PortletPageResolver pageResolver) 103 { 104 _pageResolver = pageResolver; 105 } 106 } | Popular Tags |