1 package org.apache.fulcrum.intake.model; 2 3 56 57 import org.apache.fulcrum.intake.xmlmodel.XmlField; 58 59 66 public class StringField 67 extends Field 68 { 69 public StringField(XmlField field, Group group) 70 throws Exception 71 { 72 super(field, group); 73 } 74 75 80 protected void setDefaultValue(String prop) 81 { 82 defaultValue = prop; 83 } 84 85 88 protected void doSetValue() 89 { 90 if ( isMultiValued ) 91 { 92 String [] ss = pp.getStrings(getKey()); 93 setTestValue(ss); 94 } 95 else 96 { 97 setTestValue(pp.getString(getKey())); 98 } 99 } 100 101 105 public void setRequired(boolean v, String message) 106 { 107 this.required = v; 108 if (v) 109 { 110 if (isMultiValued) 111 { 112 String [] ss = (String [])getTestValue(); 113 if (ss == null || ss.length == 0) 114 { 115 valid_flag = false; 116 this.message = message; 117 } 118 else 119 { 120 boolean set = false; 121 for (int i=0; i<ss.length; i++) 122 { 123 if (ss[i] != null && ss[i].length() > 0) 124 { 125 set = true; 126 } 127 } 128 if (!set) 129 { 130 valid_flag = false; 131 this.message = message; 132 } 133 } 134 } 135 else 136 { 137 if (!set_flag || ((String )getTestValue()).length() == 0) 138 { 139 valid_flag = false; 140 this.message = message; 141 } 142 } 143 144 } 145 } 146 } 147 | Popular Tags |