1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 from __pyjamas__ import console
16 from pyjamas import Factory
17 from pyjamas import DOM
18
19 from pyjamas.ui.Widget import Widget
22
23 _props = [("name", "Name", "Name", None),
24 ("value", "Value", "Value", None),
25 ("defaultValue", "Default Value", "DefaultValue", None),
26 ]
27
28 - def __init__(self, name=None, value=None, **kwargs):
29
30 name = kwargs.get("Name", name)
31 if name is not None:
32 kwargs['Name'] = name
33 value = kwargs.get("Value", value)
34 if value is not None:
35 kwargs['Value'] = kwargs.get("Value", value)
36 element = kwargs.pop('Element', None) or DOM.createElement("input")
37 self.setElement(element)
38 DOM.setAttribute(element, "type", "hidden")
39
40 Widget.__init__(self, **kwargs)
41
42 @classmethod
45
48
51
54
57
59 if name is None:
60 raise ValueError("Name cannot be null")
61 console.error("Name cannot be null")
62 elif len(name) == 0:
63 raise ValueError("Name cannot be an empty string.")
64 console.error("Name cannot be an empty string.")
65 DOM.setAttribute(self.getElement(), "name", name)
66
69
70 Factory.registerClass('pyjamas.ui.Hidden', 'Hidden', Hidden)
71