1 16 17 package info.jtrac.webflow; 18 19 import info.jtrac.domain.Config; 20 import info.jtrac.util.ValidationUtils; 21 import org.springframework.beans.propertyeditors.StringTrimmerEditor; 22 import org.springframework.validation.DataBinder; 23 import org.springframework.webflow.execution.Event; 24 import org.springframework.webflow.execution.RequestContext; 25 import org.springframework.webflow.execution.ScopeType; 26 27 30 public class ConfigFormAction extends AbstractFormAction { 31 32 public ConfigFormAction() { 33 setFormObjectClass(Config.class); 34 setFormObjectName("config"); 35 setFormObjectScope(ScopeType.REQUEST); 36 } 37 38 @Override 39 protected void initBinder(RequestContext request, DataBinder binder) { 40 binder.registerCustomEditor(String .class, new StringTrimmerEditor(true)); 41 } 42 43 @Override 44 public Object createFormObject(RequestContext context) { 45 String param = ValidationUtils.getParameter(context, "param"); 46 String value = jtrac.loadConfig(param); 47 if (value == null) { 48 return new Config(param, null); 49 } 50 return new Config(param, value); 51 } 52 53 public Event configFormHandler(RequestContext context) throws Exception { 54 Config config = (Config) getFormObject(context); 55 jtrac.storeConfig(config); 56 return success(); 57 } 58 59 } 60 | Popular Tags |