001/** 002 * Copyright 2005-2018 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 */ 016package org.kuali.rice.kew.actionlist.web; 017 018import org.displaytag.decorator.TableDecorator; 019import org.kuali.rice.kew.actionitem.ActionItemBase; 020import org.kuali.rice.kew.api.KewApiConstants; 021import org.kuali.rice.kew.api.actionlist.DisplayParameters; 022 023 024/** 025 * Class used to decorate table rows generated by our table tag lib. 026 * 027 * @author Kuali Rice Team (rice.collab@kuali.org) 028 */ 029public class ActionListDecorator extends TableDecorator { 030 private static final org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(ActionListDecorator.class); 031 032 private int rowCounter = 0; 033 034 @Override 035 public String startRow() { 036 return ""; 037 } 038 039 @Override 040 public String finishRow() { 041 ActionItemBase actionItem = (ActionItemBase) getCurrentRowObject(); 042 String returnRow = ""; 043 try { 044 DisplayParameters displayParameters = actionItem.getDisplayParameters(); 045 if (displayParameters != null) { 046 Integer index = actionItem.getActionListIndex(); 047 Integer frameHeight = new Integer(290); 048 try { 049 if (displayParameters.getFrameHeight() != null && displayParameters.getFrameHeight() > 0) { 050 frameHeight = displayParameters.getFrameHeight(); 051 } 052 } catch (Exception ex) { 053 LOG.error("Error getting custom action list frame height.", ex); 054 } 055 StringBuffer newRow = new StringBuffer(); 056 newRow.append("<tr id='G"); 057 newRow.append(index.toString()); 058 newRow.append("' style='display: none;'>"); 059 newRow.append("<td class='white' height='0' colspan='11' >"); 060 newRow.append("<iframe name='iframeAL_"); 061 newRow.append(index.toString()); 062 newRow.append("' scrolling='yes' width=100% height="); 063 newRow.append(frameHeight.toString()); 064 newRow.append(" hspace=0 vspace=0 frameborder=0></iframe>"); 065 newRow.append("</td></tr>"); 066 returnRow += newRow.toString(); 067 } 068 } catch (Exception e) { 069 LOG.error("Error with custom action list attribute.", e); 070 } 071 return returnRow; 072 } 073 074 /** 075 * Adds a CSS class to the current row based on the value of the row object's rowStyleClass attribute. 076 * 077 * @see org.displaytag.decorator.TableDecorator#addRowClass() 078 */ 079 @Override 080 public String addRowClass() { 081 ActionItemBase actionItem = (ActionItemBase) getCurrentRowObject(); 082 return "actionlist_" + KewApiConstants.ACTION_LIST_COLOR_NAMES.get(actionItem.getRowStyleClass()); 083 } 084 085 /** 086 * Adds a unique ID to this row that allows JavaScript to add mouse event listeners at run-time. This is necessary because the action list's 087 * display:table tag does not allow event handlers to be specified for the row elements. 088 * 089 * @see org.displaytag.decorator.TableDecorator#addRowId() 090 */ 091 @Override 092 public String addRowId() { 093 return "actionlist_tr_" + rowCounter++; 094 } 095 096 /** 097 * Resets the row index counter after all rows have been added to the table. 098 * 099 * @see org.displaytag.decorator.TableDecorator#finish() 100 */ 101 @Override 102 public void finish() { 103 super.finish(); 104 rowCounter = 0; 105 } 106 107}