]> err.no Git - sope/blob - sope-appserver/NGObjDOM/XHTML.subproj/ODR_XHTML_form.m
d25e41706f7fee52187603b1afb921e6df24cca8
[sope] / sope-appserver / NGObjDOM / XHTML.subproj / ODR_XHTML_form.m
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
6   OGo 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
9   later version.
10
11   OGo 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.
15
16   You should have received a copy of the GNU Lesser General Public
17   License along with OGo; see the file COPYING.  If not, write to the
18   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #include "ODRDynamicXHTMLTag.h"
24
25 /*
26   Usage:
27
28     <form [enctype="multipart/form-data"]>
29       ...
30     </form>
31
32   HTML 4:
33 */
34
35 @interface ODR_XHTML_form : ODRDynamicXHTMLTag
36 @end
37
38 #include "common.h"
39
40 @implementation ODR_XHTML_form
41
42 - (BOOL)requiresFormForNode:(id)_domNode inContext:(WOContext *)_ctx {
43   return NO;
44 }
45
46 - (void)takeValuesForNode:(id)_node
47   fromRequest:(WORequest *)_request
48                 inContext:(WOContext *)_ctx {
49   if ([_node hasChildNodes]) {
50     [_ctx setInForm:YES];
51     
52     [self takeValuesForChildNodes:[_node childNodes]
53           fromRequest:_request
54           inContext:_ctx];
55     
56     [_ctx setInForm:NO];
57   }
58
59 }
60
61 - (id)invokeActionForNode:(id)_node
62   fromRequest:(WORequest *)_request
63   inContext:(WOContext *)_ctx
64 {
65   id result = nil;
66   
67   if ([_node hasChildNodes]) {
68     [_ctx setInForm:YES];
69     
70     result = [self invokeActionForChildNodes:[_node childNodes]
71                    fromRequest:_request
72                    inContext:_ctx];
73     
74     [_ctx setInForm:NO];
75   }
76   
77   return result;
78 }
79
80
81 - (void)appendNode:(id)_node
82   toResponse:(WOResponse *)_response
83   inContext:(WOContext *)_ctx
84 {
85   NSString *enctype = nil;
86
87   enctype = [self stringFor:@"enctype" node:_node ctx:_ctx];
88   
89   if ([_node hasChildNodes]) {
90     [_ctx setInForm:YES];
91     [_response appendContentString:@"<form method=\"post\" action=\""];
92     [_response appendContentString:[_ctx componentActionURL]];
93     [_response appendContentCharacter:'"'];
94     if (enctype != nil) {
95       [_response appendContentString:@" enctype=\""];
96       [_response appendContentString:enctype];
97       [_response appendContentCharacter:'"'];
98     }
99     [_response appendContentCharacter:'>'];
100     [super appendChildNodes:[_node childNodes]
101            toResponse:_response
102            inContext:_ctx];
103     [_ctx setInForm:NO];
104     [_response appendContentString:@"</form>"];
105   }
106 }
107
108 @end /* ODR_XHTML_form */