diff --git a/ChangeLog b/ChangeLog index e33f445..ada326e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2014-05-29 Manuel Guesdon + * GSWDatabase/GSWHTMLDynamicElement.[hm] + add -hasNonURLAttributes + add -hasURLAttributes + add -hasConstantAttributes + * GSWeb/GSWRadioButtonList.m + handle disabled association + handle other associations (like id, onChange, etc) + * GSWeb/GSWCheckBoxList.m + handle disabled association + handle other associations (like id, onChange, etc) 2014-05-29 Manuel Guesdon * GSWDatabase/WODisplayGroup.m add NSArray -objectsAtIndexesArray: diff --git a/GSWeb/GSWCheckBoxList.m b/GSWeb/GSWCheckBoxList.m index c5df8e6..de8be81 100644 --- a/GSWeb/GSWCheckBoxList.m +++ b/GSWeb/GSWCheckBoxList.m @@ -280,6 +280,10 @@ static Class standardClass = Nil; BOOL doEscape = NO; id selections = nil; IMP oaiIMP=NULL; + BOOL isDisabled=[self disabledInComponent:GSWContext_component(context)]; + BOOL hasConstantAttributes=[self hasConstantAttributes]; + BOOL hasNonURLAttributes=[self hasNonURLAttributes]; + BOOL hasURLAttributes=[self hasURLAttributes]; if (_escapeHTML==nil) doEscape=_defaultEscapeHTML; @@ -355,9 +359,33 @@ static Class standardClass = Nil; GSWResponse_appendContentAsciiString(response,GSWIntToNSString(i)); if ([selections containsObject:item]) - GSWResponse_appendContentAsciiString(response,@"\" checked>"); + GSWResponse_appendContentAsciiString(response,@"\" checked"); else - GSWResponse_appendContentAsciiString(response,@"\">"); + GSWResponse_appendContentAsciiString(response,@"\""); + + if (isDisabled) + GSWResponse_appendContentAsciiString(response,@" disabled"); + + //append other associations (like id, onChange, ...) + if (hasConstantAttributes) + { + [self appendConstantAttributesToResponse: response + inContext: context]; + } + + if (hasNonURLAttributes) + { + [self appendNonURLAttributesToResponse: response + inContext: context]; + } + + if (hasURLAttributes) + { + [self appendURLAttributesToResponse: response + inContext: context]; + } + + GSWResponse_appendContentCharacter(response,'>'); if (prefixStr != nil) GSWResponse_appendContentString(response,prefixStr); diff --git a/GSWeb/GSWHTMLDynamicElement.h b/GSWeb/GSWHTMLDynamicElement.h index 599356a..a1c734d 100644 --- a/GSWeb/GSWHTMLDynamicElement.h +++ b/GSWeb/GSWHTMLDynamicElement.h @@ -66,12 +66,15 @@ directActionNameAssociation:(GSWAssociation*)directActionName inContext:(GSWContext*)context; +-(BOOL) hasNonURLAttributes; -(void) appendNonURLAttributesToResponse:(GSWResponse*) response inContext:(GSWContext*) context; +-(BOOL) hasURLAttributes; -(void) appendURLAttributesToResponse:(GSWResponse*) response inContext:(GSWContext*) context; +-(BOOL) hasConstantAttributes; -(void) appendConstantAttributesToResponse:(GSWResponse*) response inContext:(GSWContext*)aContext; diff --git a/GSWeb/GSWHTMLDynamicElement.m b/GSWeb/GSWHTMLDynamicElement.m index bf39d92..565957f 100644 --- a/GSWeb/GSWHTMLDynamicElement.m +++ b/GSWeb/GSWHTMLDynamicElement.m @@ -539,6 +539,15 @@ static inline BOOL _needQuote(NSString* str_needQuote) return newQueryDictionary; } +//-------------------------------------------------------------------- +//Used by childs like GSW(CheckBox|RadioButton)List to avoid calling +//multiple time appendConstantAttributesToResponse: if there's nothing +//to do +-(BOOL)hasConstantAttributes +{ + return ([[self constantAttributesRepresentation] length]>0 ? YES : NO); +} + //-------------------------------------------------------------------- -(void) appendConstantAttributesToResponse:(GSWResponse*) response inContext:(GSWContext*)aContext @@ -582,6 +591,15 @@ static inline BOOL _needQuote(NSString* str_needQuote) } } +//-------------------------------------------------------------------- +//Used by childs like GSW(CheckBox|RadioButton)List to avoid calling +//multiple time appendNonURLAttributesToResponse: if there's nothing +//to do +-(BOOL)hasNonURLAttributes +{ + return ([[self nonUrlAttributeAssociations] count]>0 ? YES : NO); +} + //-------------------------------------------------------------------- -(void) appendNonURLAttributesToResponse:(GSWResponse*) response inContext:(GSWContext*) context @@ -593,6 +611,15 @@ static inline BOOL _needQuote(NSString* str_needQuote) } +//-------------------------------------------------------------------- +//Used by childs like GSW(CheckBox|RadioButton)List to avoid calling +//multiple time appendURLAttributesToResponse: if there's nothing +//to do +-(BOOL)hasURLAttributes +{ + return ([[self urlAttributeAssociations] count]>0 ? YES : NO); +} + //-------------------------------------------------------------------- -(void) appendURLAttributesToResponse:(GSWResponse*) response inContext:(GSWContext*) context diff --git a/GSWeb/GSWRadioButtonList.m b/GSWeb/GSWRadioButtonList.m index 2031d3d..2f62ebc 100644 --- a/GSWeb/GSWRadioButtonList.m +++ b/GSWeb/GSWRadioButtonList.m @@ -265,6 +265,10 @@ static Class standardClass = Nil; NSString* ctxName = [self nameInContext:context]; id selection = [_selection valueInComponent:component]; IMP list_oaiIMP=NULL; + BOOL isDisabled=[self disabledInComponent:GSWContext_component(context)]; + BOOL hasConstantAttributes=[self hasConstantAttributes]; + BOOL hasNonURLAttributes=[self hasNonURLAttributes]; + BOOL hasURLAttributes=[self hasURLAttributes]; for (i = 0; i < count; i++) { @@ -329,10 +333,34 @@ static Class standardClass = Nil; if (selection != nil && [selection isEqual:item]) - GSWResponse_appendContentAsciiString(response,@"\" checked>"); + GSWResponse_appendContentAsciiString(response,@"\" checked"); else - GSWResponse_appendContentAsciiString(response,@"\">"); + GSWResponse_appendContentAsciiString(response,@"\""); + if (isDisabled) + GSWResponse_appendContentAsciiString(response,@" disabled"); + + //append other associations (like id, onChange, ...) + if (hasConstantAttributes) + { + [self appendConstantAttributesToResponse: response + inContext: context]; + } + + if (hasNonURLAttributes) + { + [self appendNonURLAttributesToResponse: response + inContext: context]; + } + + if (hasURLAttributes) + { + [self appendURLAttributesToResponse: response + inContext: context]; + } + + GSWResponse_appendContentCharacter(response,'>'); + if (prefixStr != nil) GSWResponse_appendContentString(response,prefixStr);