1 16 package org.apache.cocoon.acting; 17 18 import org.apache.avalon.framework.configuration.Configuration; 19 import org.apache.avalon.framework.thread.ThreadSafe; 20 21 import org.apache.cocoon.environment.ObjectModelHelper; 22 import org.apache.cocoon.environment.Request; 23 24 import java.util.Collection ; 25 import java.util.HashMap ; 26 import java.util.Iterator ; 27 import java.util.Map ; 28 29 39 public class FormValidatorAction extends AbstractValidatorAction implements ThreadSafe { 40 41 50 protected HashMap createMapOfParameters(Map objectModel, Collection set) { 51 String name; 52 HashMap params = new HashMap (set.size()); 53 Request request = ObjectModelHelper.getRequest(objectModel); 55 for (Iterator i = set.iterator(); i.hasNext();) { 56 name = ((Configuration) i.next()).getAttribute("name", "").trim(); 57 Object [] values = request.getParameterValues(name); 58 if (values != null) { 59 switch (values.length) { 60 case 0 : 61 params.put(name, null); 62 break; 63 case 1 : 64 params.put(name, values[0]); 65 break; 66 default : 67 params.put(name, values); 68 } 69 } else { 70 params.put(name, values); 71 } 72 } 73 return params; 74 } 75 76 79 boolean isStringEncoded() { 80 return true; 81 } 82 83 84 } 85 | Popular Tags |