Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
02111-1307, USA.
*/
-// $Id$
#include "WOInput.h"
#include "WOElement+private.h"
@implementation WOInput
+static BOOL takeValueDebugOn = NO;
+
+ (int)version {
return [super version] + 0 /* v2 */;
}
if (self->name == nil)
return [_ctx elementID];
- if ((name = [self->name stringValueInComponent:[_ctx component]]))
+ if ((name = [self->name stringValueInComponent:[_ctx component]]) != nil)
return name;
[[_ctx component]
return [_ctx elementID];
}
-// ******************** responder ********************
+/* taking form values */
- (id)parseFormValue:(id)_value inContext:(WOContext *)_ctx {
+ /* redefined in subclasses */
return _value;
}
return;
formName = OWFormElementName(self, _ctx);
+ if ((formValue = [_req formValueForKey:formName]) == nil)
+ // TODO: is this correct?
+ return;
- if ((formValue = [_req formValueForKey:formName])) {
-#if DEBUG && 0
- NSLog(@"%s(%@): form=%@ ctx=%@ value=%@ ..", __PRETTY_FUNCTION__,
- [_ctx elementID], formName, [_ctx contextID], formValue);
-#endif
-
- if ([self->value isValueSettable]) {
- formValue = [self parseFormValue:formValue inContext:_ctx];
- [self->value setStringValue:formValue inComponent:[_ctx component]];
- }
-#if DEBUG
- else {
- NSLog(@"%s: form value is not settable: %@", __PRETTY_FUNCTION__,
- self->value);
- }
-#endif
+ if (takeValueDebugOn) {
+ [self logWithFormat:
+ @"%s(%@): form=%@ ctx=%@ value=%@ ..", __PRETTY_FUNCTION__,
+ [_ctx elementID], formName, [_ctx contextID], formValue];
+ }
+
+ if ([self->value isValueSettable]) {
+ formValue = [self parseFormValue:formValue inContext:_ctx];
+ [self->value setStringValue:formValue inComponent:[_ctx component]];
+ }
+ else if (self->value != nil) {
+ [self logWithFormat:
+ @"%s: form value is not settable: %@", __PRETTY_FUNCTION__,
+ self->value];
}
}
/* description */
- (NSString *)associationDescription {
- NSMutableString *str = [NSMutableString stringWithCapacity:128];
-
+ NSMutableString *str;
+
+ str = [NSMutableString stringWithCapacity:128];
if (self->value) [str appendFormat:@" value=%@", self->value];
if (self->name) [str appendFormat:@" name=%@", self->name];
if (self->disabled) [str appendFormat:@" disabled=%@", self->disabled];
-
return str;
}