001/** 002 * Copyright 2005-2016 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.lookupable; 017 018import javax.servlet.jsp.PageContext; 019 020import org.apache.commons.lang.StringUtils; 021import org.displaytag.decorator.DisplaytagColumnDecorator; 022import org.displaytag.exception.DecoratorException; 023import org.displaytag.properties.MediaTypeEnum; 024import org.kuali.rice.kew.api.KewApiConstants; 025 026 027/** 028 * A ColumnDecorator for columns in a Lookup which adds an extra non-breaking space if the column 029 * is an empty String. 030 * 031 * @author Kuali Rice Team (rice.collab@kuali.org) 032 */ 033public class LookupColumnDecorator implements DisplaytagColumnDecorator { 034 035 public Object decorate(Object columnValue, PageContext pageContext, MediaTypeEnum media) throws DecoratorException { 036 if (columnValue == null) { 037 return KewApiConstants.HTML_NON_BREAKING_SPACE; 038 } 039 if (columnValue instanceof String && StringUtils.isEmpty(((String)columnValue).trim())) { 040 return KewApiConstants.HTML_NON_BREAKING_SPACE; 041 } 042 return columnValue; 043 } 044 045}