View Javadoc
1 /* 2 * Scope: a generic MVC framework. 3 * Copyright (c) 2000-2002, The Scope team 4 * All rights reserved. 5 * 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the distribution. 17 * 18 * Neither the name "Scope" nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR 27 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 29 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 30 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 31 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 32 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 33 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * 35 * 36 * $Id: ValidationModel.java,v 1.5 2002/09/05 15:41:51 ludovicc Exp $ 37 */ 38 package samples.servlet.xml.validation; 39 40 import java.util.Date; 41 import java.util.List; 42 43 /*** 44 * <P> 45 * 46 * ValidationController uses one of these to supply data for its Views, and to 47 * keep session state in. It contains a number of properties, including a simple 48 * String, a Date that will involve a String conversion when the View 49 * repopulates its model, and a property that has a validation rule that may 50 * result in a thrown Exception. </P> <P> 51 * 52 * This model contains a list of String validation failures that are put in red 53 * at the top of the page. </P> <P> 54 * 55 * Scope's default ModelManager implementation builds on the JavaBeans API, so 56 * this model object is just a normal JavaBean. </P> 57 * 58 * @author <A HREF="mailto:smeyfroi@users.sourceforge.net">Steve Meyfroidt</A> 59 * @created 05 September 2002 60 * @version $Revision: 1.5 $ $Date: 2002/09/05 15:41:51 $ 61 */ 62 public class ValidationModel { 63 64 private String name; 65 private Date date; 66 private int number; 67 private List validationErrors; 68 69 /*** 70 * Constructor for the ValidationModel object 71 */ 72 public ValidationModel() { 73 setName("Fred"); 74 setDate(new Date(0)); 75 } 76 77 /*** 78 * Gets the name 79 * 80 * @return The name value 81 */ 82 public String getName() { 83 return name; 84 } 85 86 /*** 87 * Gets the date 88 * 89 * @return The date value 90 */ 91 public Date getDate() { 92 return date; 93 } 94 95 /*** 96 * Gets the number 97 * 98 * @return The number value 99 */ 100 public int getNumber() { 101 return number; 102 } 103 104 /*** 105 * Gets the validation failures 106 * 107 * @return The validationFailures value 108 */ 109 public List getValidationFailures() { 110 return validationErrors; 111 } 112 113 /*** 114 * Sets the name 115 * 116 * @param inName The new name value 117 */ 118 public void setName(String inName) { 119 name = inName; 120 } 121 122 /*** 123 * Sets the date 124 * 125 * @param inDate The new date value 126 */ 127 public void setDate(Date inDate) { 128 date = inDate; 129 } 130 131 /*** 132 * Sets the number 133 * 134 * @param inNumber The new number value 135 * @throws Exception TODO: Describe the Exception 136 */ 137 public void setNumber(int inNumber) throws Exception { 138 if (inNumber > 10) { 139 throw new IllegalArgumentException("Number must be less than 10."); 140 } 141 number = inNumber; 142 } 143 144 /*** 145 * Sets the validation failures 146 * 147 * @param inFailures The new validationFailures value 148 */ 149 public void setValidationFailures(List inFailures) { 150 validationErrors = inFailures; 151 } 152 }

This page was automatically generated by Maven