diff --git a/examples/widgetapp/widget.coffee b/examples/widgetapp/widget.coffee
index 58e81af6..2dd69883 100644
--- a/examples/widgetapp/widget.coffee
+++ b/examples/widgetapp/widget.coffee
@@ -113,45 +113,17 @@ class WSF_INPUT_CONTROL extends WSF_CONTROL
window.states[@control_name]['text'] = state.text
@$el.val(state.text)
-class WSF_TEXTAREA_CONTROL extends WSF_CONTROL
+class WSF_TEXTAREA_CONTROL extends WSF_INPUT_CONTROL
+
+class WSF_AUTOCOMPLETE_CONTROL extends WSF_INPUT_CONTROL
attach_events: () ->
- self = @
- @$el.change () ->
- self.change()
-
- change: () ->
- window.states[@control_name]['text'] = @$el.val()
- if window.states[@control_name]['callback_change']
- trigger_callback(@control_name, 'change')
- @trigger('change')
-
- value:()->
- return @$el.val()
-
- update: (state) ->
- if state.text?
- window.states[@control_name]['text'] = state.text
- @$el.val(state.text)
-
-class WSF_TEXTAREA_CONTROL extends WSF_CONTROL
- attach_events: () ->
- self = @
- @$el.change () ->
- self.change()
-
- change: () ->
- window.states[@control_name]['text'] = @$el.val()
- if window.states[@control_name]['callback_change']
- trigger_callback(@control_name, 'change')
- @trigger('change')
-
- value:()->
- return @$el.val()
-
- update: (state) ->
- if state.text?
- window.states[@control_name]['text'] = state.text
- @$el.val(state.text)
+ super
+ @$el.typeahead({
+ name: @control_name
+ local: ["one",
+ "two",
+ "three"]
+ })
class WSF_CHECKBOX_CONTROL extends WSF_CONTROL
attach_events: ()->
@@ -257,6 +229,7 @@ typemap =
"WSF_BUTTON_CONTROL":WSF_BUTTON_CONTROL
"WSF_INPUT_CONTROL":WSF_INPUT_CONTROL
"WSF_TEXTAREA_CONTROL":WSF_TEXTAREA_CONTROL
+ "WSF_AUTOCOMPLETE_CONTROL":WSF_AUTOCOMPLETE_CONTROL
"WSF_CHECKBOX_CONTROL":WSF_CHECKBOX_CONTROL
"WSF_FORM_ELEMENT_CONTROL": WSF_FORM_ELEMENT_CONTROL
"WSF_HTML_CONTROL": WSF_HTML_CONTROL
diff --git a/library/server/wsf_html/webcontrol/autocompletions/wsf_autocompletion.e b/library/server/wsf_html/webcontrol/autocompletions/wsf_autocompletion.e
new file mode 100644
index 00000000..4e89bb55
--- /dev/null
+++ b/library/server/wsf_html/webcontrol/autocompletions/wsf_autocompletion.e
@@ -0,0 +1,16 @@
+note
+ description: "Summary description for {WSF_AUTOCOMPLETION}."
+ author: ""
+ date: "$Date$"
+ revision: "$Revision$"
+
+deferred class
+ WSF_AUTOCOMPLETION
+
+feature
+
+ autocompletion (input: STRING): JSON_ARRAY
+ deferred
+ end
+
+end
diff --git a/library/server/wsf_html/webcontrol/autocompletions/wsf_simple_autocompletion.e b/library/server/wsf_html/webcontrol/autocompletions/wsf_simple_autocompletion.e
new file mode 100644
index 00000000..8e67e971
--- /dev/null
+++ b/library/server/wsf_html/webcontrol/autocompletions/wsf_simple_autocompletion.e
@@ -0,0 +1,46 @@
+note
+ description: "Summary description for {WSF_SIMPLE_AUTOCOMPLETION}."
+ author: ""
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ WSF_SIMPLE_AUTOCOMPLETION
+
+inherit
+
+ WSF_AUTOCOMPLETION
+
+create
+ make
+
+feature {NONE}
+
+ make (l: LIST [STRING])
+ do
+ list := l
+ end
+
+feature -- Implementation
+
+ autocompletion (input: STRING): JSON_ARRAY
+ local
+ o: JSON_OBJECT
+ do
+ create Result.make_array
+ across
+ list as c
+ loop
+ if c.item.as_lower.has_substring (input.as_lower) then
+ create o.make
+ o.put (create {JSON_STRING}.make_json (c.item), "value")
+ Result.add (o)
+ end
+ end
+ end
+
+feature
+
+ list: LIST [STRING]
+
+end
diff --git a/library/server/wsf_html/webcontrol/input/wsf_autocomplete_control.e b/library/server/wsf_html/webcontrol/input/wsf_autocomplete_control.e
new file mode 100644
index 00000000..1e3e7a7d
--- /dev/null
+++ b/library/server/wsf_html/webcontrol/input/wsf_autocomplete_control.e
@@ -0,0 +1,47 @@
+note
+ description: "Summary description for {WSF_AUTOCOMPLETE_CONTROL}."
+ author: ""
+ date: "$Date$"
+ revision: "$Revision$"
+
+class
+ WSF_AUTOCOMPLETE_CONTROL
+
+inherit
+
+ WSF_INPUT_CONTROL
+ redefine
+ handle_callback
+ end
+
+create
+ make_autocomplete, make_autocomplete_with_agent
+
+feature {NONE} -- Creation
+
+ make_autocomplete (n: STRING; c: WSF_AUTOCOMPLETION)
+ do
+ make_autocomplete_with_agent (n, agent c.autocompletion)
+ end
+
+ make_autocomplete_with_agent (n: STRING; c: FUNCTION [ANY, TUPLE [STRING], JSON_ARRAY])
+ do
+ make_input (n, "")
+ create_json_list := c
+ end
+
+feature -- Callback
+
+ handle_callback (cname: STRING; event: STRING)
+ do
+ Precursor {WSF_INPUT_CONTROL} (cname, event)
+ if cname.is_equal (control_name) and event.is_equal ("autocomplete") then
+ state_changes.put (create_json_list.item ([text]), create {JSON_STRING}.make_json ("suggestions"))
+ end
+ end
+
+feature -- Autocomplete
+
+ create_json_list: FUNCTION [ANY, TUPLE [STRING], JSON_ARRAY]
+
+end
diff --git a/library/server/wsf_html/webcontrol/validators/wsf_max_validator.e b/library/server/wsf_html/webcontrol/validators/wsf_max_validator.e
index a46c2eec..f766a41d 100644
--- a/library/server/wsf_html/webcontrol/validators/wsf_max_validator.e
+++ b/library/server/wsf_html/webcontrol/validators/wsf_max_validator.e
@@ -5,10 +5,11 @@ note
revision: "$Revision$"
class
- WSF_max_VALIDATOR[G]
+ WSF_max_VALIDATOR [G]
inherit
- WSF_VALIDATOR [LIST[G]]
+
+ WSF_VALIDATOR [LIST [G]]
redefine
state
end
@@ -18,7 +19,7 @@ create
feature {NONE}
- make_max_validator (m:INTEGER; e: STRING)
+ make_max_validator (m: INTEGER; e: STRING)
do
make (e)
max := m
@@ -26,10 +27,9 @@ feature {NONE}
feature -- Implementation
- is_valid (input:LIST[G]): BOOLEAN
+ is_valid (input: LIST [G]): BOOLEAN
do
- Result:= input.count < max or input.count = max
-
+ Result := input.count < max or input.count = max
end
feature
diff --git a/library/server/wsf_html/webcontrol/wsf_control.e b/library/server/wsf_html/webcontrol/wsf_control.e
index 6f61e0b3..b4b8f454 100644
--- a/library/server/wsf_html/webcontrol/wsf_control.e
+++ b/library/server/wsf_html/webcontrol/wsf_control.e
@@ -67,7 +67,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
feature --EVENT HANDLING
handle_callback (cname: STRING; event: STRING)
- -- Method called if any callback recived. In this method you can route the callback to the event handler
+ -- Method called if any callback received. In this method you can route the callback to the event handler
deferred
end
diff --git a/library/server/wsf_html/webcontrol/wsf_page_control.e b/library/server/wsf_html/webcontrol/wsf_page_control.e
index d15e1ff7..0ce7358f 100644
--- a/library/server/wsf_html/webcontrol/wsf_page_control.e
+++ b/library/server/wsf_html/webcontrol/wsf_page_control.e
@@ -84,6 +84,7 @@ feature
data.append (states.representation)
data.append (";")
data.append ("")
+ data.append ("")
data.append ("")
data.append ("