2005-03-20 Helge Hess <helge.hess@opengroupware.org>
+ * v4.5.139
+
+ * DynamicElements/WOCheckboxList.m, DynamicElements/WOBrowser.m,
+ DynamicElements/WOCheckbox.m, DynamicElements/WOPopUpButton.m,
+ DynamicElements/WORadioButton.m, DynamicElements/WORadioButtonList.m,
+ DynamicElements/WOSubmitButton.m, DynamicElements/WOText.m,
+ DynamicElements/WOTextField.m: code cleanups, minor perf
+ improvements, generate 'disabled' <input> attribute
+
+ * DynamicElements/WOImageButton.m: generate <img> instead of <input>
+ if 'disabled' binding evaluates to true
+
* WOContext.m: changed default query parameter separator to & as
suggested by Stephane (v4.5.138)
-
+
2005-03-15 Marcus Mueller <znek@mulle-kybernetik.com>
* NGObjWeb.xcode: added WOWatchDogApplicationMainOSX.m and removed
sComponent = [_ctx component];
if ([self->disabled boolValueInComponent:sComponent])
- return;
+ return;
formValue = [_request formValuesForKey:OWFormElementName(self, _ctx)];
#if 0
}
}
+/* generate response */
+
- (void)appendOptionsToResponse:(WOResponse *)_response
inContext:(WOContext *)_ctx
{
- WOComponent *sComponent = [_ctx component];
- BOOL isSingle = NO;
- NSString *nilStr = nil;
- NSArray *array = nil;
- id selArray = nil;
+ WOComponent *sComponent;
+ BOOL isSingle;
+ NSString *nilStr;
+ NSArray *array;
+ id selArray;
int i, toGo;
+ sComponent = [_ctx component];
nilStr = [self->noSelectionString stringValueInComponent:sComponent];
isSingle = [self->singleSelection boolValueInComponent:sComponent];
selArray = [self->selection valueInComponent:sComponent];
toGo = [array count];
- if (nilStr) {
+ if (nilStr != nil) {
WOResponse_AddCString(_response, "<option value=\"$\">");
WOResponse_AddHtmlString(_response, nilStr);
WOResponse_AddCString(_response, "</option>");
}
-
+
for (i = 0; i < toGo; i++) {
- NSString *v = nil;
- NSString *displayV = nil;
- id object = [array objectAtIndex:i];
+ NSString *v, *displayV;
+ id object;
BOOL isSelected;
+ object = [array objectAtIndex:i];
+
if ([self->item isValueSettable])
[self->item setValue:object inComponent:sComponent];
isSelected = NO;
- if (selArray) {
+ if (selArray != nil) {
isSelected = isSingle
? [selArray isEqual:object] : [selArray containsObject:object];
}
- v = self->value
+ v = (self->value != nil)
? [self->value stringValueInComponent:sComponent]
- : [NSString stringWithFormat:@"%i", i];
+ : [NSString stringWithFormat:@"%i", i]; // TODO: slow
displayV = self->string
? [self->string stringValueInComponent:sComponent]
WOResponse_AddUInt(_response, s);
[_response appendContentCharacter:'"'];
}
+
+ if ([self->disabled boolValueInComponent:[_ctx component]])
+ WOResponse_AddCString(_response, " disabled=\"disabled\"");
if (isMultiple)
WOResponse_AddCString(_response, " multiple=\"multiple\"");
}
- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
- if (![[_ctx request] isFromClientComponent]) {
- NSString *v;
- BOOL isChecked;
+ NSString *v;
+ BOOL isChecked;
+
+ if ([[_ctx request] isFromClientComponent])
+ return;
- v = [self->value stringValueInComponent:[_ctx component]];
- isChecked = [self->checked boolValueInComponent:[_ctx component]];
+ v = [self->value stringValueInComponent:[_ctx component]];
+ isChecked = [self->checked boolValueInComponent:[_ctx component]];
- WOResponse_AddCString(_response, "<input type=\"checkbox\" name=\"");
- [_response appendContentHTMLAttributeValue:
- OWFormElementName(self, _ctx)];
- WOResponse_AddCString(_response, "\" value=\"");
- [_response appendContentHTMLAttributeValue:([v length] > 0) ? v : @"1"];
- WOResponse_AddCString(_response, "\"");
+ WOResponse_AddCString(_response, "<input type=\"checkbox\" name=\"");
+ [_response appendContentHTMLAttributeValue:
+ OWFormElementName(self, _ctx)];
+ WOResponse_AddCString(_response, "\" value=\"");
+ [_response appendContentHTMLAttributeValue:([v length] > 0) ? v : @"1"];
+ WOResponse_AddCString(_response, "\"");
+
+ if ([self->disabled boolValueInComponent:[_ctx component]])
+ WOResponse_AddCString(_response, " disabled=\"disabled\"");
- if (isChecked)
- WOResponse_AddCString(_response, " checked=\"checked\"");
+ if (isChecked)
+ WOResponse_AddCString(_response, " checked=\"checked\"");
- [self appendExtraAttributesToResponse:_response inContext:_ctx];
+ [self appendExtraAttributesToResponse:_response inContext:_ctx];
- if (self->otherTagString) {
- WOResponse_AddChar(_response, ' ');
- WOResponse_AddString(_response,
- [self->otherTagString stringValueInComponent:
- [_ctx component]]);
- }
-
- if (_ctx->wcFlags.xmlStyleEmptyElements) {
- WOResponse_AddCString(_response, " />\n");
- }
- else {
- WOResponse_AddCString(_response, ">\n");
- }
+ if (self->otherTagString) {
+ WOResponse_AddChar(_response, ' ');
+ WOResponse_AddString(_response,
+ [self->otherTagString stringValueInComponent:
+ [_ctx component]]);
+ }
+
+ if (_ctx->wcFlags.xmlStyleEmptyElements) {
+ WOResponse_AddCString(_response, " />\n");
+ }
+ else {
+ WOResponse_AddCString(_response, ">\n");
}
}
return self;
}
-#if !LIB_FOUNDATION_BOEHM_GC
- (void)dealloc {
- RELEASE(self->list);
- RELEASE(self->item);
- RELEASE(self->index);
- RELEASE(self->selections);
- RELEASE(self->prefix);
- RELEASE(self->suffix);
+ [self->list release];
+ [self->item release];
+ [self->index release];
+ [self->selections release];
+ [self->prefix release];
+ [self->suffix release];
[super dealloc];
}
-#endif
-// OWResponder
+/* OWResponder */
- (void)takeValuesFromRequest:(WORequest *)_request
inContext:(WOContext *)_ctx
Remember, the 'value' of a checkbox list is _not_ the form value but the
string besides the checkbox.
*/
- if (![self->disabled boolValueInComponent:[_ctx component]]) {
// could be optimized to use a single NAME with multiple values ..
WOComponent *sComponent = [_ctx component];
NSArray *array = [self->list valueInComponent:sComponent];
NSArray *selArray = nil;
unsigned goCount = [array count];
+
+ if ([self->disabled boolValueInComponent:[_ctx component]])
+ return;
- if (goCount > 0) {
- NSMutableArray *newSelection = nil;
- unsigned cnt;
+ if (goCount > 0) {
+ NSMutableArray *newSelection = nil;
+ unsigned cnt;
- if (self->selections)
- newSelection = [[NSMutableArray alloc] initWithCapacity:goCount];
+ if (self->selections)
+ newSelection = [[NSMutableArray alloc] initWithCapacity:goCount];
- [_ctx appendZeroElementIDComponent];
+ [_ctx appendZeroElementIDComponent];
- for (cnt = 0; cnt < goCount; cnt++) {
- id formValue = nil;
- id object = [array objectAtIndex:cnt];
-
- if (self->index)
- [self->index setUnsignedIntValue:cnt inComponent:sComponent];
-
- if (self->item)
- [self->item setValue:object inComponent:sComponent];
-
- formValue = [_request formValueForKey:OWFormElementName(self, _ctx)];
- if ([formValue isEqualToString:[self stringForInt:cnt]]) {
- if ((object != nil) && (self->selections != nil))
- [newSelection addObject:object];
- }
- [_ctx incrementLastElementIDComponent];
+ for (cnt = 0; cnt < goCount; cnt++) {
+ id formValue = nil;
+ id object = [array objectAtIndex:cnt];
+
+ if (self->index)
+ [self->index setUnsignedIntValue:cnt inComponent:sComponent];
+
+ if (self->item)
+ [self->item setValue:object inComponent:sComponent];
+
+ formValue = [_request formValueForKey:OWFormElementName(self, _ctx)];
+ if ([formValue isEqualToString:[self stringForInt:cnt]]) {
+ if ((object != nil) && (self->selections != nil))
+ [newSelection addObject:object];
}
+ [_ctx incrementLastElementIDComponent];
+ }
- [_ctx deleteLastElementIDComponent]; // list index
+ [_ctx deleteLastElementIDComponent]; // list index
- if (self->selections) {
- selArray = [newSelection copy];
- [newSelection release];
- }
+ if (self->selections) {
+ selArray = [newSelection copy];
+ [newSelection release];
}
- else if (self->selections)
- selArray = [[NSArray alloc] init];
+ }
+ else if (self->selections)
+ selArray = [[NSArray alloc] init];
- if ([self->selections isValueSettable])
- [self->selections setValue:selArray inComponent:sComponent];
+ if ([self->selections isValueSettable])
+ [self->selections setValue:selArray inComponent:sComponent];
- RELEASE(selArray);
- }
+ [selArray release];
}
-- (id)invokeActionForRequest:(WORequest *)_request inContext:(WOContext *)_ctx {
+- (id)invokeActionForRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
return nil;
}
+/* generate response */
+
- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
- if (![[_ctx request] isFromClientComponent]) {
- WOComponent *sComponent = [_ctx component];
- NSArray *array = [self->list valueInComponent:sComponent];
- unsigned goCount = [array count];
-
- if (goCount > 0) {
- NSArray *selArray = [self->selections valueInComponent:sComponent];
- unsigned cnt;
+ WOComponent *sComponent;
+ NSArray *array;
+ unsigned goCount;
+ NSArray *selArray;
+ unsigned cnt;
+ BOOL canSetIndex, canSetItem;
- [_ctx appendZeroElementIDComponent];
-
- for (cnt = 0; cnt < goCount; cnt++) {
- id object = [array objectAtIndex:cnt];
-
- if ([self->index isValueSettable])
- [self->index setUnsignedIntValue:cnt inComponent:sComponent];
+ if ([[_ctx request] isFromClientComponent])
+ return;
+
+ sComponent = [_ctx component];
+ array = [self->list valueInComponent:sComponent];
+ goCount = [array count];
- if ([self->item isValueSettable])
- [self->item setValue:object inComponent:sComponent];
+ if (goCount == 0)
+ return;
+
+ selArray = [self->selections valueInComponent:sComponent];
- if (self->prefix) {
- NSString *ps;
+ [_ctx appendZeroElementIDComponent];
- ps = [self->prefix stringValueInComponent:sComponent];
- WOResponse_AddString(_response, ps);
- }
+ canSetIndex = [self->index isValueSettable];
+ canSetItem = [self->item isValueSettable];
- /* add checkbox */
- {
- NSString *n = nil;
+ for (cnt = 0; cnt < goCount; cnt++) {
+ id object = [array objectAtIndex:cnt];
+
+ if (canSetIndex)
+ [self->index setUnsignedIntValue:cnt inComponent:sComponent];
+
+ if (canSetItem)
+ [self->item setValue:object inComponent:sComponent];
+
+ if (self->prefix != nil) {
+ NSString *ps;
+
+ ps = [self->prefix stringValueInComponent:sComponent];
+ WOResponse_AddString(_response, ps);
+ }
- n = self->name
- ? [self->name stringValueInComponent:sComponent]
- : OWFormElementName(self, _ctx);
+ /* add checkbox */
+ {
+ NSString *n = nil;
- WOResponse_AddCString(_response, "<input type=\"checkbox\" name=\"");
- [_response appendContentHTMLAttributeValue:n];
- WOResponse_AddCString(_response, "\" value=\"");
- WOResponse_AddInt(_response, cnt);
- WOResponse_AddCString(_response, "\"");
+ n = self->name
+ ? [self->name stringValueInComponent:sComponent]
+ : OWFormElementName(self, _ctx);
- if ([selArray containsObject:object])
- WOResponse_AddCString(_response, " checked=\"checked\"");
-
- [self appendExtraAttributesToResponse:_response inContext:_ctx];
+ WOResponse_AddCString(_response, "<input type=\"checkbox\" name=\"");
+ [_response appendContentHTMLAttributeValue:n];
+ WOResponse_AddCString(_response, "\" value=\"");
+ WOResponse_AddInt(_response, cnt);
+ WOResponse_AddCString(_response, "\"");
+
+ if ([selArray containsObject:object])
+ WOResponse_AddCString(_response, " checked=\"checked\"");
+
+ if ([self->disabled boolValueInComponent:sComponent])
+ WOResponse_AddCString(_response, " disabled=\"disabled\"");
+
+ [self appendExtraAttributesToResponse:_response inContext:_ctx];
- if (self->otherTagString) {
- WOResponse_AddChar(_response, ' ');
- WOResponse_AddString(_response,
- [self->otherTagString stringValueInComponent:
- [_ctx component]]);
- }
- WOResponse_AddEmptyCloseParens(_response, _ctx);
-
- // the value in a checkbox list is the string besides the checkbox
- if (self->value) {
- WOResponse_AddHtmlString(_response,
- [self->value stringValueInComponent:sComponent]);
- }
- }
-
- if (self->suffix) {
- NSString *ss;
-
- ss = [self->suffix stringValueInComponent:sComponent];
- WOResponse_AddString(_response, ss);
- }
- [_ctx incrementLastElementIDComponent];
+ if (self->otherTagString != nil) {
+ n = [self->otherTagString stringValueInComponent:sComponent];
+ WOResponse_AddChar(_response, ' ');
+ WOResponse_AddString(_response, n);
+ }
+ WOResponse_AddEmptyCloseParens(_response, _ctx);
+
+ // the value in a checkbox list is the string besides the checkbox
+ if (self->value != nil) {
+ n = [self->value stringValueInComponent:sComponent];
+ WOResponse_AddHtmlString(_response, n);
}
- [_ctx deleteLastElementIDComponent]; // list index
}
+
+ if (self->suffix != nil) {
+ NSString *ss;
+
+ ss = [self->suffix stringValueInComponent:sComponent];
+ WOResponse_AddString(_response, ss);
+ }
+ [_ctx incrementLastElementIDComponent];
}
+ [_ctx deleteLastElementIDComponent]; // list index
}
/* description */
- (NSString *)associationDescription {
NSMutableString *str;
- str = [[NSMutableString alloc] init];
+ str = [NSMutableString stringWithCapacity:256];
[str appendString:[super associationDescription]];
if (self->list) [str appendFormat:@" list=%@", self->list];
if (self->item) [str appendFormat:@" item=%@", self->item];
if (self->suffix) [str appendFormat:@" suffix=%@", self->suffix];
if (self->selections) [str appendFormat:@" selections=%@", self->selections];
- return AUTORELEASE(str);
+ return str;
}
@end /* WOCheckBoxList */
}
- (void)dealloc {
- RELEASE(self->actionClass);
- RELEASE(self->directActionName);
- RELEASE(self->queryDictionary);
- RELEASE(self->queryParameters);
- RELEASE(self->action);
- RELEASE(self->disabledFilename);
- RELEASE(self->framework);
- RELEASE(self->filename);
- RELEASE(self->src);
- RELEASE(self->pageName);
- RELEASE(self->x);
- RELEASE(self->y);
+ [self->actionClass release];
+ [self->directActionName release];
+ [self->queryDictionary release];
+ [self->queryParameters release];
+ [self->action release];
+ [self->disabledFilename release];
+ [self->framework release];
+ [self->filename release];
+ [self->src release];
+ [self->pageName release];
+ [self->x release];
+ [self->y release];
[super dealloc];
}
//NSLog(@"%s: take values ...", __PRETTY_FUNCTION__);
- if (self->disabled) {
+ if (self->disabled != nil) {
if ([self->disabled boolValueInComponent:sComponent])
return;
}
}
- (id)invokeActionForRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
- if (self->disabled) {
+ if (self->disabled != nil) {
if ([self->disabled boolValueInComponent:[_ctx component]])
return nil;
}
WOComponent *sComponent = [_ctx component];
NSString *uUri = nil;
NSString *uFi = nil;
+ BOOL isDisabled;
uUri = [self->src stringValueInComponent:sComponent];
-
- if ([self->disabled boolValueInComponent:sComponent]) {
+
+ if ((isDisabled = [self->disabled boolValueInComponent:sComponent])) {
uFi = [self->disabledFilename stringValueInComponent:sComponent];
if (uFi == nil)
uFi = [self->filename stringValueInComponent:sComponent];
}
else
uFi = [self->filename stringValueInComponent:sComponent];
-
- WOResponse_AddCString(_response, "<input type=\"image\" name=\"");
- [_response appendContentHTMLAttributeValue:OWFormElementName(self, _ctx)];
- WOResponse_AddChar(_response, '"');
+
+ if (isDisabled) {
+ WOResponse_AddCString(_response, "<img");
+ }
+ else {
+ WOResponse_AddCString(_response, "<input type=\"image\" name=\"");
+ [_response appendContentHTMLAttributeValue:OWFormElementName(self, _ctx)];
+ WOResponse_AddChar(_response, '"');
+ }
WOResponse_AddCString(_response, " src=\"");
- if (uFi) {
+ if (uFi != nil) {
WOResourceManager *rm;
NSArray *langs;
NSString *frameworkName;
else
[_response appendContentHTMLAttributeValue:uUri];
WOResponse_AddChar(_response, '"');
-
+
[self appendExtraAttributesToResponse:_response inContext:_ctx];
- if (self->otherTagString) {
+ if (self->otherTagString != nil) {
+ NSString *s;
+
+ s = [self->otherTagString stringValueInComponent:sComponent];
WOResponse_AddChar(_response, ' ');
- WOResponse_AddString(_response,
- [self->otherTagString stringValueInComponent:
- [_ctx component]]);
+ WOResponse_AddString(_response, s);
}
WOResponse_AddEmptyCloseParens(_response, _ctx);
}
@implementation WOPasswordField
-- (id)initWithName:(NSString *)_name
- associations:(NSDictionary *)_config
- template:(WOElement *)_root {
-
- if ((self = [super initWithName:_name associations:_config template:_root])) {
- self->size = OWGetProperty(_config, @"size");
+- (id)initWithName:(NSString *)_name associations:(NSDictionary *)_a
+ template:(WOElement *)_root
+{
+ if ((self = [super initWithName:_name associations:_a template:_root])) {
+ self->size = OWGetProperty(_a, @"size");
}
return self;
}
-#if !LIB_FOUNDATION_BOEHM_GC
- (void)dealloc {
- RELEASE(self->size); self->size = nil;
+ [self->size release];
[super dealloc];
}
-#endif
-// ******************** responder ********************
+/* generate response */
- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
- NSString *v = [self->value stringValueInComponent:[_ctx component]];
- unsigned int s = [self->size unsignedIntValueInComponent:[_ctx component]];
-
+ NSString *v;
+ unsigned int s;
+
+ v = [self->value stringValueInComponent:[_ctx component]];
+ s = [self->size unsignedIntValueInComponent:[_ctx component]];
+
WOResponse_AddCString(_response, "<input type=\"password\" name=\"");
[_response appendContentHTMLAttributeValue:OWFormElementName(self, _ctx)];
WOResponse_AddCString(_response, "\" value=\"");
[_response appendContentHTMLAttributeValue:v];
[_response appendContentCharacter:'"'];
+
if (s > 0) {
WOResponse_AddCString(_response, " size=\"");
WOResponse_AddUInt(_response, s);
[_response appendContentCharacter:'"'];
}
+
+ if ([self->disabled boolValueInComponent:[_ctx component]])
+ WOResponse_AddCString(_response, " disabled=\"disabled\"");
+
[self appendExtraAttributesToResponse:_response inContext:_ctx];
- if (self->otherTagString) {
+
+ if (self->otherTagString != nil) {
+ v = [self->otherTagString stringValueInComponent:[_ctx component]];
WOResponse_AddChar(_response, ' ');
- WOResponse_AddString(_response,
- [self->otherTagString stringValueInComponent:
- [_ctx component]]);
+ WOResponse_AddString(_response, v);
}
+
WOResponse_AddEmptyCloseParens(_response, _ctx);
}
- (NSString *)associationDescription {
NSMutableString *str = nil;
- str = [[NSMutableString alloc] initWithString:[super associationDescription]];
-
+
+ str = [NSMutableString stringWithCapacity:128];
+ [str appendString:[super associationDescription]];
+
if (self->size) [str appendFormat:@" size=%@", self->size];
-
- return AUTORELEASE(str);
+
+ return str;
}
@end /* WOPasswordField */
[self->item setValue:nil inComponent:sComponent]; // Reset 'item'
}
+/* generate response */
+
- (void)appendOptionsToResponse:(WOResponse *)_response
inContext:(WOContext *)_ctx
{
WOResponse_AddCString(_response, "<select name=\"");
[_response appendContentHTMLAttributeValue:OWFormElementName(self, _ctx)];
WOResponse_AddChar(_response, '"');
+
[self appendExtraAttributesToResponse:_response inContext:_ctx];
- if (self->otherTagString) {
+
+ if (self->otherTagString != nil) {
WOResponse_AddChar(_response, ' ');
WOResponse_AddString(_response,
[self->otherTagString stringValueInComponent:
[_ctx component]]);
}
+
+ if ([self->disabled boolValueInComponent:[_ctx component]])
+ WOResponse_AddCString(_response, " disabled=\"disabled\"");
+
WOResponse_AddChar(_response, '>');
[self appendOptionsToResponse:_response inContext:_ctx];
[_response appendContentHTMLAttributeValue:lvalue];
WOResponse_AddCString(_response, "\"");
- if (self->checked) {
+ if (self->checked != nil) {
if ([self->checked boolValueInComponent:sComponent])
WOResponse_AddCString(_response, " checked=\"checked\"");
}
else {
- id v = [self->value valueInComponent:sComponent];
- id sel = [self->selection valueInComponent:sComponent];
+ id v, sel;
- if ([v isEqual:sel])
+ v = [self->value valueInComponent:sComponent];
+ sel = [self->selection valueInComponent:sComponent];
+ if ((v == sel) || [v isEqual:sel])
WOResponse_AddCString(_response, " checked=\"checked\"");
}
+ if ([self->disabled boolValueInComponent:sComponent])
+ WOResponse_AddCString(_response, " disabled=\"disabled\"");
+
[self appendExtraAttributesToResponse:_response inContext:_ctx];
- if (self->otherTagString) {
+ if (self->otherTagString != nil) {
+ lvalue = [self->otherTagString stringValueInComponent:sComponent];
WOResponse_AddChar(_response, ' ');
- WOResponse_AddString(_response,
- [self->otherTagString stringValueInComponent:
- sComponent]);
+ WOResponse_AddString(_response, lvalue);
}
+
WOResponse_AddEmptyCloseParens(_response, _ctx);
}
unsigned cnt;
NSString *n;
id sel;
-
+ BOOL canSetIndex, canSetItem;
+
sComponent = [_ctx component];
array = [self->list valueInComponent:sComponent];
goCount = [array count];
n = OWFormElementName(self, _ctx);
sel = [self->selection valueInComponent:sComponent];
+ canSetIndex = [self->index isValueSettable];
+ canSetItem = [self->item isValueSettable];
+
for (cnt = 0; cnt < goCount; cnt++) {
- id object = [array objectAtIndex:cnt];
+ id object;
+
+ object = [array objectAtIndex:cnt];
- if ([self->index isValueSettable])
+ if (canSetIndex)
[self->index setUnsignedIntValue:cnt inComponent:sComponent];
-
- if ([self->item isValueSettable])
+
+ if (canSetItem)
[self->item setValue:object inComponent:sComponent];
- if (self->prefix) {
+ if (self->prefix != nil) {
WOResponse_AddString(_response,
[self->prefix stringValueInComponent:sComponent]);
}
WOResponse_AddCString(_response, "\" value=\"");
WOResponse_AddInt(_response, cnt);
WOResponse_AddCString(_response, "\"");
-
- if ([sel isEqual:object])
+
+ if (sel == object || [sel isEqual:object])
WOResponse_AddCString(_response, " checked=\"checked\"");
+
+ if ([self->disabled boolValueInComponent:sComponent])
+ WOResponse_AddCString(_response, " disabled=\"disabled\"");
+
[self appendExtraAttributesToResponse:_response inContext:_ctx];
- if (self->otherTagString) {
+ if (self->otherTagString != nil) {
+ NSString *s;
+
+ s = [self->otherTagString stringValueInComponent:sComponent];
WOResponse_AddChar(_response, ' ');
- WOResponse_AddString(_response,
- [self->otherTagString stringValueInComponent:
- [_ctx component]]);
+ WOResponse_AddString(_response, s);
}
WOResponse_AddEmptyCloseParens(_response, _ctx);
// the value in a radio list is the string besides the button
- if (self->value) {
+ if (self->value != nil) {
NSString *s;
s = [self->value stringValueInComponent:sComponent];
}
}
- if (self->suffix) {
+ if (self->suffix != nil) {
WOResponse_AddString(_response,
[self->suffix stringValueInComponent:sComponent]);
}
return self;
}
-#if !LIB_FOUNDATION_BOEHM_GC
- (void)dealloc {
- RELEASE(self->actionClass);
- RELEASE(self->directActionName);
- RELEASE(self->queryDictionary);
- RELEASE(self->queryParameters);
- RELEASE(self->action);
- RELEASE(self->pageName);
+ [self->actionClass release];
+ [self->directActionName release];
+ [self->queryDictionary release];
+ [self->queryParameters release];
+ [self->action release];
+ [self->pageName release];
[super dealloc];
}
-#endif
-// responder
+/* handle request */
-- (void)takeValuesFromRequest:(WORequest *)_request
- inContext:(WOContext *)_ctx
-{
+- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
id formValue;
- if (self->disabled) {
+ if (self->disabled != nil) {
if ([self->disabled boolValueInComponent:[_ctx component]])
return;
}
- if ((formValue = [_request formValueForKey:OWFormElementName(self, _ctx)])) {
+ if ((formValue = [_rq formValueForKey:OWFormElementName(self, _ctx)])) {
//NSLog(@"%@: value=%@ ..", [self elementID], formValue);
if ([self->value isValueSettable]) {
}
}
-- (id)invokeActionForRequest:(WORequest *)_request inContext:(WOContext *)_ctx {
- if (self->disabled) {
+- (id)invokeActionForRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
+ if (self->disabled != nil) {
if ([self->disabled boolValueInComponent:[_ctx component]])
return nil;
}
- /* check whether this is the active form element (determined in take-values) */
+ /*
+ check whether this is the active form element (determined in take-values)
+ */
if (![[_ctx elementID] isEqualToString:[_ctx senderID]]) {
NSLog(@"SUBMITBUTTON is not active (%@ vs %@) !",
[_ctx elementID], [_ctx senderID]);
return nil;
}
- if (self->action)
+ if (self->action != nil)
return [self executeAction:self->action inContext:_ctx];
if (self->pageName) {
@"%@[0x%08X]: did not find page with name %@ !",
NSStringFromClass([self class]), self, pname];
}
- NSLog(@"%@: showing page %@", self, page);
+ [self logWithFormat:@"showing page %@", page];
return page;
}
return nil;
}
-- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
- NSString *v = [self->value stringValueInComponent:[_ctx component]];
+/* generate response */
+- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
+ NSString *v;
+
+ v = [self->value stringValueInComponent:[_ctx component]];
WOResponse_AddCString(_response, "<input type=\"submit\" name=\"");
[_response appendContentHTMLAttributeValue:OWFormElementName(self, _ctx)];
WOResponse_AddCString(_response, "\" value=\"");
[_response appendContentHTMLAttributeValue:v];
WOResponse_AddChar(_response, '"');
+
+ if ([self->disabled boolValueInComponent:[_ctx component]])
+ WOResponse_AddCString(_response, " disabled=\"disabled\"");
+
[self appendExtraAttributesToResponse:_response inContext:_ctx];
- if (self->otherTagString) {
+ if (self->otherTagString != nil) {
+ v = [self->otherTagString stringValueInComponent:[_ctx component]];
WOResponse_AddChar(_response, ' ');
- WOResponse_AddString(_response,
- [self->otherTagString stringValueInComponent:
- [_ctx component]]);
+ WOResponse_AddString(_response, v);
}
WOResponse_AddEmptyCloseParens(_response, _ctx);
}
/* description */
- (NSString *)associationDescription {
- NSMutableString *str = [NSMutableString stringWithCapacity:128];
+ NSMutableString *str;
+
+ str = [NSMutableString stringWithCapacity:128];
[str appendString:[super associationDescription]];
+
if (self->action) [str appendFormat:@" action=%@", self->action];
if (self->pageName) [str appendFormat:@" page=%@", self->pageName];
-
+
if (self->actionClass)
[str appendFormat:@" actionClass=%@", self->actionClass];
if (self->directActionName)
- (id)initWithName:(NSString *)_name
associations:(NSDictionary *)_config
- template:(WOElement *)_root {
+ template:(WOElement *)_t
+{
- if ((self = [super initWithName:_name associations:_config template:_root])) {
+ if ((self = [super initWithName:_name associations:_config template:_t])) {
self->rows = OWGetProperty(_config, @"rows");
self->cols = OWGetProperty(_config, @"cols");
self->formatter = OWGetProperty(_config, @"formatter");
self->numberformat = OWGetProperty(_config, @"numberformat");
self->dateformat = OWGetProperty(_config, @"dateformat");
-
+
if (self->formatter == nil) {
- if ([_config objectForKey:@"formatterClass"]) {
+ if ([_config objectForKey:@"formatterClass"] != nil) {
id className;
className = OWGetProperty(_config, @"formatterClass");
/* formatter */
static inline NSFormatter *_getFormatter(WOText *self, WOContext *_ctx) {
- NSFormatter *fmt = nil;
+ NSFormatter *fmt = nil;
- if (self->numberformat) {
+ if (self->numberformat != nil) {
fmt = [[[NSNumberFormatter alloc] init] autorelease];
[(NSNumberFormatter *)fmt setFormat:
[self->numberformat valueInComponent:[_ctx component]]];
}
- else if (self->dateformat) {
+ else if (self->dateformat != nil) {
fmt = [[NSDateFormatter alloc]
initWithDateFormat:
[self->dateformat valueInComponent:
return fmt;
}
-// ******************** responder ********************
+/* handle requests */
- (id)parseFormValue:(id)_value inContext:(WOContext *)_ctx {
- NSFormatter *fmt = nil;
+ NSFormatter *fmt;
+ NSException *formatException = nil;
+ NSString *keyPath = nil;
+ NSString *errorText = nil;
+ id object = nil;
fmt = _getFormatter(self, _ctx);
-
- if (fmt) {
- NSString *errorText = nil;
- id object = nil;
+ if (fmt == nil)
+ return [super parseFormValue:_value inContext:_ctx];
- //fmt = [self->formatter valueInComponent:[_ctx component]];
+ //fmt = [self->formatter valueInComponent:[_ctx component]];
- if ([fmt getObjectValue:&object forString:[_value stringValue]
+ if ([fmt getObjectValue:&object forString:[_value stringValue]
errorDescription:&errorText]) {
return object;
- }
- else {
- NSException *formatException = nil;
- NSString *keyPath = nil;
+ }
+
- if ([self->value respondsToSelector:@selector(keyPath)])
- keyPath = [(id)self->value keyPath];
+ if ([self->value respondsToSelector:@selector(keyPath)])
+ keyPath = [(id)self->value keyPath];
- formatException = [NSException exceptionWithName:@"WOValidationException"
+ formatException = [NSException exceptionWithName:@"WOValidationException"
reason:errorText
userInfo:nil];
-
- [[_ctx component] validationFailedWithException:formatException
- value:_value
- keyPath:keyPath];
- return nil;
- }
- }
- else
- return [super parseFormValue:_value inContext:_ctx];
+
+ [[_ctx component] validationFailedWithException:formatException
+ value:_value
+ keyPath:keyPath];
+ return nil;
}
+/* generate response */
+
- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
WOComponent *sComponent;
NSFormatter *fmt;
WOResponse_AddUInt(_response, c);
WOResponse_AddChar(_response, '"');
}
+
+ if ([self->disabled boolValueInComponent:sComponent])
+ WOResponse_AddCString(_response, " disabled=\"disabled\"");
+
[self appendExtraAttributesToResponse:_response inContext:_ctx];
if (self->otherTagString) {
+ NSString *s;
+
+ s = [self->otherTagString stringValueInComponent:[_ctx component]];
WOResponse_AddChar(_response, ' ');
- WOResponse_AddString(_response,
- [self->otherTagString stringValueInComponent:
- [_ctx component]]);
+ WOResponse_AddString(_response, s);
}
WOResponse_AddChar(_response, '>');
str = [NSMutableString stringWithCapacity:64];
[str appendString:[super associationDescription]];
- if (self->rows) [str appendFormat:@" rows=%@", self->rows];
- if (self->cols) [str appendFormat:@" cols=%@", self->cols];
+ if (self->rows) [str appendFormat:@" rows=%@", self->rows];
+ if (self->cols) [str appendFormat:@" cols=%@", self->cols];
if (self->formatter) [str appendFormat:@" formatter=%@", self->formatter];
if (self->dateformat) [str appendFormat:@" dateformat=%@", self->dateformat];
if (self->numberformat)
[str appendFormat:@" numberformat=%@", self->numberformat];
-
+
return str;
}
- (id)initWithName:(NSString *)_name
associations:(NSDictionary *)_config
- template:(WOElement *)_root
+ template:(WOElement *)_t
{
- if ((self = [super initWithName:_name associations:_config template:_root])) {
+ if ((self = [super initWithName:_name associations:_config template:_t])) {
self->size = OWGetProperty(_config, @"size");
self->formatter = OWGetProperty(_config, @"formatter");
self->numberformat = OWGetProperty(_config, @"numberformat");
if (self->formatter == nil) {
if ([_config objectForKey:@"formatterClass"]) {
id className;
-
- className = OWGetProperty(_config, @"formatterClass");
- className = AUTORELEASE(className);
-
+
+ className = [OWGetProperty(_config, @"formatterClass") autorelease];
className = [className valueInComponent:nil];
className = NSClassFromString(className);
className = [[className alloc] init];
- self->formatter = [WOAssociation associationWithValue:className];
- self->formatter = RETAIN(self->formatter);
- RELEASE(className);
+ self->formatter =
+ [[WOAssociation associationWithValue:className] retain];
+ [className release];
}
}
/* formatter */
static inline NSFormatter *_getFormatter(WOTextField *self, WOContext *_ctx) {
- NSFormatter *fmt = nil;
+ // TODO: a DUP to WOText?
+ NSFormatter *fmt = nil;
- if (self->numberformat) {
+ if (self->numberformat != nil) {
fmt = [[[NSNumberFormatter alloc] init] autorelease];
[(NSNumberFormatter *)fmt setFormat:
[self->numberformat valueInComponent:[_ctx component]]];
}
- else if (self->dateformat) {
+ else if (self->dateformat != nil) {
fmt = [[NSDateFormatter alloc]
initWithDateFormat:
[self->dateformat valueInComponent:
allowNaturalLanguage:NO];
fmt = [fmt autorelease];
}
- else if (self->formatter) {
+ else if (self->formatter != nil) {
fmt = [self->formatter valueInComponent:[_ctx component]];
}
return fmt;
}
-// ******************** responder ********************
+/* handle requests */
- (id)parseFormValue:(id)_value inContext:(WOContext *)_ctx {
- NSFormatter *fmt = nil;
-
- fmt = _getFormatter(self, _ctx);
+ // TODO: a DUP to WOText?
+ NSException *formatException = nil;
+ NSString *keyPath = nil;
+ NSFormatter *fmt;
+ NSString *errorText = nil;
+ id object = nil;
+
+ if ((fmt = _getFormatter(self, _ctx)) == nil)
+ return [super parseFormValue:_value inContext:_ctx];
- if (fmt) {
- NSString *errorText = nil;
- id object = nil;
-
- //fmt = [self->formatter valueInComponent:[_ctx component]];
+ //fmt = [self->formatter valueInComponent:[_ctx component]];
- if ([fmt getObjectValue:&object forString:[_value stringValue]
+ if ([fmt getObjectValue:&object forString:[_value stringValue]
errorDescription:&errorText]) {
- return object;
- }
- else {
- NSException *formatException = nil;
- NSString *keyPath = nil;
-
- if ([self->value respondsToSelector:@selector(keyPath)])
- keyPath = [(id)self->value keyPath];
-
- formatException = [NSException exceptionWithName:@"WOValidationException"
- reason:errorText
- userInfo:nil];
-
- [[_ctx component] validationFailedWithException:formatException
- value:_value
- keyPath:keyPath];
- return nil;
- }
+ return object;
}
- else
- return [super parseFormValue:_value inContext:_ctx];
+
+ if ([self->value respondsToSelector:@selector(keyPath)])
+ keyPath = [(id)self->value keyPath];
+
+ formatException = [NSException exceptionWithName:@"WOValidationException"
+ reason:errorText
+ userInfo:nil];
+
+ [[_ctx component] validationFailedWithException:formatException
+ value:_value
+ keyPath:keyPath];
+ return nil;
}
+/* generate response */
+
- (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
- NSFormatter *fmt = nil;
- id obj = nil;
- unsigned s = 0;
+ NSFormatter *fmt;
+ id obj;
+ unsigned s;
obj = [self->value valueInComponent:[_ctx component]];
s = [self->size unsignedIntValueInComponent:[_ctx component]];
- fmt = _getFormatter(self, _ctx);
- if (fmt) {
- NSString *formattedObj = nil;
+ if ((fmt = _getFormatter(self, _ctx)) != nil) {
+ NSString *formattedObj;
formattedObj = [fmt editingStringForObjectValue:obj];
WOResponse_AddUInt(_response, s);
WOResponse_AddChar(_response, '"');
}
+
+ if (self->disabled != nil) {
+ if ([self->disabled boolValueInComponent:[_ctx component]])
+ WOResponse_AddCString(_response, " disabled=\"disabled\"");
+ }
+
[self appendExtraAttributesToResponse:_response inContext:_ctx];
if (self->otherTagString) {
WOResponse_AddChar(_response, ' ');
- (id)invokeActionForRequest:(WORequest *)_request
inContext:(WOContext *)_ctx
{
- if (self->disabled) {
+ if (self->disabled != nil) {
if ([self->disabled boolValueInComponent:[_ctx component]])
return nil;
}
@end /* _WOComplexHyperlink */
+
@implementation _WOHrefHyperlink
static BOOL debugStaticLinks = NO;
# version file
-SUBMINOR_VERSION:=138
+SUBMINOR_VERSION:=139
# v4.5.122 requires libNGExtensions v4.5.153
# v4.5.91 requires libNGExtensions v4.5.134