mirror of
https://github.com/gnustep/libs-gsweb.git
synced 2025-02-23 03:31:16 +00:00
* GSWeb.framework/GSWTextField.m: o added warning in _isFormattedValueInComponent:equalToFormattedValue: o added warning in takeValuesFromRequest:inContext: * GSWeb.framework/GSWPopUpButton.m o added ElementID debugging methods o added DocStructure debugging features * GSWeb.framework/GSWSwitchComponent.m o added ElementID debugging methods o added DocStructure debugging features * GSWeb.framework/GSWRepetition.m o added ElementID debugging methods o added DocStructure debugging features o param names changes to conform to coding standards * GSWeb.framework/GSWComponentContent.m o added ElementID debugging methods o added DocStructure debugging features * GSWeb.framework/GSWComponentReference.m: o added ElementID debugging methods o added DocStructure debugging features o ivar names changes to conform to coding standards o logs * GSWeb.framework/GSWElement.m: o added ElementID debugging methods o added DocStructure debugging features o logs * GSWeb.framework/GSWElement.h o added ElementID debugging * GSWeb.framework/GSWForm.m: o added ElementID debugging o added DocStructure debugging features o logs * GSWeb.framework/GSWHTMLDynamicElement.m: o ivar names changes to conform to coding standards o added ElementID debugging o added DocStructure debugging features * GSWeb.framework/GSWConditional.m: o added ElementID debugging o added DocStructure debugging features o ivar names changes to conform to coding standards * GSWeb.framework/GSWConditional.h. o ivar names changes to conform to coding standards * GSWeb.framework/GSWRepetition.h. o param names changes to conform to coding standards * GSWeb.framework/GSWReset.m: o ivar names changes to conform to coding standards o added ElementID debugging o added DocStructure debugging features * GSWeb.framework/GSWReset.h. o ivar names changes to conform to coding standards * GSWeb.framework/GSWResponse.h/.m: o added DocStructure debugging features * GSWeb.framework/GSWContext.h/.m: o added DocStructure debugging features * GSWeb.framework/GSWSession.m: o added DocStructure debugging features * GSWeb.framework/GSWTemplateParserXML.m o logs * GSWeb.framework/GSWTemplateParser.m o logs * GSWeb.framework/GSWDisplayGroup.m: o corrected insertion bugs o added -insertAfterLastObject o added -selectFirst * GSWeb.framework/GSWDisplayGroup.h: o added -insertAfterLastObject o added -selectFirst * GSWeb.framework/GSWHTMLStaticElement.m o added ElementID debugging o added DocStructure debugging features * GSWeb.framework/GSWCheckBox.m o added ElementID debugging o added DocStructure debugging features * GSWeb.framework/GSWComponent.m o added ElementID debugging o added DocStructure debugging features * GSWeb.framework/GSWHTMLStaticGroup.m o added ElementID debugging o added DocStructure debugging features * GSWeb.framework/GSWTextField.m o added ElementID debugging o added DocStructure debugging features * GSWeb.framework/GSWString.m o added ElementID debugging o added DocStructure debugging features * GSWeb.framework/GSWSubmitButton.m o added ElementID debugging o added DocStructure debugging features * GSWeb.framework/GSWURLValuedElementData.m/.h: o added ElementID debugging o added DocStructure debugging features o ivar names changes to conform to coding standards * GSWeb.framework/GSWRadioButton.m o added ElementID debugging o added DocStructure debugging features * GSWeb.framework/GSWInput.m o added ElementID debugging o added DocStructure debugging features o logs * GSWeb.framework/GSWHyperlink.m o added ElementID debugging o added DocStructure debugging features * GSWeb.framework/GSWFileUpload.m o added ElementID debugging o added DocStructure debugging features git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@13661 72102866-910b-0410-8b05-ffd578937521
387 lines
12 KiB
Objective-C
387 lines
12 KiB
Objective-C
/** GSWInput.m - <title>GSWeb: Class GSWInput</title>
|
|
|
|
Copyright (C) 1999-2002 Free Software Foundation, Inc.
|
|
|
|
Written by: Manuel Guesdon <mguesdon@orange-concept.com>
|
|
Date: Feb 1999
|
|
|
|
$Revision$
|
|
$Date$
|
|
|
|
This file is part of the GNUstep Web Library.
|
|
|
|
<license>
|
|
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.
|
|
</license>
|
|
**/
|
|
|
|
static char rcsId[] = "$Id$";
|
|
|
|
#include <GSWeb/GSWeb.h>
|
|
|
|
//====================================================================
|
|
@implementation GSWInput
|
|
|
|
//--------------------------------------------------------------------
|
|
-(id)initWithName:(NSString*)aName
|
|
associations:(NSDictionary*)associations
|
|
contentElements:(NSArray*)elements
|
|
{
|
|
NSMutableDictionary* attributedAssociations=[[associations mutableCopy] autorelease];
|
|
LOGObjectFnStartC("GSWInput");
|
|
NSDebugMLLog(@"gswdync",@"aName=%@ associations:%@ elements=%@",aName,associations,elements);
|
|
[attributedAssociations removeObjectForKey:disabled__Key];
|
|
[attributedAssociations removeObjectForKey:enabled__Key];//??
|
|
[attributedAssociations removeObjectForKey:value__Key];//??
|
|
if (!WOStrictFlag)
|
|
[attributedAssociations removeObjectForKey:handleValidationException__Key];
|
|
_value = [[associations objectForKey:value__Key
|
|
withDefaultObject:[_value autorelease]] retain];
|
|
NSDebugMLLog(@"gswdync",@"GSWInput: value=%@",_value);
|
|
if ((self=[super initWithName:aName
|
|
attributeAssociations:attributedAssociations
|
|
contentElements:elements]))
|
|
{
|
|
_disabled = [[associations objectForKey:disabled__Key
|
|
withDefaultObject:[_disabled autorelease]] retain];
|
|
NSDebugMLLog(@"gswdync",@"GSWInput: disabled=%@",_disabled);
|
|
if (!WOStrictFlag)
|
|
{
|
|
_enabled = [[associations objectForKey:enabled__Key
|
|
withDefaultObject:[_enabled autorelease]] retain];
|
|
NSDebugMLLog(@"gswdync",@"GSWInput: enabled=%@",_enabled);
|
|
if (_disabled && _enabled)
|
|
{
|
|
ExceptionRaise0(@"GSWInput",@"You can't use 'diabled' and 'enabled' parameters at the same time.");
|
|
};
|
|
};
|
|
_name = [[associations objectForKey:name__Key
|
|
withDefaultObject:[_name autorelease]] retain];
|
|
NSDebugMLLog(@"gswdync",@"GSWInput: name=%@",_name);
|
|
|
|
if (!WOStrictFlag)
|
|
{
|
|
_handleValidationException = [[associations objectForKey:handleValidationException__Key
|
|
withDefaultObject:[_handleValidationException autorelease]] retain];
|
|
NSDebugMLLog(@"gswdync",@"GSWInput: handleValidationException=%@",_handleValidationException);
|
|
|
|
// Turbocat Additions
|
|
// [attributedAssociations removeObjectForKey: escapeHTML__Key];
|
|
if ([associations objectForKey: escapeHTML__Key])
|
|
{
|
|
_tcEscapeHTML = [[associations objectForKey:escapeHTML__Key
|
|
withDefaultObject:nil] retain];
|
|
};
|
|
};
|
|
};
|
|
LOGObjectFnStopC("GSWInput");
|
|
return self;
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)dealloc
|
|
{
|
|
DESTROY(_disabled);
|
|
DESTROY(_enabled);//GSWeb Only
|
|
DESTROY(_name);
|
|
DESTROY(_value);
|
|
DESTROY(_handleValidationException);//GSWeb Only
|
|
DESTROY(_tcEscapeHTML);//GSWeb Only
|
|
[super dealloc];
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSString*)elementName
|
|
{
|
|
return @"INPUT";
|
|
};
|
|
|
|
@end
|
|
|
|
//==============================================================================
|
|
@implementation GSWInput (GSWInputA)
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSString*)nameInContext:(GSWContext*)context
|
|
{
|
|
//OK
|
|
GSWComponent* component=nil;
|
|
NSString* nameValue=nil;
|
|
LOGObjectFnStartC("GSWInput");
|
|
GSWAssertIsElementID(context);
|
|
if (_name)
|
|
{
|
|
component=[context component];
|
|
nameValue=[_name valueInComponent:component];
|
|
}
|
|
else
|
|
{
|
|
nameValue=[context elementID];
|
|
NSDebugMLLog(@"gswdync",@"elementID=%@",[context elementID]);
|
|
};
|
|
GSWAssertIsElementID(context);
|
|
LOGObjectFnStopC("GSWInput");
|
|
return nameValue;
|
|
};
|
|
|
|
static int countAutoValue = 0;
|
|
|
|
//--------------------------------------------------------------------
|
|
-(NSString*)valueInContext:(GSWContext*)context
|
|
{
|
|
//OK
|
|
GSWComponent *component=nil;
|
|
NSString *valueValue=nil;
|
|
|
|
LOGObjectFnStartC("GSWInput");
|
|
countAutoValue++;
|
|
if(_value)
|
|
{
|
|
component=[context component];
|
|
valueValue=[_value valueInComponent:component];
|
|
}
|
|
else
|
|
{
|
|
valueValue=[NSString stringWithFormat:@"%@.%d", [context elementID], countAutoValue];
|
|
NSDebugMLLog(@"gswdync",@"elementID=%@ _countAutoValue",[context elementID], countAutoValue);
|
|
}
|
|
LOGObjectFnStopC("GSWInput");
|
|
return valueValue;
|
|
}
|
|
|
|
//--------------------------------------------------------------------
|
|
- (void)resetAutoValue
|
|
{
|
|
LOGObjectFnStartC("GSWInput");
|
|
|
|
countAutoValue = 0;
|
|
|
|
LOGObjectFnStopC("GSWInput");
|
|
}
|
|
|
|
//--------------------------------------------------------------------
|
|
-(BOOL)disabledInContext:(GSWContext*)context
|
|
{
|
|
//OK
|
|
if (!WOStrictFlag && _enabled)
|
|
return ![self evaluateCondition:_enabled
|
|
inContext:context];
|
|
else
|
|
return [self evaluateCondition:_disabled
|
|
inContext:context];
|
|
};
|
|
|
|
@end
|
|
|
|
//==============================================================================
|
|
@implementation GSWInput (GSWInputB)
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)takeValuesFromRequest:(GSWRequest*)request
|
|
inContext:(GSWContext*)context
|
|
{
|
|
//OK
|
|
BOOL disabledInContext=NO;
|
|
LOGObjectFnStartC("GSWInput");
|
|
GSWStartElement(context);
|
|
GSWAssertCorrectElementID(context);
|
|
disabledInContext=[self disabledInContext:context]; //return 0
|
|
if (!disabledInContext)
|
|
{
|
|
BOOL wasFormSubmitted=[context _wasFormSubmitted];
|
|
if (wasFormSubmitted)
|
|
{
|
|
GSWComponent* component=[context component];
|
|
NSString* nameInContext=[self nameInContext:context];
|
|
NSString* valueValue=[request formValueForKey:nameInContext];
|
|
NSDebugMLLog(@"gswdync",@"nameInContext=%@",nameInContext);
|
|
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
|
|
NS_DURING
|
|
{
|
|
[_value setValue:valueValue
|
|
inComponent:component];
|
|
};
|
|
NS_HANDLER
|
|
{
|
|
LOGException(@"GSWInput _value=%@ valueValue=%@ exception=%@",
|
|
_value,valueValue,localException);
|
|
if (!WOStrictFlag)
|
|
{
|
|
[self handleValidationException:localException
|
|
inContext:context];
|
|
}
|
|
else
|
|
{
|
|
[localException raise];
|
|
};
|
|
}
|
|
NS_ENDHANDLER;
|
|
};
|
|
};
|
|
GSWAssertIsElementID(context);
|
|
LOGObjectFnStopC("GSWInput");
|
|
};
|
|
|
|
@end
|
|
|
|
//====================================================================
|
|
@implementation GSWInput (GSWInputC)
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)appendGSWebObjectsAssociationsToResponse:(GSWResponse*)response
|
|
inContext:(GSWContext*)context
|
|
{
|
|
//OK
|
|
BOOL disabledInContext=NO;
|
|
LOGObjectFnStartC("GSWInput");
|
|
disabledInContext=[self disabledInContext:context]; //return 0
|
|
if (disabledInContext)
|
|
[response _appendContentAsciiString:@" disabled"];
|
|
[self appendValueToResponse:response
|
|
inContext:context];
|
|
[self appendNameToResponse:response
|
|
inContext:context];
|
|
LOGObjectFnStopC("GSWInput");
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)appendValueToResponse:(GSWResponse*)response
|
|
inContext:(GSWContext*)context
|
|
{
|
|
//OK
|
|
GSWComponent* component=nil;
|
|
LOGObjectFnStartC("GSWInput");
|
|
component=[context component];
|
|
if (_value)
|
|
{
|
|
id valueValue=[_value valueInComponent:component];
|
|
NSDebugMLLog(@"gswdync",@"valueValue=%@",valueValue);
|
|
if (valueValue)
|
|
{
|
|
[response appendContentCharacter:' '];
|
|
[response _appendContentAsciiString:@"value"];
|
|
[response appendContentCharacter:'='];
|
|
[response appendContentCharacter:'"'];
|
|
if (_tcEscapeHTML && [self evaluateCondition:_tcEscapeHTML
|
|
inContext:context] == NO)
|
|
{
|
|
[response appendContentString:valueValue];
|
|
}
|
|
else
|
|
{
|
|
[response appendContentHTMLAttributeValue:valueValue];
|
|
};
|
|
[response appendContentCharacter:'"'];
|
|
};
|
|
};
|
|
LOGObjectFnStopC("GSWInput");
|
|
};
|
|
|
|
//--------------------------------------------------------------------
|
|
-(void)appendNameToResponse:(GSWResponse*)response
|
|
inContext:(GSWContext*)context
|
|
{
|
|
//OK
|
|
NSString* name=nil;
|
|
LOGObjectFnStartC("GSWInput");
|
|
name=[self nameInContext:context];
|
|
NSDebugMLLog(@"gswdync",@"name=%@",name);
|
|
if (name)
|
|
{
|
|
[response appendContentCharacter:' '];
|
|
[response _appendContentAsciiString:@"name"];
|
|
[response appendContentCharacter:'='];
|
|
[response appendContentCharacter:'"'];
|
|
[response appendContentHTMLAttributeValue:name];
|
|
[response appendContentCharacter:'"'];
|
|
};
|
|
LOGObjectFnStopC("GSWInput");
|
|
};
|
|
|
|
@end
|
|
|
|
//====================================================================
|
|
@implementation GSWInput (GSWInputD)
|
|
|
|
//--------------------------------------------------------------------
|
|
+(BOOL)hasGSWebObjectsAssociations
|
|
{
|
|
return YES;
|
|
};
|
|
|
|
@end
|
|
|
|
//====================================================================
|
|
@implementation GSWInput (GSWInputE)
|
|
|
|
//GSWeb additions {
|
|
-(void)handleValidationException:(NSException*)exception
|
|
inContext:(GSWContext*)context
|
|
{
|
|
BOOL isValidationException=[exception isValidationException];
|
|
BOOL raise=YES;
|
|
LOGObjectFnStartC("GSWInput");
|
|
if (isValidationException)
|
|
{
|
|
GSWComponent* component=[context component];
|
|
id handleValidationException=[handleValidationException valueInComponent:component];
|
|
BOOL handle=NO;
|
|
if (!handleValidationException)
|
|
{
|
|
handleValidationException = [component handleValidationExceptionDefault];
|
|
};
|
|
if (handleValidationException)
|
|
{
|
|
if ([handleValidationException isEqualToString:@"handleAndRaise"])
|
|
{
|
|
handle=YES;
|
|
raise=YES;
|
|
}
|
|
else if ([handleValidationException isEqualToString:@"handle"])
|
|
{
|
|
handle=YES;
|
|
raise=NO;
|
|
}
|
|
else if ([handleValidationException isEqualToString:@"raise"])
|
|
{
|
|
handle=NO;
|
|
raise=YES;
|
|
}
|
|
else
|
|
{
|
|
NSDebugMLog(@"Unknown case for handleValidationException %@",handleValidationException);
|
|
};
|
|
};
|
|
if (handle)
|
|
{
|
|
NSDebugMLog(@"Handled validation exception %@",exception);
|
|
[component setValidationFailureMessage:[[exception userInfo]objectForKey:@"message"]
|
|
forElement:self];
|
|
}
|
|
else
|
|
{
|
|
NSDebugMLog(@"Unhandled validation exception %@",exception);
|
|
};
|
|
};
|
|
if (raise)
|
|
{
|
|
NSDebugMLog(@"Raise exception %@",exception);
|
|
exception=ExceptionByAddingUserInfoObjectFrameInfo0(exception,@"handleValidationException:inContext");
|
|
[exception raise];
|
|
};
|
|
LOGObjectFnStopC("GSWInput");
|
|
};
|
|
// }
|
|
@end
|