]> err.no Git - sope/commitdiff
added support for 'disabled' binding as in WO
authorhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Sun, 20 Mar 2005 23:09:45 +0000 (23:09 +0000)
committerhelge <helge@e4a50df8-12e2-0310-a44c-efbce7f8a7e3>
Sun, 20 Mar 2005 23:09:45 +0000 (23:09 +0000)
git-svn-id: http://svn.opengroupware.org/SOPE/trunk@678 e4a50df8-12e2-0310-a44c-efbce7f8a7e3

14 files changed:
sope-appserver/NGObjWeb/ChangeLog
sope-appserver/NGObjWeb/DynamicElements/WOBrowser.m
sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m
sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m
sope-appserver/NGObjWeb/DynamicElements/WOImageButton.m
sope-appserver/NGObjWeb/DynamicElements/WOPasswordField.m
sope-appserver/NGObjWeb/DynamicElements/WOPopUpButton.m
sope-appserver/NGObjWeb/DynamicElements/WORadioButton.m
sope-appserver/NGObjWeb/DynamicElements/WORadioButtonList.m
sope-appserver/NGObjWeb/DynamicElements/WOSubmitButton.m
sope-appserver/NGObjWeb/DynamicElements/WOText.m
sope-appserver/NGObjWeb/DynamicElements/WOTextField.m
sope-appserver/NGObjWeb/DynamicElements/_WOComplexHyperlink.m
sope-appserver/NGObjWeb/Version

index 4f3d8e1b91a1ad837fb6419a253cd2e0759ec4e8..86240c9a38d674c5b1744834988d2aec2b8a39e7 100644 (file)
@@ -1,8 +1,20 @@
 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 &amp; as
          suggested by Stephane (v4.5.138)
-
+       
 2005-03-15  Marcus Mueller  <znek@mulle-kybernetik.com>
 
        * NGObjWeb.xcode: added WOWatchDogApplicationMainOSX.m and removed
index 4261f6df647cb917c340748860713720700785a6..fdd07c9c1bed17f3ae92175c68b62b5f1d8acf90 100644 (file)
   
   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\"");
index 5510870fbf8ded1b2b81ba12b85dd21f76604b6f..8a6bbfc99b34f7a769c16e8ebd20a7015ad859a5 100644 (file)
 }
 
 - (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");
   }
 }
 
index 06c48a06930ca827bb504c1e2f62e801f90e3715..9e2290fdae227f28da978df5abc474d5ee6c6bcb 100644 (file)
   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 */
index e28e3538c46ed9291e0bc62bff68bbe39662cc7f..839ece94abee7477b8a73872dd9f995cfac8e196 100644 (file)
 }
 
 - (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);
 }
index 76a2394423af8b8fc0f4683828d99abd0debd729..ef37ab4e90415c3fd5e1655d4dbded632b4726f4 100644 (file)
 
 @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 */
index 664d2a0f35270975a8788f04308f287c85640189..2947c8fac3cfe582b42d7aef0d292303fdcf4aa3 100644 (file)
@@ -231,6 +231,8 @@ static NSNumber *yesNum = nil;
     [self->item setValue:nil inComponent:sComponent]; // Reset 'item'
 }
 
+/* generate response */
+
 - (void)appendOptionsToResponse:(WOResponse *)_response
   inContext:(WOContext *)_ctx
 {
@@ -376,13 +378,19 @@ static NSNumber *yesNum = nil;
   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];
index 84282001c551ee497c0b465368645f16bf41dfbc..4451bf365d2339ef3451513805c3bfe86fd74d3e 100644 (file)
   [_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);
 }
 
index 8cc254fdace197de71d194e033cf58e9630cfecd..254f53053360dd084d39aee5760c1e5c6d84f4c6 100644 (file)
   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]);
     }
index 05abea48e0ca7ab74271fb87d23ae5f8359acbc1..840a2d35dc3f59c58483c9676e6d8c7e26296a6d 100644 (file)
   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)
index fb76149250a2acb654013486004e2c8665349995..3b7506f3080392d9f088efb7b010eca362da1738 100644 (file)
 
 - (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:
@@ -121,45 +122,43 @@ static inline NSFormatter *_getFormatter(WOText *self, WOContext *_ctx) {
   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;
@@ -195,12 +194,17 @@ static inline NSFormatter *_getFormatter(WOText *self, WOContext *_ctx) {
     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, '>');
 
@@ -230,13 +234,13 @@ static inline NSFormatter *_getFormatter(WOText *self, WOContext *_ctx) {
   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;
 }
 
index a4eb1530233fc1ebb24ac7f61b49f25966f20984..9b56f44250e3e2dc8ff80e195a36c554f24a6c0c 100644 (file)
@@ -62,9 +62,9 @@
 
 - (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:
@@ -126,63 +125,59 @@ static inline NSFormatter *_getFormatter(WOTextField *self, WOContext *_ctx) {
                             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];
 
@@ -205,6 +200,12 @@ static inline NSFormatter *_getFormatter(WOTextField *self, WOContext *_ctx) {
     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, ' ');
index 058fee763510b36002b85263d445616cf19ea02b..b159c3637692067d8c54fd4fe73280c0fdedf677 100644 (file)
@@ -182,7 +182,7 @@ static Class NSURLClass = Nil;
 - (id)invokeActionForRequest:(WORequest *)_request
   inContext:(WOContext *)_ctx
 {
-  if (self->disabled) {
+  if (self->disabled != nil) {
     if ([self->disabled boolValueInComponent:[_ctx component]])
       return nil;
   }
@@ -334,6 +334,7 @@ static Class NSURLClass = Nil;
 
 @end /* _WOComplexHyperlink */
 
+
 @implementation _WOHrefHyperlink
 
 static BOOL debugStaticLinks = NO;
index d1260870f185ca8546a55cf5f5e75da47d4a7234..39200753174934a5fecc93cac5c0f57a8395efaf 100644 (file)
@@ -1,6 +1,6 @@
 # version file
 
-SUBMINOR_VERSION:=138
+SUBMINOR_VERSION:=139
 
 # v4.5.122 requires libNGExtensions v4.5.153
 # v4.5.91  requires libNGExtensions v4.5.134