001 package edu.nrao.sss.webapp; 002 003 import javax.faces.event.ActionEvent; 004 005 import java.util.List; 006 import java.util.ArrayList; 007 008 /** 009 * Keeps track of whether or not a server error has been reported and holds a 010 * list of error messages to be displayed to the user. 011 */ 012 public class ServerErrorStatus 013 { 014 public static final String SERVER_ERROR_STATUS_EL = "#{errorStatus}"; 015 016 private List<String> errors = new ArrayList<String>(); 017 018 /** @return true if error messages have been added */ 019 public boolean getServerErrorsExist() 020 { 021 return !this.errors.isEmpty(); 022 } 023 024 /** 025 * clears the error list 026 */ 027 public void clearErrors(ActionEvent e) 028 { 029 this.errors.clear(); 030 } 031 032 /** 033 * @return a list of errors messages that have been added. 034 */ 035 public List<String> getErrorMessages() 036 { 037 return this.errors; 038 } 039 040 /** 041 * Adds an error message and sets the server errors exist flag. 042 */ 043 public void addErrorMessage(String msg) 044 { 045 if (msg != null && msg.length() > 0) 046 this.errors.add(msg); 047 } 048 }