View Javadoc
1   /*
2    * Copyright 2009 The Kuali Foundation
3    * 
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * 
8    * http://www.opensource.org/licenses/ecl2.php
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.ole.sys.document.web;
17  
18  import java.util.Iterator;
19  import java.util.List;
20  
21  import javax.servlet.jsp.JspException;
22  import javax.servlet.jsp.PageContext;
23  import javax.servlet.jsp.tagext.Tag;
24  
25  import org.kuali.ole.sys.document.web.renderers.GroupErrorsRenderer;
26  
27  /**
28   * Extension to override rendering of errors to first verify the error key starts with the give collection name.
29   */
30  public class CollectionAccountingLineGroupImpl extends DefaultAccountingLineGroupImpl {
31  
32      /**
33       * Renders any errors for the group
34       * 
35       * @param pageContext the page context where the errors will be rendered on
36       * @param parentTag the parent tag requesting the rendering
37       */
38      @Override
39      protected void renderErrors(PageContext pageContext, Tag parentTag) throws JspException {
40          String propName = getCollectionPropertyName();
41          GroupErrorsRenderer errorRenderer = new GroupErrorsRenderer();
42          List errors = errorRenderer.getErrorPropertyList(pageContext);
43          if ( errors != null && !errors.isEmpty()) { 
44              for (Iterator itr = errors.iterator(); itr.hasNext();) {
45                  String error = (String) itr.next();
46                  if (error.startsWith(propName)) {
47                      errorRenderer.setErrorKeyMatch(error);
48                      errorRenderer.setColSpan(getWidthInCells());
49                      errorRenderer.render(pageContext, parentTag);
50      
51                      moveListToMap(errorRenderer.getErrorsRendered(), getDisplayedErrors());
52                      moveListToMap(errorRenderer.getWarningsRendered(), getDisplayedWarnings());
53                      moveListToMap(errorRenderer.getInfoRendered(), getDisplayedInfo());
54      
55                      errorRenderer.clear();
56                  }
57              }
58          }
59      }
60  }