1 7 package com.inversoft.verge.mvc.view.jsp.actionflow; 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.actionflow.ActionFlowMetaData; 22 import com.inversoft.verge.util.WebBean; 23 24 25 31 public class ATei extends TagExtraInfo { 32 33 36 private static final Logger logger = Logger.getLogger(ATei.class); 37 38 39 44 public boolean isValid(TagData data) { 45 boolean valid = true; 46 String form = data.getAttributeString("form"); 47 if (form != null) { 48 String namespace = data.getAttributeString("namespace"); 49 ActionFlowMetaData metaData = new ActionFlowMetaData(namespace, form); 50 51 try { 52 metaData.findFormConfig(null); 53 } catch (MVCException mvce) { 54 logger.fatal(mvce); 55 valid = false; 56 } 57 } 58 59 return valid; 60 } 61 62 67 public VariableInfo [] getVariableInfo(TagData data) { 68 VariableInfo [] infos = null; 69 String form = data.getAttributeString("form"); 70 if (form != null) { 71 String namespace = data.getAttributeString("namespace"); 72 ActionFlowMetaData metaData = new ActionFlowMetaData(namespace, form); 73 74 BaseFormConfig config = null; 75 try { 76 config = metaData.findFormConfig(null); 77 } catch (MVCException mvce) { 78 logger.fatal(mvce); 79 throw new IllegalArgumentException ("Invalid form name: " + form); 80 } 81 82 Collection formBeans = config.getFormBeans(); 83 infos = new VariableInfo [formBeans.size()]; 84 Iterator iter = formBeans.iterator(); 85 WebBean webBean; 86 int count = 0; 87 while (iter.hasNext()) { 88 webBean = (WebBean) iter.next(); 89 infos[count] = new VariableInfo (webBean.getID(), webBean.getClassName(), 90 true, VariableInfo.NESTED); 91 } 92 } 93 94 return infos; 95 } 96 } | Popular Tags |