CO
if (pageContext.getParameter("ClearBtn") != null) { clearRegion(pageContext, webBean, "SearchPanelRN"); String[] webBeanStr = new String[]{ "ProjectSetIdSch", "ProjectIdSch", "VendorIdSch" }; clearWebBeanValue(pageContext, webBean, webBeanStr); }
公共类
public static void clearRegion(OAPageContext pageContext, BaseMutableUINode baseNode) { UINodeList nodeList = baseNode.getIndexedNodeList(); OARenderingContext rc = pageContext.getRenderingContext(); for (int i = 0; i < nodeList.size(rc); i++) { UINode node = nodeList.getUINode(rc, i); if (node instanceof OAWebBeanDataAttribute) { OAWebBeanDataAttribute nodeToClear = (OAWebBeanDataAttribute)node; nodeToClear.setValue(pageContext, null); } clearRegion(pageContext, (BaseMutableUINode)node); } } /** * 将一个Region下的所有的子节点清空,通常用于清空查询条件。 */ public static void clearRegion(OAPageContext pageContext, OAWebBean webBean, String regionId) { String pageLayoutId = pageContext.getPageLayoutBean().getID(); if (pageLayoutId.equals(regionId)) { BaseMutableUINode baseNode = (BaseMutableUINode)webBean; clearRegion(pageContext, baseNode); } else { BaseMutableUINode baseNode = (BaseMutableUINode)webBean.findChildRecursive(regionId); clearRegion(pageContext, baseNode); } } /** * 清空指定组件的值 * @param pageContext * @param webBean * @param strWebBeanNames 需要被清空的组件ID */ public static void clearWebBeanValue(OAPageContext pageContext, OAWebBean webBean, String[] strWebBeanNames){ { if (strWebBeanNames != null) { OAWebBean itemWebBean = null; //Search for Bean if (strWebBeanNames != null) { for (int i = 0; i < strWebBeanNames.length; i++) { //用这个替换大量的类型匹配instance itemWebBean = webBean.findChildRecursive(strWebBeanNames[i]); if (itemWebBean instanceof OAWebBeanDataAttribute) { OAWebBeanDataAttribute nodeToClear = (OAWebBeanDataAttribute)itemWebBean; nodeToClear.setValue(pageContext, null); } } } } } }