| 1 7 package com.inversoft.verge.examples.madlib; 8 9 10 import com.inversoft.error.BasicError; 11 import com.inversoft.error.ErrorRegistry; 12 import com.inversoft.verge.mvc.controller.Action; 13 14 15 24 public class SelectionActionHandler { 25 26 29 public static final String SUCCESS_ACTION = "success"; 30 31 34 public static final String FAILURE_ACTION = "failure"; 35 36 37 40 public SelectionActionHandler() { 41 } 43 44 45 public Object handleSelect(Action action) { 46 MadLibBean mb = (MadLibBean) action.getHttpSession().getAttribute("madLibBean"); 48 49 try { 51 MadLib madLib = MadLibFactory.buildMadLib(mb.getTitle()); 52 if (madLib == null) { 53 BasicError error = ErrorRegistry.getBasicError(MadLibValidator.ERROR_BUNDLE, 54 "notFound", null, this); 55 action.getRequestContext().addError(error); 56 return FAILURE_ACTION; 57 } 58 59 mb.setMadLib(madLib); 60 } catch (MadLibException mle) { 61 BasicError error = ErrorRegistry.getBasicError(MadLibValidator.ERROR_BUNDLE, 62 "invalid", null, this); 63 action.getRequestContext().addError(error); 64 return FAILURE_ACTION; 65 } 66 67 mb.reset(); 70 71 return SUCCESS_ACTION; 72 } 73 } 74 | Popular Tags |