Source code: com/gammastream/validity/GSVExceptionViewer.java
1 // Generated by the WebObjects Wizard Mon Nov 13 13:18:37 America/Chicago 2000
2 package com.gammastream.validity;
3
4 import com.webobjects.foundation.*;
5 import com.webobjects.appserver.*;
6 import com.webobjects.eocontrol.*;
7 import com.webobjects.eoaccess.*;
8
9 public class GSVExceptionViewer extends WOComponent {
10
11 public String currentMessage;
12 public NSArray messageArray;
13 private NSArray _attributeKeys = null;
14
15 public GSVExceptionViewer(WOContext context){
16 super(context);
17 }
18
19 public void reset(){
20 super.reset();
21 currentMessage = null;
22 messageArray = null;
23 _attributeKeys = null;
24 }
25
26 public boolean synchronizesVariablesWithBindings(){
27 return false;
28 }
29
30 public boolean isStateless(){
31 return true;
32 }
33
34 public NSValidation.ValidationException exception(){
35 return (NSValidation.ValidationException)this.valueForBinding("exception");
36 }
37
38 public boolean showAllErrors(){
39 if(this.hasBinding("showAllErrors")){
40 return ((Boolean)this.valueForBinding("showAllErrors")).booleanValue();
41 }
42 return false;
43 }
44
45 public NSArray attributeKeys(){
46 if( _attributeKeys == null ){
47 String key = (String)this.valueForBinding("attributeKey");
48 _attributeKeys = NSArray.componentsSeparatedByString(key, ":");
49 }
50 return _attributeKeys;
51 }
52
53
54 public boolean show() {
55 if(exception()!=null){
56 return true;
57 }
58 return false;
59 }
60
61 public NSDictionary messageDictionary(){
62 if(this.show() && this.exception().userInfo().objectForKey(GSVEngine.ERROR_DICTIONARY_KEY) != null){
63 return (NSDictionary)this.exception().userInfo().objectForKey(GSVEngine.ERROR_DICTIONARY_KEY);
64 }
65 return null;
66 }
67
68 public NSArray messages(){
69 NSDictionary md = this.messageDictionary();
70 if( md != null ){
71 return md.allValues();
72 }
73 return NSArray.EmptyArray;
74 }
75
76 public NSArray messagesForAttribute(){
77 NSMutableArray array = new NSMutableArray();
78 NSDictionary d2 = this.exception().userInfo();
79 if( d2 != null ){
80 NSDictionary d = (NSDictionary)d2.objectForKey(GSVEngine.ERROR_DICTIONARY_KEY);
81 if( d != null ){
82 if( this.attributeKeys() != null ){
83 for( int i=0;i<this.attributeKeys().count();i++){
84 array.addObjectsFromArray((NSArray)d.objectForKey(this.attributeKeys().objectAtIndex(i)));
85 }
86 }
87 }
88 }
89 return array;
90 }
91
92 public boolean hasMessagesForAttribute(){
93 NSArray messages = this.messagesForAttribute();
94 return (messages != null && messages.count() > 0);
95 }
96 }
97