From 92a74ba31fc7c820dfd2c51299a6015398164274 Mon Sep 17 00:00:00 2001 From: helge Date: Wed, 30 Mar 2005 23:04:32 +0000 Subject: [PATCH] added some support to generate empty attributes (like selected or checked) git-svn-id: http://svn.opengroupware.org/SOPE/trunk@709 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- sope-appserver/NGObjWeb/ChangeLog | 18 +++++++- .../NGObjWeb/DynamicElements/WOBrowser.m | 9 +++- .../NGObjWeb/DynamicElements/WOCheckBox.m | 41 ++++++++++--------- .../NGObjWeb/DynamicElements/WOCheckBoxList.m | 14 ++++--- .../NGObjWeb/DynamicElements/WOPopUpButton.m | 13 ++++-- .../NGObjWeb/DynamicElements/WORadioButton.m | 18 +++++--- .../DynamicElements/WORadioButtonList.m | 18 ++++---- sope-appserver/NGObjWeb/NGObjWeb/WOContext.h | 5 ++- sope-appserver/NGObjWeb/Version | 2 +- sope-appserver/NGObjWeb/WOContext.m | 8 ++++ 10 files changed, 100 insertions(+), 46 deletions(-) diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 8bf2e857..96ce32c2 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,4 +1,20 @@ -2005-03-31 Stephane Corthesy +2005-03-31 Helge Hess + + * v4.5.147 + + * DynamicElements/WOCheckBox.m, DynamicElements/WOCheckBoxList.m, + DynamicElements/WORadioButton.m, DynamicElements/WORadioButtonList.m: + added support for empty 'disabled' and 'checked' attributes, removed + '\n' after generated tag + + * DynamicElements/WOBrowser.m, DynamicElements/WOPopUpButton.m: added + support for empty "selected" attribute + + * WOContext.m: added new flag/accessor 'generateEmptyAttributes' to + put elements into a mode where they do not render XHTML style + attributes (just 'selected' instead of 'selected="selected"') + +2005-03-30 Stephane Corthesy * DynamicElements/WOPopUpButton.m, DynamicElements/WOPopUpButton.api: added new binding 'itemGroup' which allows generation of the diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOBrowser.m b/sope-appserver/NGObjWeb/DynamicElements/WOBrowser.m index fdd07c9c..0900cb8c 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOBrowser.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOBrowser.m @@ -321,8 +321,13 @@ WOResponse_AddCString(_response, ""); } diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m b/sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m index 8a6bbfc9..fb265f2b 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOCheckBox.m @@ -55,29 +55,28 @@ [super dealloc]; } -// ******************** OWResponder ******************** +/* handling requests */ -- (void)takeValuesFromRequest:(WORequest *)_request - inContext:(WOContext *)_ctx -{ +- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx { /* Checkboxes are special in their form-value handling. If the form is submitted and the checkbox is checked, a 'YES' value is transferred in the request. If the checkbox is not-checked, no value is transferred at all ! */ - if (![self->disabled boolValueInComponent:[_ctx component]]) { - id formValue; + id formValue; + + if ([self->disabled boolValueInComponent:[_ctx component]]) + return; - formValue = [_request formValueForKey:OWFormElementName(self, _ctx)]; + formValue = [_rq formValueForKey:OWFormElementName(self, _ctx)]; - if ([self->checked isValueSettable]) { + if ([self->checked isValueSettable]) { [self->checked setBoolValue:formValue ? YES : NO inComponent:[_ctx component]]; - } - - if ([self->value isValueSettable] && (formValue != nil)) - [self->value setStringValue:formValue inComponent:[_ctx component]]; } + + if ([self->value isValueSettable] && (formValue != nil)) + [self->value setStringValue:formValue inComponent:[_ctx component]]; } - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx { @@ -97,12 +96,16 @@ [_response appendContentHTMLAttributeValue:([v length] > 0) ? v : @"1"]; WOResponse_AddCString(_response, "\""); - if ([self->disabled boolValueInComponent:[_ctx component]]) - WOResponse_AddCString(_response, " disabled=\"disabled\""); + if ([self->disabled boolValueInComponent:[_ctx component]]) { + WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes + ? " disabled" : " disabled=\"disabled\""); + } + + if (isChecked) { + WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes + ? " checked" : " checked=\"checked\""); + } - if (isChecked) - WOResponse_AddCString(_response, " checked=\"checked\""); - [self appendExtraAttributesToResponse:_response inContext:_ctx]; if (self->otherTagString) { @@ -113,10 +116,10 @@ } if (_ctx->wcFlags.xmlStyleEmptyElements) { - WOResponse_AddCString(_response, " />\n"); + WOResponse_AddCString(_response, " />"); } else { - WOResponse_AddCString(_response, ">\n"); + WOResponse_AddCString(_response, ">"); } } diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m b/sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m index 9e2290fd..a22794fa 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOCheckBoxList.m @@ -192,12 +192,16 @@ 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\""); + if ([self->disabled boolValueInComponent:sComponent]) { + WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes + ? " disabled" : " disabled=\"disabled\""); + } + + if ([selArray containsObject:object]) { + WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes + ? " checked" : " checked=\"checked\""); + } [self appendExtraAttributesToResponse:_response inContext:_ctx]; diff --git a/sope-appserver/NGObjWeb/DynamicElements/WOPopUpButton.m b/sope-appserver/NGObjWeb/DynamicElements/WOPopUpButton.m index 07287468..73993c07 100644 --- a/sope-appserver/NGObjWeb/DynamicElements/WOPopUpButton.m +++ b/sope-appserver/NGObjWeb/DynamicElements/WOPopUpButton.m @@ -394,9 +394,16 @@ static NSNumber *yesNum = nil; } WOResponse_AddCString(_response, "