libs-gsweb/GSWeb.framework/GSWSwitchComponent.m

187 lines
6.3 KiB
Mathematica
Raw Normal View History

/* GSWSwitchComponent.m - GSWeb: Class GSWSwitchComponent
Copyright (C) 1999 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@sbuilders.com>
Date: Jan 1999
This file is part of the GNUstep Web Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
static char rcsId[] = "$Id$";
#include <GSWeb/GSWeb.h>
//====================================================================
@implementation GSWSwitchComponent
//--------------------------------------------------------------------
-(id)initWithName:(NSString*)name_
associations:(NSDictionary*)associations_
template:(GSWElement*)templateElement_
{
LOGObjectFnStartC("GSWSwitchComponent");
if ((self=[super initWithName:name_
2002-01-26 Manuel Guesdon <mguesdon@orange-concept.com> * GSWeb.framework/GSWSwitchComponent.m: o logs o corected bug: use GSWComponentName__Key[] * GSWeb.framework/GSWSession.m: o logs * GSWExtensions.framework/GSWExtensions.m: o added better formatting * GSWExtensions.framework/GSWExtensions.gswc/GSWExtensions.HTML: o added better formatting * GSWExtensions.framework/French.lproj/GSWExtensions.gswc/GSWExtensions.HTML: o added better formatting * GSWExtensionsGSW.framework/GSWLogin.m: o added -login exception cataching to add exception verbosity. * GSWeb.framework/GSWDynamicElement.m/.h: o logs o added ivar _definitionName and associated methods * GSWeb.framework/GSWElement.m/.h: o added ivar -definitionName * GSWeb.framework/GSWTemplateParserANTLR.m: o set dynamic element definition name * GSWeb.framework/GSWTemplateParserXML.m: o set dynamic element definition name * GSWeb.framework/GSWConditional.m: o logs * GSWeb.framework/GSWComponent.m: o logs o remove GDL2 code in -valueForBinding: and setValue:forBinding: I don't see a reason for this code and it may make a loop * GSWeb.framework/GSWAssociation.m: o logs o Fix in validateValue:forKeyPath: test & call * GSWeb.framework/GSWDisplayGroup.m: o logs * GSWeb.framework/GSWBundle.m: o logs * GSWeb.framework/GSWImageButton.m: o logs (element definition name) * GSWeb.framework/GSWForm.m: o logs (element definition name) o stop invokeActionForRequest:inContext: when the current Id is after senderID * GSWeb.framework: GSWElementIDString.m o added -compare:options:range: * GSWeb.framework: GSWHTMLDynamicElement.m o stop invokeActionForRequest:inContext: when the current Id is after senderID * GSWeb.framework: GSWHTMLStaticElement.m o stop invokeActionForRequest:inContext: when the current Id is after senderID * GSWExtensions.framework/WebServerResources: o converted .gif to .png * GSWeb.framework/GSWUtils.m: o removed members in NSUserDefaults description git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@12219 72102866-910b-0410-8b05-ffd578937521
2002-01-26 10:43:23 +00:00
associations:associations_
template:nil]))
{
NSMutableDictionary* _associations=[NSMutableDictionary dictionaryWithDictionary:associations_];
NSDebugMLLog(@"gswdync",@"GSWSwitchComponent: _associations=%@",_associations);
NSDebugMLLog(@"gswdync",@"GSWSwitchComponent: GSWComponentName__Key=%@",GSWComponentName__Key[GSWebNamingConv]);
[_associations removeObjectForKey:GSWComponentName__Key[GSWebNamingConv]];
componentName = [[associations_ objectForKey:GSWComponentName__Key[GSWebNamingConv]
withDefaultObject:[componentName autorelease]] retain];
NSDebugMLLog(@"gswdync",@"GSWSwitchComponent: componentName=%@",componentName);
2002-01-26 Manuel Guesdon <mguesdon@orange-concept.com> * GSWeb.framework/GSWSwitchComponent.m: o logs o corected bug: use GSWComponentName__Key[] * GSWeb.framework/GSWSession.m: o logs * GSWExtensions.framework/GSWExtensions.m: o added better formatting * GSWExtensions.framework/GSWExtensions.gswc/GSWExtensions.HTML: o added better formatting * GSWExtensions.framework/French.lproj/GSWExtensions.gswc/GSWExtensions.HTML: o added better formatting * GSWExtensionsGSW.framework/GSWLogin.m: o added -login exception cataching to add exception verbosity. * GSWeb.framework/GSWDynamicElement.m/.h: o logs o added ivar _definitionName and associated methods * GSWeb.framework/GSWElement.m/.h: o added ivar -definitionName * GSWeb.framework/GSWTemplateParserANTLR.m: o set dynamic element definition name * GSWeb.framework/GSWTemplateParserXML.m: o set dynamic element definition name * GSWeb.framework/GSWConditional.m: o logs * GSWeb.framework/GSWComponent.m: o logs o remove GDL2 code in -valueForBinding: and setValue:forBinding: I don't see a reason for this code and it may make a loop * GSWeb.framework/GSWAssociation.m: o logs o Fix in validateValue:forKeyPath: test & call * GSWeb.framework/GSWDisplayGroup.m: o logs * GSWeb.framework/GSWBundle.m: o logs * GSWeb.framework/GSWImageButton.m: o logs (element definition name) * GSWeb.framework/GSWForm.m: o logs (element definition name) o stop invokeActionForRequest:inContext: when the current Id is after senderID * GSWeb.framework: GSWElementIDString.m o added -compare:options:range: * GSWeb.framework: GSWHTMLDynamicElement.m o stop invokeActionForRequest:inContext: when the current Id is after senderID * GSWeb.framework: GSWHTMLStaticElement.m o stop invokeActionForRequest:inContext: when the current Id is after senderID * GSWExtensions.framework/WebServerResources: o converted .gif to .png * GSWeb.framework/GSWUtils.m: o removed members in NSUserDefaults description git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@12219 72102866-910b-0410-8b05-ffd578937521
2002-01-26 10:43:23 +00:00
ASSIGN(componentAttributes,[NSDictionary dictionaryWithDictionary:_associations]);
NSDebugMLLog(@"gswdync",@"GSWSwitchComponent: componentAttributes=%@",componentAttributes);
ASSIGN(template,templateElement_);
NSDebugMLLog(@"gswdync",@"GSWSwitchComponent: template=%@",template);
componentCache=[NSMutableDictionary new];
};
LOGObjectFnStopC("GSWSwitchComponent");
return self;
};
//--------------------------------------------------------------------
-(void)dealloc
{
DESTROY(componentName);
DESTROY(componentAttributes);
DESTROY(template);
DESTROY(componentCache);
[super dealloc];
};
//--------------------------------------------------------------------
-(NSString*)description
{
return [NSString stringWithFormat:@"<%s %p>",
object_get_class_name(self),
(void*)self];
};
@end
//====================================================================
@implementation GSWSwitchComponent (GSWSwitchComponentA)
//--------------------------------------------------------------------
-(void)appendToResponse:(GSWResponse*)response_
inContext:(GSWContext*)context_
{
GSWElement* _element=nil;
NSString* _elementNameInContext=nil;
LOGObjectFnStartC("GSWSwitchComponent");
_elementNameInContext=[self _elementNameInContext:context_];
[context_ appendElementIDComponent:_elementNameInContext];
_element=[self _realComponentWithName:_elementNameInContext
inContext:context_];
[_element appendToResponse:response_
inContext:context_];
[context_ deleteLastElementIDComponent];
LOGObjectFnStopC("GSWSwitchComponent");
};
//--------------------------------------------------------------------
-(GSWElement*)invokeActionForRequest:(GSWRequest*)request_
inContext:(GSWContext*)context_
{
GSWElement* _resultElement=nil;
GSWElement* _element=nil;
NSString* _elementNameInContext=nil;
LOGObjectFnStartC("GSWSwitchComponent");
_elementNameInContext=[self _elementNameInContext:context_];
[context_ appendElementIDComponent:_elementNameInContext];
_element=[self _realComponentWithName:_elementNameInContext
inContext:context_];
_resultElement=[_element invokeActionForRequest:request_
inContext:context_];
[context_ deleteLastElementIDComponent];
LOGObjectFnStopC("GSWSwitchComponent");
return _resultElement;
};
//--------------------------------------------------------------------
-(void)takeValuesFromRequest:(GSWRequest*)request_
inContext:(GSWContext*)context_
{
GSWElement* _element=nil;
NSString* _elementNameInContext=nil;
LOGObjectFnStartC("GSWSwitchComponent");
_elementNameInContext=[self _elementNameInContext:context_];
[context_ appendElementIDComponent:_elementNameInContext];
_element=[self _realComponentWithName:_elementNameInContext
inContext:context_];
[_element takeValuesFromRequest:request_
inContext:context_];
[context_ deleteLastElementIDComponent];
LOGObjectFnStopC("GSWSwitchComponent");
};
//--------------------------------------------------------------------
-(GSWElement*)_realComponentWithName:(NSString*)name_
inContext:(GSWContext*)context_
{
GSWElement* _element=nil;
NSArray* _languages=nil;
LOGObjectFnStartC("GSWSwitchComponent");
if (!name_)
{
ExceptionRaise0(@"GSWSwitchComponent",@"ComponentName is null !");
}
else
{
_element=[componentCache objectForKey:name_];
if (!_element)
{
_languages=[context_ languages];
_element=[GSWApp dynamicElementWithName:name_
associations:componentAttributes
template:template
languages:_languages];
if (_element)
[componentCache setObject:_element
forKey:name_];
else
{
ExceptionRaise(@"GSWSwitchComponent: Creation failed for element named:%@",
name_);
};
};
};
LOGObjectFnStopC("GSWSwitchComponent");
return _element;
};
//--------------------------------------------------------------------
-(NSString*)_elementNameInContext:(GSWContext*)context_
{
GSWComponent* _component=nil;
NSString* _componentNameValue=nil;
LOGObjectFnStartC("GSWSwitchComponent");
_component=[context_ component];
_componentNameValue=[componentName valueInComponent:_component];
LOGObjectFnStopC("GSWSwitchComponent");
return _componentNameValue;
};
@end