From 0c265f4f78190498dcd3cc38459eadbef6bffc17 Mon Sep 17 00:00:00 2001 From: YNH Webdev Date: Thu, 5 Sep 2013 17:43:46 +0200 Subject: [PATCH] Fix form and textarea bug --- examples/widgetapp/widget.coffee | 2 +- examples/widgetapp/widget.js | 2 +- .../webcontrol/wsf_form_element_control.e | 50 +++++++++++++------ 3 files changed, 37 insertions(+), 17 deletions(-) diff --git a/examples/widgetapp/widget.coffee b/examples/widgetapp/widget.coffee index cfa7045a..50323004 100644 --- a/examples/widgetapp/widget.coffee +++ b/examples/widgetapp/widget.coffee @@ -69,7 +69,7 @@ class WSF_TEXTAREA_CONTROL extends WSF_CONTROL update: (state) -> if state.text? window.states[@control_name]['text'] = state.text - $el.val(state.text) + @$el.val(state.text) #map class name to effective class typemap = diff --git a/examples/widgetapp/widget.js b/examples/widgetapp/widget.js index ffea70e7..45a9abca 100644 --- a/examples/widgetapp/widget.js +++ b/examples/widgetapp/widget.js @@ -136,7 +136,7 @@ WSF_TEXTAREA_CONTROL.prototype.update = function(state) { if (state.text != null) { window.states[this.control_name]['text'] = state.text; - return $el.val(state.text); + return this.$el.val(state.text); } }; diff --git a/library/server/wsf_html/webcontrol/wsf_form_element_control.e b/library/server/wsf_html/webcontrol/wsf_form_element_control.e index d350aaa0..d057cc56 100644 --- a/library/server/wsf_html/webcontrol/wsf_form_element_control.e +++ b/library/server/wsf_html/webcontrol/wsf_form_element_control.e @@ -11,7 +11,7 @@ inherit WSF_CONTROL redefine - read_state_changes + read_state_changes,load_state,read_state end create @@ -48,33 +48,53 @@ feature loop end end +feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT -feature --Implementation + load_state (new_states: JSON_OBJECT) + -- Pass new_states to subcontrols + do + Precursor (new_states) + value_control.load_state (new_states) + end set_state (new_state: JSON_OBJECT) do - value_control.set_state (new_state) + value_control.set_state(new_state) end - state: JSON_OBJECT + read_state (states: JSON_OBJECT) + -- Read states in subcontrols do - Result := value_control.state - end - - handle_callback (cname, event: STRING_8) - do - value_control.handle_callback (cname, event) + Precursor (states) + value_control.read_state(states) end read_state_changes (states: JSON_OBJECT) - -- Add a new entry in the `states_changes` JSON object with the `control_name` as key and the `state` as value + -- Read states_changes in subcontrols do - if state_changes.count > 0 then - states.put (state_changes, create {JSON_STRING}.make_json (control_name)) - end - value_control.read_state_changes (states) + Precursor (states) + value_control.read_state_changes(states) end + state: JSON_OBJECT + --Read state + do + create Result.make + end + +feature --EVENT HANDLING + + handle_callback (cname: STRING; event: STRING) + -- Pass callback to subcontrols + do + if equal (cname, control_name) then + else + value_control.handle_callback (cname, event) + end + end +feature --Implementation + + render: STRING local body: STRING