]> err.no Git - sope/blob - sope-appserver/NGObjWeb/DynamicElements/WOPasswordField.m
improved query string handling
[sope] / sope-appserver / NGObjWeb / DynamicElements / WOPasswordField.m
1 /*
2   Copyright (C) 2000-2005 SKYRIX Software AG
3
4   This file is part of SOPE.
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21
22 #include "WOInput.h"
23 #include "decommon.h"
24
25 @interface WOPasswordField : WOInput
26 {
27   // WODynamicElement: extraAttributes
28   // WODynamicElement: otherTagString
29   // WOInput:    name
30   // WOInput:    value
31   // WOInput:    disabled
32 @protected
33   // non WO:
34   WOAssociation *size;
35 }
36
37 @end /* WOPasswordField */
38
39 @implementation WOPasswordField
40
41 - (id)initWithName:(NSString *)_name associations:(NSDictionary *)_a
42   template:(WOElement *)_root
43 {
44   if ((self = [super initWithName:_name associations:_a template:_root])) {
45     self->size = OWGetProperty(_a, @"size");
46   }
47   return self;
48 }
49
50 - (void)dealloc {
51   [self->size release];
52   [super dealloc];
53 }
54
55 /* generate response */
56
57 - (void)appendToResponse:(WOResponse *)_response inContext:(WOContext *)_ctx {
58   NSString     *v;
59   unsigned int s;
60   
61   v = [self->value stringValueInComponent:[_ctx component]];
62   s = [self->size  unsignedIntValueInComponent:[_ctx component]];
63   
64   WOResponse_AddCString(_response, "<input type=\"password\" name=\"");
65   [_response appendContentHTMLAttributeValue:OWFormElementName(self, _ctx)];
66   WOResponse_AddCString(_response, "\" value=\"");
67   [_response appendContentHTMLAttributeValue:v];
68   [_response appendContentCharacter:'"'];
69   
70   if (s > 0) {
71     WOResponse_AddCString(_response, " size=\"");
72     WOResponse_AddUInt(_response, s);
73     [_response appendContentCharacter:'"'];
74   }
75   
76   if ([self->disabled boolValueInComponent:[_ctx component]])
77     WOResponse_AddCString(_response, " disabled=\"disabled\"");
78   
79   [self appendExtraAttributesToResponse:_response inContext:_ctx];
80   
81   if (self->otherTagString != nil) {
82     v = [self->otherTagString stringValueInComponent:[_ctx component]];
83     WOResponse_AddChar(_response, ' ');
84     WOResponse_AddString(_response, v);
85   }
86   
87   WOResponse_AddEmptyCloseParens(_response, _ctx);
88 }
89
90 /* description */
91
92 - (NSString *)associationDescription {
93   NSMutableString *str = nil;
94   
95   str = [NSMutableString stringWithCapacity:128];
96   [str appendString:[super associationDescription]];
97   
98   if (self->size) [str appendFormat:@" size=%@", self->size];
99   
100   return str;
101 }
102
103 @end /* WOPasswordField */