CustIdValidator.java Sample

This topic inludes the source code for the CustIdValidator.java Sample.

Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/ExtensionDevKit/ControlDevKit/ControlFeatures/propEditor/ide/

Sample Source Code


01 package propEditor.ide; 
02 
03 import com.bea.control.Issue;
04 import com.bea.control.ValidateAttribute;
05 import java.util.Map;
06 
07 public class CustIdValidator implements ValidateAttribute
08 
09     int legalValues[] 987654987655987658987659 };
10     
11     static class CustIdIssue implements Issue
12     {
13         String _message;
14         private CustIdIssue(String message) { _message = message; }
15         public boolean isError() { return true}
16         public String getDescription() { return _message; }
17         public String getPrescription() 
18         
19             return "Provide one of the following values: " +
20              "987654, 987655, 987658, 987659. that's all"
21         
22     }
23     
24     // called by the attribute editor.
25     public Issue[] validateId(String value)
26     {
27          return validateDuringCompile(null, value, null);   
28     }
29 
30     public Issue[] validateDuringCompile(String attributeType, String value, Map context)
31     {
32             Issue[] issues = new Issue[1];
33             int val;
34             try 
35             {
36                 val = Integer.parseInt(value);
37             }
38             catch(Exception e)
39             {
40                 issues[0new CustIdIssue(e.getMessage());
41                 return issues;
42             }
43             
44 
45         for(int i = 0; i < legalValues.length; i++)
46         {
47             if(legalValues[i== val)
48             {
49                 return null;
50             }
51        }            
52     
53         issues[0new CustIdIssue("unsupported value error");
54         return issues;
55     }
56     
57     public Issue[] validateDuringEdit(String attributeType, String value)
58     {
59         return null;
60     }
61