added fragment handling

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gsweb/trunk@18738 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Manuel Guesdon 2004-03-01 16:47:04 +00:00
parent 625e698695
commit 8e82a98b17
2 changed files with 45 additions and 21 deletions

View file

@ -1,6 +1,6 @@
/** GSWForm.h - <title>GSWeb: Class GSWForm</title> /** GSWForm.h - <title>GSWeb: Class GSWForm</title>
Copyright (C) 1999-2003 Free Software Foundation, Inc. Copyright (C) 1999-2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com> Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999 Date: Jan 1999
@ -44,6 +44,7 @@
//GSWeb Additions { //GSWeb Additions {
GSWAssociation* _disabled; GSWAssociation* _disabled;
GSWAssociation* _enabled; GSWAssociation* _enabled;
GSWAssociation* _fragmentIdentifier;
NSDictionary* _otherPathQueryAssociations; NSDictionary* _otherPathQueryAssociations;
// } // }
NSDictionary* _otherQueryAssociations; NSDictionary* _otherQueryAssociations;

View file

@ -1,6 +1,6 @@
/** GSWForm.m - <title>GSWeb: Class GSWForm</title> /** GSWForm.m - <title>GSWeb: Class GSWForm</title>
Copyright (C) 1999-2003 Free Software Foundation, Inc. Copyright (C) 1999-2004 Free Software Foundation, Inc.
Written by: Manuel Guesdon <mguesdon@orange-concept.com> Written by: Manuel Guesdon <mguesdon@orange-concept.com>
Date: Jan 1999 Date: Jan 1999
@ -101,6 +101,12 @@ RCS_ID("$Id$")
ExceptionRaise(@"GSWForm",@"You can't specify 'disabled' and 'enabled' together. componentAssociations:%@", ExceptionRaise(@"GSWForm",@"You can't specify 'disabled' and 'enabled' together. componentAssociations:%@",
associations); associations);
}; };
_fragmentIdentifier = [[associations objectForKey:fragmentIdentifier__Key
withDefaultObject:[_fragmentIdentifier autorelease]] retain];
NSDebugMLLog(@"gswdync",@"fragmentIdentifier=%@",_fragmentIdentifier);
[tmpAssociations removeObjectForKey:fragmentIdentifier__Key];
}; };
_queryDictionary = [[associations objectForKey:queryDictionary__Key _queryDictionary = [[associations objectForKey:queryDictionary__Key
@ -145,6 +151,7 @@ RCS_ID("$Id$")
DESTROY(_queryDictionary); DESTROY(_queryDictionary);
DESTROY(_disabled); DESTROY(_disabled);
DESTROY(_enabled); DESTROY(_enabled);
DESTROY(_fragmentIdentifier);
DESTROY(_otherQueryAssociations); DESTROY(_otherQueryAssociations);
DESTROY(_otherPathQueryAssociations); DESTROY(_otherPathQueryAssociations);
[super dealloc]; [super dealloc];
@ -301,11 +308,14 @@ RCS_ID("$Id$")
int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb]; int elementsNb=[(GSWElementIDString*)[context elementID]elementsNb];
#endif #endif
BOOL multipleSubmitValue=NO; BOOL multipleSubmitValue=NO;
LOGObjectFnStartC("GSWForm"); LOGObjectFnStartC("GSWForm");
GSWStartElement(context); GSWStartElement(context);
senderID=[context senderID]; senderID=[context senderID];
elementID=[context elementID]; elementID=[context elementID];
NSDebugMLLog(@"gswdync",@"senderId=%@",senderID); NSDebugMLLog(@"gswdync",@"senderId=%@",senderID);
NS_DURING NS_DURING
{ {
GSWAssertCorrectElementID(context);// Debug Only GSWAssertCorrectElementID(context);// Debug Only
@ -335,24 +345,6 @@ RCS_ID("$Id$")
(multipleSubmitValue ? "YES" : "NO")); (multipleSubmitValue ? "YES" : "NO"));
[context _setIsMultipleSubmitForm:multipleSubmitValue]; [context _setIsMultipleSubmitForm:multipleSubmitValue];
}; };
/*
for(i=0;!element && !searchIsOver && i<[_dynamicChildren count];i++)
{
NSDebugMLLog(@"gswdync",@"i=%d",i);
element=[[_dynamicChildren objectAtIndex:i] invokeActionForRequest:request
inContext:context];
// if (![context _wasFormSubmitted] && [[context elementID] compare:senderID]==NSOrderedDescending)
if (![context _wasFormSubmitted] && [[context elementID] isSearchOverForSenderID:senderID])
{
NSDebugMLLog(@"gswdync",@"id=%@ senderid=%@ => search is over",
[context elementID],
senderID);
searchIsOver=YES;
};
[context incrementLastElementIDComponent];
};
*/
NSDebugMLLog(@"gswdync",@"isFormSubmited=%d",isFormSubmited); NSDebugMLLog(@"gswdync",@"isFormSubmited=%d",isFormSubmited);
@ -404,9 +396,10 @@ RCS_ID("$Id$")
[localException raise]; [localException raise];
} }
NS_ENDHANDLER; NS_ENDHANDLER;
senderID=[context senderID]; senderID=[context senderID];
elementID=[context elementID]; elementID=[context elementID];
//if (![context _wasActionInvoked] && [_elementID compare:senderID]!=NSOrderedAscending)
if (![context _wasActionInvoked] && [elementID isSearchOverForSenderID:senderID]) if (![context _wasActionInvoked] && [elementID isSearchOverForSenderID:senderID])
{ {
LOGError(@"Action not invoked at the end of %@ (def name=%@) (id=%@) senderId=%@", LOGError(@"Action not invoked at the end of %@ (def name=%@) (id=%@) senderId=%@",
@ -415,7 +408,9 @@ RCS_ID("$Id$")
elementID, elementID,
senderID); senderID);
}; };
LOGObjectFnStopC("GSWForm"); LOGObjectFnStopC("GSWForm");
return element; return element;
}; };
@ -492,6 +487,15 @@ RCS_ID("$Id$")
if (_href) if (_href)
{ {
id actionValue=[_href valueInComponent:component]; id actionValue=[_href valueInComponent:component];
if (_fragmentIdentifier)
{
id fragment=[_fragmentIdentifier valueInComponent:component];
NSDebugMLLog(@"gswdync",@"fragment=%@",fragment);
if (fragment)
actionValue=[NSString stringWithFormat:@"%@#%@",
actionValue,fragment];
};
NSDebugMLLog(@"gswdync",@"actionValue=%@",actionValue);
//TODO emit a warning ! //TODO emit a warning !
[response _appendTagAttribute:@"action" [response _appendTagAttribute:@"action"
value:actionValue value:actionValue
@ -505,6 +509,15 @@ RCS_ID("$Id$")
else else
{ {
id actionValue=[context componentActionURL]; id actionValue=[context componentActionURL];
if (_fragmentIdentifier)
{
id fragment=[_fragmentIdentifier valueInComponent:component];
NSDebugMLLog(@"gswdync",@"fragment=%@",fragment);
if (fragment)
actionValue=[NSString stringWithFormat:@"%@#%@",
actionValue,fragment];
};
NSDebugMLLog(@"gswdync",@"actionValue=%@",actionValue);
[response _appendTagAttribute:@"action" [response _appendTagAttribute:@"action"
value:actionValue value:actionValue
escapingHTMLAttributeValue:NO]; escapingHTMLAttributeValue:NO];
@ -529,6 +542,16 @@ RCS_ID("$Id$")
isSecure:NO]; isSecure:NO];
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl); NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
if (_fragmentIdentifier)
{
id fragment=[_fragmentIdentifier valueInComponent:[context component]];
NSDebugMLLog(@"gswdync",@"fragment=%@",fragment);
if (fragment)
anUrl=[NSString stringWithFormat:@"%@#%@",
anUrl,fragment];
};
NSDebugMLLog(@"gswdync",@"anUrl=%@",anUrl);
[response _appendTagAttribute:@"action" [response _appendTagAttribute:@"action"
value:anUrl value:anUrl
escapingHTMLAttributeValue:NO]; escapingHTMLAttributeValue:NO];