1 15 package org.apache.tapestry.engine; 16 17 import java.io.IOException ; 18 import java.util.HashMap ; 19 import java.util.Map ; 20 21 import org.apache.hivemind.util.Defense; 22 import org.apache.tapestry.IRequestCycle; 23 import org.apache.tapestry.Tapestry; 24 import org.apache.tapestry.services.LinkFactory; 25 import org.apache.tapestry.services.ResponseRenderer; 26 import org.apache.tapestry.services.ServiceConstants; 27 28 34 35 public class PageService implements IEngineService 36 { 37 38 private ResponseRenderer _responseRenderer; 39 40 41 private LinkFactory _linkFactory; 42 43 public ILink getLink(IRequestCycle cycle, Object parameter) 44 { 45 Defense.isAssignable(parameter, String .class, "parameter"); 46 47 Map parameters = new HashMap (); 48 49 parameters.put(ServiceConstants.SERVICE, Tapestry.PAGE_SERVICE); 50 parameters.put(ServiceConstants.PAGE, parameter); 51 52 return _linkFactory.constructLink(cycle, parameters, true); 53 54 } 55 56 public void service(IRequestCycle cycle) throws IOException 57 { 58 String pageName = cycle.getParameter(ServiceConstants.PAGE); 59 60 67 cycle.activate(pageName); 68 69 _responseRenderer.renderResponse(cycle); 70 } 71 72 public String getName() 73 { 74 return Tapestry.PAGE_SERVICE; 75 } 76 77 78 public void setResponseRenderer(ResponseRenderer responseRenderer) 79 { 80 _responseRenderer = responseRenderer; 81 } 82 83 84 public void setLinkFactory(LinkFactory linkFactory) 85 { 86 _linkFactory = linkFactory; 87 } 88 } | Popular Tags |