1 16 package org.apache.cocoon.woody.acting; 17 18 import org.apache.cocoon.acting.Action; 19 import org.apache.cocoon.environment.Redirector; 20 import org.apache.cocoon.environment.SourceResolver; 21 import org.apache.cocoon.environment.Request; 22 import org.apache.cocoon.environment.ObjectModelHelper; 23 import org.apache.cocoon.woody.FormManager; 24 import org.apache.cocoon.woody.formmodel.Form; 25 import org.apache.excalibur.source.Source; 26 import org.apache.avalon.framework.thread.ThreadSafe; 27 import org.apache.avalon.framework.parameters.Parameters; 28 import org.apache.avalon.framework.service.Serviceable; 29 import org.apache.avalon.framework.service.ServiceManager; 30 import org.apache.avalon.framework.service.ServiceException; 31 32 import java.util.Map ; 33 34 45 public class MakeFormAction implements Action, ThreadSafe, Serviceable { 46 47 FormManager formManager; 48 49 public void service(ServiceManager serviceManager) throws ServiceException { 50 formManager = (FormManager)serviceManager.lookup(FormManager.ROLE); 51 } 52 53 public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String src, Parameters parameters) 54 throws Exception { 55 String formSource = parameters.getParameter("form-definition"); 56 String formAttribute = parameters.getParameter("attribute-name"); 57 58 Source source = null; 59 try { 60 source = resolver.resolveURI(formSource); 61 Form form = formManager.createForm(source); 62 63 Request request = ObjectModelHelper.getRequest(objectModel); 64 request.setAttribute(formAttribute, form); 65 } finally { 66 resolver.release(source); 67 } 68 69 return null; 70 } 71 72 } 73 | Popular Tags |