001 /* 002 * Copyright 2011 The Kuali Foundation. 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.kfs.sys.document.web; 017 018 import java.util.Iterator; 019 import java.util.List; 020 021 import javax.servlet.jsp.JspException; 022 import javax.servlet.jsp.PageContext; 023 import javax.servlet.jsp.tagext.Tag; 024 025 import org.kuali.kfs.sys.document.web.DefaultAccountingLineGroupImpl; 026 import org.kuali.kfs.sys.document.web.renderers.GroupErrorsRenderer; 027 028 /** 029 * Extension to override rendering of errors to first verify the error key starts with the give collection name. 030 */ 031 public class CollectionAccountingLineGroupImpl extends DefaultAccountingLineGroupImpl { 032 033 /** 034 * Renders any errors for the group 035 * 036 * @param pageContext the page context where the errors will be rendered on 037 * @param parentTag the parent tag requesting the rendering 038 */ 039 @Override 040 protected void renderErrors(PageContext pageContext, Tag parentTag) throws JspException { 041 String propName = getCollectionPropertyName(); 042 GroupErrorsRenderer errorRenderer = new GroupErrorsRenderer(); 043 List errors = errorRenderer.getErrorPropertyList(pageContext); 044 if ( errors != null && !errors.isEmpty()) { 045 for (Iterator itr = errors.iterator(); itr.hasNext();) { 046 String error = (String) itr.next(); 047 if (error.startsWith(propName)) { 048 errorRenderer.setErrorKeyMatch(error); 049 errorRenderer.setColSpan(getWidthInCells()); 050 errorRenderer.render(pageContext, parentTag); 051 052 moveListToMap(errorRenderer.getErrorsRendered(), getDisplayedErrors()); 053 moveListToMap(errorRenderer.getWarningsRendered(), getDisplayedWarnings()); 054 moveListToMap(errorRenderer.getInfoRendered(), getDisplayedInfo()); 055 056 errorRenderer.clear(); 057 } 058 } 059 } 060 } 061 }