1 /** 2 * Copyright 2005-2016 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.rice.krad.uif.field; 17 18 import org.apache.commons.lang.StringUtils; 19 20 /** 21 * Encapsulates a text message to be displayed 22 * 23 * <p> 24 * The <code>MessageField</code> is used to display static text in the user 25 * interface. The message type can be used to group similar messages for styling 26 * </p> 27 * 28 * @author Kuali Rice Team (rice.collab@kuali.org) 29 */ 30 public class MessageField extends FieldBase { 31 private static final long serialVersionUID = 4090058533452450395L; 32 33 private String messageText; 34 private String messageType; 35 36 public MessageField() { 37 super(); 38 } 39 40 /** 41 * Override to render only if the message text has been given or there is a conditional expression on the 42 * message text 43 * 44 * @see org.kuali.rice.krad.uif.component.ComponentBase#isRender() 45 */ 46 @Override 47 public boolean isRender() { 48 boolean render = super.isRender(); 49 50 if (render) { 51 render = getPropertyExpressions().containsKey("messageText") || (StringUtils.isNotBlank(messageText) 52 && !StringUtils.equals(messageText, " ")); 53 } 54 55 return render; 56 } 57 58 public MessageField(String messageType) { 59 this.messageType = messageType; 60 } 61 62 public MessageField(String messageText, String messageType) { 63 this.messageText = messageText; 64 this.messageType = messageType; 65 } 66 67 /** 68 * Text that makes up the message that will be displayed 69 * 70 * @return String message text 71 */ 72 public String getMessageText() { 73 return this.messageText; 74 } 75 76 /** 77 * Setter for the message text 78 * 79 * @param messageText 80 */ 81 public void setMessageText(String messageText) { 82 this.messageText = messageText; 83 } 84 85 /** 86 * Type of the field's message, used to suffix the message fields id 87 * 88 * <p> 89 * Messages that have similar intent can be grouped by this type string. For 90 * messages of the same type, their id will contain the same suffix which 91 * can be used for scripting to apply additional styling or behavior to that 92 * groups of messages (for example show/hide) 93 * </p> 94 * 95 * @return String message type 96 */ 97 public String getMessageType() { 98 return this.messageType; 99 } 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 }