1 7 package com.inversoft.verge.mvc.view.jsp.form; 8 9 10 import java.util.Collection ; 11 import java.util.Iterator ; 12 13 import javax.servlet.jsp.tagext.TagData ; 14 import javax.servlet.jsp.tagext.TagExtraInfo ; 15 import javax.servlet.jsp.tagext.VariableInfo ; 16 17 import org.apache.log4j.Logger; 18 19 import com.inversoft.verge.mvc.MVCException; 20 import com.inversoft.verge.mvc.config.BaseFormConfig; 21 import com.inversoft.verge.mvc.controller.form.FormMVCMetaData; 22 import com.inversoft.verge.mvc.controller.form.config.ActionConfig; 23 import com.inversoft.verge.mvc.controller.form.config.FormConfig; 24 import com.inversoft.verge.mvc.controller.form.config.FormMVCConfigRegistry; 25 import com.inversoft.verge.util.WebBean; 26 27 28 34 public class ATei extends TagExtraInfo { 35 36 39 private static final Logger logger = Logger.getLogger(ATei.class); 40 41 42 47 public boolean isValid(TagData data) { 48 boolean valid = true; 49 String form = data.getAttributeString("form"); 50 FormConfig config = null; 51 if (form != null) { 52 FormMVCMetaData metaData = new FormMVCMetaData(form, null); 53 54 try { 55 config = (FormConfig) metaData.findFormConfig(null); 56 } catch (MVCException mvce) { 57 logger.fatal(mvce); 58 valid = false; 59 } 60 } 61 62 63 String action = data.getAttributeString("action"); 65 ActionConfig actionConfig = 66 FormMVCConfigRegistry.getInstance(null). 67 lookupAction(action, config); 68 if (actionConfig == null) { 69 logger.fatal("[ATag] - Invalid action named: " + action); 70 valid = false; 71 } 72 73 return valid; 74 } 75 76 81 public VariableInfo [] getVariableInfo(TagData data) { 82 VariableInfo [] infos = null; 83 String form = data.getAttributeString("form"); 84 if (form != null) { 85 FormMVCMetaData metaData = new FormMVCMetaData(form, null); 86 87 BaseFormConfig config = null; 88 try { 89 config = metaData.findFormConfig(null); 90 } catch (MVCException mvce) { 91 logger.fatal(mvce); 92 throw new IllegalArgumentException ("Invalid form name: " + form); 93 } 94 95 Collection formBeans = config.getFormBeans(); 96 infos = new VariableInfo [formBeans.size()]; 97 Iterator iter = formBeans.iterator(); 98 WebBean webBean; 99 int count = 0; 100 while (iter.hasNext()) { 101 webBean = (WebBean) iter.next(); 102 infos[count] = new VariableInfo (webBean.getID(), webBean.getClassName(), 103 true, VariableInfo.NESTED); 104 } 105 } 106 107 return infos; 108 } 109 } | Popular Tags |