]> err.no Git - sope/blob - sope-appserver/NGObjWeb/NGObjWeb/WOComponent.h
major improvements in resource/template lookup with SoProduct's
[sope] / sope-appserver / NGObjWeb / NGObjWeb / WOComponent.h
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
6   SOPE is free software; you can redistribute it and/or modify it under
7   the terms of the GNU Lesser General Public License as published by the
8   Free Software Foundation; either version 2, or (at your option) any
9   later version.
10
11   SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12   WARRANTY; without even the implied warranty of MERCHANTABILITY or
13   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
14   License for more details.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with SOPE; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21
22 #ifndef __NGObjWeb_WOComponent_H__
23 #define __NGObjWeb_WOComponent_H__
24
25 #import <Foundation/NSMapTable.h>
26 #import <NGObjWeb/WOElement.h>
27 #include <NGObjWeb/WOActionResults.h>
28
29 @class NSString, NSDictionary, NSMutableDictionary, NSURL, NSException, NSURL;
30 @class WOElement, WOContext, WOSession, WOApplication, WOResourceManager;
31
32 @interface WOComponent : WOElement < WOActionResults, NSCoding >
33 {
34 @private
35   NSDictionary        *wocBindings;     // bindings to parent component
36   NSString            *wocName;         // name of component
37   
38   WOComponent         *parentComponent; // non-retained;
39   NSDictionary        *subcomponents;   // subcomponents
40   NSMutableDictionary *wocVariables;    // user variables
41
42   struct {
43     BOOL reloadTemplates:1; // component definition caching
44     BOOL isAwake:1;
45   } componentFlags;
46
47 @protected // transient (non-retained)
48   WOContext     *context;
49   WOApplication *application;
50   WOSession     *session;
51   
52   NSURL *wocBaseURL;
53   id    cycleContext; // was: _ODCycleCtx
54   id    wocClientObject;
55 }
56
57 - (id)initWithContext:(WOContext *)_ctx;
58
59 - (void)awake;
60 - (void)sleep;
61
62 /*
63   This method needs to be called before using a component cached by yourself.
64 */
65 - (void)ensureAwakeInContext:(WOContext *)_ctx;
66
67 /* accessors */
68
69 - (NSString *)name;
70 - (NSString *)path;
71 - (NSURL *)baseURL;
72
73 - (id)application;
74 - (id)session;
75 - (WOContext *)context;
76 - (BOOL)hasSession; // new in WO4
77
78 /* component definition caching */
79
80 - (void)setCachingEnabled:(BOOL)_flag;
81 - (BOOL)isCachingEnabled;
82
83 /* resources */
84
85 - (NSString *)pathForResourceNamed:(NSString *)_name ofType:(NSString *)_ext;
86 - (NSString *)frameworkName;
87
88 /* templates */
89
90 - (WOElement *)templateWithName:(NSString *)_name;
91
92 - (WOElement *)templateWithHTMLString:(NSString *)_html
93   declarationString:(NSString *)_wod
94   languages:(NSArray *)_languages;
95   
96 - (id)pageWithName:(NSString *)_name; // new in WO4
97
98 - (void)setTemplate:(id)_template;
99
100 /* child components */
101
102 - (BOOL)synchronizesVariablesWithBindings;                // new in WO4
103 - (void)setValue:(id)_value forBinding:(NSString *)_name; // new in WO4
104 - (id)valueForBinding:(NSString *)_name;                  // new in WO4
105 - (BOOL)hasBinding:(NSString *)_name;                     // new in WO4
106 - (BOOL)canSetValueForBinding:(NSString *)_name;          // new in WO4
107 - (BOOL)canGetValueForBinding:(NSString *)_name;          // new in WO4
108
109 - (id)performParentAction:(NSString *)_attributeName;
110 - (id)parent;
111
112 /* variables */
113
114 - (BOOL)isStateless; // new in WO4.5
115 - (void)reset;       // new in WO4.5
116
117 - (void)setObject:(id)_object forKey:(NSString *)_key;
118 - (id)objectForKey:(NSString *)_key;
119
120 - (void)validationFailedWithException:(NSException *)_exception
121   value:(id)_value
122   keyPath:(NSString *)_keyPath; // new in WO4
123
124 /* logging */
125
126 - (BOOL)isEventLoggingEnabled;
127
128 @end /* WOComponent */
129
130 @interface WOComponent(Logging)
131 /* implemented in NGExtensions */
132
133 - (void)logWithFormat:(NSString *)_fmt arguments:(va_list)_arguments;
134 - (void)logWithFormat:(NSString *)_fmt, ...;
135 - (void)debugWithFormat:(NSString *)_fmt, ...;
136
137 @end
138
139 @interface WOComponent(SkyrixExtensions)
140
141 - (WOResourceManager *)resourceManager;
142 - (id)existingSession;
143
144 - (id<WOActionResults>)redirectToLocation:(id)_loc;
145 - (BOOL)shouldTakeValuesFromRequest:(WORequest *)_rq inContext:(WOContext*)_c;
146
147 @end
148
149 @interface WOComponent(DeprecatedMethodsInWO4)
150
151 - (WOElement *)templateWithHTMLString:(NSString *)_html
152   declarationString:(NSString *)_wod;
153
154 - (NSString *)stringForKey:(NSString *)_key
155   inTableNamed:(NSString *)_tableName
156   withDefaultValue:(NSString *)_default;
157
158 @end /* WOComponent(DeprecatedMethodsInWO4) */
159
160 @interface WOComponent(AdvancedBindingAccessors)
161
162 - (void)setUnsignedIntValue:(unsigned)_value forBinding:(NSString *)_name;
163 - (unsigned)unsignedIntValueForBinding:(NSString *)_name;
164 - (void)setIntValue:(int)_value forBinding:(NSString *)_name;
165 - (int)intValueForBinding:(NSString *)_name;
166
167 @end /* WOComponent(AdvancedBindingAccessors) */
168
169 @interface WOComponent(Statistics)
170
171 - (NSString *)descriptionForResponse:(WOResponse *)_response
172   inContext:(WOContext *)_context;
173
174 @end /* WOComponent(Statistics) */
175
176 @interface WOComponent(DirectActionExtensions)
177
178 - (void)takeFormValuesForKeyArray:(NSArray *)_keys;
179 - (void)takeFormValuesForKeys:(NSString *)_key1,...;
180 - (id<WOActionResults>)defaultAction;
181 - (id<WOActionResults>)performActionNamed:(NSString *)_actionName;
182
183 @end /* WOComponent(DirectActionExtensions) */
184
185 #endif /* __NGObjWeb_WOComponent_H__ */