-2005-03-31 Stephane Corthesy <stephane@sente.ch>
+2005-03-31 Helge Hess <helge.hess@opengroupware.org>
+
+ * 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 <stephane@sente.ch>
* DynamicElements/WOPopUpButton.m, DynamicElements/WOPopUpButton.api:
added new binding 'itemGroup' which allows generation of the
WOResponse_AddCString(_response, "<option value=\"");
WOResponse_AddString(_response, v);
- WOResponse_AddString(_response,
- isSelected ? @"\" selected=\"selected\">" : @"\">");
+ if (isSelected) {
+ WOResponse_AddString(_response, _ctx->wcFlags.allowEmptyAttributes
+ ? @"\" selected>" : @"\" selected=\"selected\">");
+ }
+ else {
+ WOResponse_AddString(_response, @"\">");
+ }
WOResponse_AddHtmlString(_response, displayV);
WOResponse_AddCString(_response, "</option>");
}
[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 {
[_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) {
}
if (_ctx->wcFlags.xmlStyleEmptyElements) {
- WOResponse_AddCString(_response, " />\n");
+ WOResponse_AddCString(_response, " />");
}
else {
- WOResponse_AddCString(_response, ">\n");
+ WOResponse_AddCString(_response, ">");
}
}
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];
}
WOResponse_AddCString(_response, "<option value=\"");
WOResponse_AddHtmlString(_response, v); // WO escapes it, always
- WOResponse_AddCString(_response,
- isSelected ?
- "\" selected=\"selected\">" : "\">");
+
+ if (isSelected) {
+ WOResponse_AddString(_response,
+ _ctx->wcFlags.allowEmptyAttributes
+ ? @"\" selected>" : @"\" selected=\"selected\">");
+ }
+ else {
+ WOResponse_AddString(_response, @"\">");
+ }
+
if (escapesHTML){
WOResponse_AddHtmlString(_response, displayV);
}
WOResponse_AddCString(_response, "\"");
if (self->checked != nil) {
- if ([self->checked boolValueInComponent:sComponent])
- WOResponse_AddCString(_response, " checked=\"checked\"");
+ if ([self->checked boolValueInComponent:sComponent]) {
+ WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes
+ ? " checked" : " checked=\"checked\"");
+ }
}
else {
id v, sel;
v = [self->value valueInComponent:sComponent];
sel = [self->selection valueInComponent:sComponent];
- if ((v == sel) || [v isEqual:sel])
- WOResponse_AddCString(_response, " checked=\"checked\"");
+ if ((v == sel) || [v isEqual:sel]) {
+ WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes
+ ? " checked" : " 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\"");
+ }
[self appendExtraAttributesToResponse:_response inContext:_ctx];
if (self->otherTagString != nil) {
/* processing requests */
-- (void)takeValuesFromRequest:(WORequest *)_request
- inContext:(WOContext *)_ctx
-{
+- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx {
WOComponent *sComponent = [_ctx component];
unsigned idx;
NSArray *array;
if ([self->disabled boolValueInComponent:sComponent])
return;
- formValue = [_request formValueForKey:OWFormElementName(self, _ctx)];
+ formValue = [_rq formValueForKey:OWFormElementName(self, _ctx)];
if (formValue == nil)
return;
WOResponse_AddInt(_response, cnt);
WOResponse_AddCString(_response, "\"");
- if (sel == object || [sel isEqual:object])
- WOResponse_AddCString(_response, " checked=\"checked\"");
+ if (sel == object || [sel isEqual:object]) {
+ WOResponse_AddCString(_response, _ctx->wcFlags.allowEmptyAttributes
+ ? " checked" : " 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\"");
+ }
[self appendExtraAttributesToResponse:_response inContext:_ctx];
if (self->otherTagString != nil) {
int savePageRequired:1; /* tracking component actions */
int inForm:1;
int xmlStyleEmptyElements:1;
- int reserved:29;
+ int allowEmptyAttributes:1;
+ int reserved:28;
} wcFlags;
@protected
- (void)setGenerateXMLStyleEmptyElements:(BOOL)_flag;
- (BOOL)generateXMLStyleEmptyElements;
+- (void)setGenerateEmptyAttributes:(BOOL)_flag;
+- (BOOL)generateEmptyAttributes;
/* variables */
# version file
-SUBMINOR_VERSION:=146
+SUBMINOR_VERSION:=147
# v4.5.122 requires libNGExtensions v4.5.153
# v4.5.91 requires libNGExtensions v4.5.134
/* per default close tags in XML style */
self->wcFlags.xmlStyleEmptyElements = 1;
+ self->wcFlags.allowEmptyAttributes = 0;
self->elementID = [[WOElementID alloc] init];
self->awakeComponents = [[NSMutableSet alloc] initWithCapacity:64];
return self->wcFlags.xmlStyleEmptyElements ? YES : NO;
}
+- (void)setGenerateEmptyAttributes:(BOOL)_flag {
+ self->wcFlags.allowEmptyAttributes = _flag ? 1 : 0;
+}
+- (BOOL)generateEmptyAttributes {
+ return self->wcFlags.allowEmptyAttributes ? YES : NO;
+}
+
- (NSString *)queryStringFromDictionary:(NSDictionary *)_queryDict {
NSEnumerator *keys;
NSString *key;