001 /** 002 * Copyright 2005-2012 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.rice.krad.uif.field; 017 018 import org.apache.commons.lang.StringUtils; 019 020 /** 021 * Encapsulates a text message to be displayed 022 * 023 * <p> 024 * The <code>MessageField</code> is used to display static text in the user 025 * interface. The message type can be used to group similar messages for styling 026 * </p> 027 * 028 * @author Kuali Rice Team (rice.collab@kuali.org) 029 */ 030 public class MessageField extends FieldBase { 031 private static final long serialVersionUID = 4090058533452450395L; 032 033 private String messageText; 034 private String messageType; 035 036 public MessageField() { 037 super(); 038 } 039 040 /** 041 * Override to render only if the message text has been given or there is a conditional expression on the 042 * message text 043 * 044 * @see org.kuali.rice.krad.uif.component.ComponentBase#isRender() 045 */ 046 @Override 047 public boolean isRender() { 048 boolean render = super.isRender(); 049 050 if (render) { 051 render = getPropertyExpressions().containsKey("messageText") || (StringUtils.isNotBlank(messageText) 052 && !StringUtils.equals(messageText, " ")); 053 } 054 055 return render; 056 } 057 058 public MessageField(String messageType) { 059 this.messageType = messageType; 060 } 061 062 public MessageField(String messageText, String messageType) { 063 this.messageText = messageText; 064 this.messageType = messageType; 065 } 066 067 /** 068 * Text that makes up the message that will be displayed 069 * 070 * @return String message text 071 */ 072 public String getMessageText() { 073 return this.messageText; 074 } 075 076 /** 077 * Setter for the message text 078 * 079 * @param messageText 080 */ 081 public void setMessageText(String messageText) { 082 this.messageText = messageText; 083 } 084 085 /** 086 * Type of the field's message, used to suffix the message fields id 087 * 088 * <p> 089 * Messages that have similar intent can be grouped by this type string. For 090 * messages of the same type, their id will contain the same suffix which 091 * can be used for scripting to apply additional styling or behavior to that 092 * groups of messages (for example show/hide) 093 * </p> 094 * 095 * @return String message type 096 */ 097 public String getMessageType() { 098 return this.messageType; 099 } 100 101 /** 102 * Setter for the message's type 103 * 104 * @param messageType 105 */ 106 public void setMessageType(String messageType) { 107 this.messageType = messageType; 108 } 109 110 }