2 Copyright (C) 2000-2005 SKYRIX Software AG
4 This file is part of SOPE.
6 SOPE is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with SOPE; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
22 #include "WOGenericElement.h"
24 @interface WOGenericContainer : WOGenericElement
26 // WODynamicElement: extraAttributes
27 // WODynamicElement: otherTagString
28 // WOGenericContainer: tagName
35 #include "WOElement+private.h"
38 // TODO(perf): ASCII Tags (appendContentCString)
39 // TODO(perf): constant tags
41 #define TagNameType_Assoc 0
42 #define TagNameType_String 1
43 #define TagNameType_ASCII 2
45 @implementation WOGenericContainer
47 - (id)initWithName:(NSString *)_name
48 associations:(NSDictionary *)_config
49 template:(WOElement *)_c
51 if ((self = [super initWithName:_name associations:_config template:_c])) {
52 self->template = [_c retain];
58 [self->template release];
65 return self->template;
68 /* handling requests */
70 - (void)takeValuesFromRequest:(WORequest *)_req inContext:(WOContext *)_ctx {
71 [self->template takeValuesFromRequest:_req inContext:_ctx];
73 - (id)invokeActionForRequest:(WORequest *)_req inContext:(WOContext *)_ctx {
74 return [self->template invokeActionForRequest:_req inContext:_ctx];
77 /* generate response */
79 - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
80 WOComponent *sComponent;
83 if ([[_ctx request] isFromClientComponent])
86 sComponent = [_ctx component];
87 switch (self->tagNameType) {
88 case TagNameType_Assoc:
89 if ((tag = [(id)self->tagName stringValueInComponent:sComponent]) == nil)
92 case TagNameType_String:
93 if ((tag = self->tagName) == nil) tag = @"p";
95 case TagNameType_ASCII:
101 WOResponse_AddChar(_response, '<');
103 WOResponse_AddString(_response, tag);
105 else if (self->tagNameType == TagNameType_ASCII) {
106 WOResponse_AddCString(_response, self->tagName);
109 [self _appendAttributesToResponse:_response inContext:_ctx];
111 if (self->otherTagString) {
112 WOResponse_AddChar(_response, ' ');
113 WOResponse_AddString(_response,
114 [self->otherTagString stringValueInComponent:
117 WOResponse_AddChar(_response, '>');
119 [self->template appendToResponse:_response inContext:_ctx];
121 WOResponse_AddCString(_response, "</");
123 WOResponse_AddString(_response, tag);
125 else if (self->tagNameType == TagNameType_ASCII) {
126 WOResponse_AddCString(_response, self->tagName);
128 WOResponse_AddChar(_response, '>');
131 @end /* WOGenericContainer */