Create new JSON_OBJECT

This commit is contained in:
YNH Webdev
2013-09-27 10:57:40 +02:00
parent 113df6efe1
commit b6c082e1fe
21 changed files with 224 additions and 94 deletions

View File

@@ -27,7 +27,7 @@ feature -- Implementation
autocompletion (input: STRING): JSON_ARRAY autocompletion (input: STRING): JSON_ARRAY
-- Implementation -- Implementation
local local
o: JSON_OBJECT o: WSF_JSON_OBJECT
do do
create Result.make_array create Result.make_array
across across
@@ -35,7 +35,7 @@ feature -- Implementation
loop loop
if c.item.as_lower.has_substring (input.as_lower) then if c.item.as_lower.has_substring (input.as_lower) then
create o.make create o.make
o.put (create {JSON_STRING}.make_json (c.item), "value") o.put_string (c.item, "value")
Result.add (o) Result.add (o)
end end
end end

View File

@@ -25,19 +25,19 @@ feature --Event handling
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
state: JSON_OBJECT state: WSF_JSON_OBJECT
-- Return state which contains the current sort_column and sort_direction -- Return state which contains the current sort_column and sort_direction
do do
create Result.make create Result.make
if attached sort_column as a_sort_column then if attached sort_column as a_sort_column then
Result.put (create {JSON_STRING}.make_json (a_sort_column), "sort_column") Result.put_string (a_sort_column, "sort_column")
else else
Result.put (create {JSON_NULL}, "sort_column") Result.put (create {JSON_NULL}, "sort_column")
end end
Result.put (create {JSON_BOOLEAN}.make_boolean (sort_direction), "sort_direction") Result.put_boolean (sort_direction, "sort_direction")
end end
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
-- Restore sort_column and sort_direction from json -- Restore sort_column and sort_direction from json
do do
if attached {JSON_STRING} new_state.item ("sort_column") as new_sort_column then if attached {JSON_STRING} new_state.item ("sort_column") as new_sort_column then

View File

@@ -35,16 +35,16 @@ feature --Event handling
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
state: JSON_OBJECT state: WSF_JSON_OBJECT
-- Return state which contains the current page, page_size and row_count -- Return state which contains the current page, page_size and row_count
do do
Result := Precursor Result := Precursor
Result.put (create {JSON_NUMBER}.make_integer (page), "page") Result.put_integer (page, "page")
Result.put (create {JSON_NUMBER}.make_integer (page_size), "page_size") Result.put_integer (page_size, "page_size")
Result.put (create {JSON_NUMBER}.make_integer (row_count), "row_count") Result.put_integer (row_count, "row_count")
end end
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
-- Restore page, page_size and row_count from json -- Restore page, page_size and row_count from json
do do
Precursor (new_state) Precursor (new_state)

View File

@@ -26,13 +26,13 @@ feature {NONE}
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
state: JSON_OBJECT state: WSF_JSON_OBJECT
-- Return empty -- Return empty
do do
create Result.make create Result.make
end end
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
-- There is no state to restore states -- There is no state to restore states
do do
end end

View File

@@ -38,15 +38,15 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
state_changes.replace (datasource.state, "datasource") state_changes.replace (datasource.state, "datasource")
end end
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
-- Restore datasource state from json -- Restore datasource state from json
do do
if attached {JSON_OBJECT} new_state.item ("datasource") as datasource_state then if attached {WSF_JSON_OBJECT} new_state.item ("datasource") as datasource_state then
datasource.set_state (datasource_state) datasource.set_state (datasource_state)
end end
end end
state: JSON_OBJECT state: WSF_JSON_OBJECT
-- Return state which contains the current datasource state -- Return state which contains the current datasource state
do do
create Result.make create Result.make

View File

@@ -39,10 +39,10 @@ feature {NONE} -- Initialization
feature -- State feature -- State
state: JSON_OBJECT state: WSF_JSON_OBJECT
do do
Result := Precursor {WSF_INPUT_CONTROL} Result := Precursor {WSF_INPUT_CONTROL}
Result.put (create {JSON_STRING}.make_json (template), "template") Result.put_string (template, "template")
end end
feature -- Callback feature -- Callback

View File

@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
-- Restore text from json -- Restore text from json
do do
if attached {JSON_BOOLEAN} new_state.item ("checked") as new_checked then if attached {JSON_BOOLEAN} new_state.item ("checked") as new_checked then
@@ -34,13 +34,13 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
end end
end end
state: JSON_OBJECT state: WSF_JSON_OBJECT
-- Return state which contains the current text and if there is an event handle attached -- Return state which contains the current text and if there is an event handle attached
do do
create Result.make create Result.make
Result.put (create {JSON_BOOLEAN}.make_boolean (checked), "checked") Result.put_boolean (checked, "checked")
Result.put (create {JSON_STRING}.make_json (checked_value), "checked_value") Result.put_string (checked_value, "checked_value")
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), "callback_change") Result.put_boolean (attached change_event, "callback_change")
end end
feature --Event handling feature --Event handling

View File

@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
-- Restore text from json -- Restore text from json
do do
if attached {JSON_STRING} new_state.item ("text") as new_text then if attached {JSON_STRING} new_state.item ("text") as new_text then
@@ -34,12 +34,12 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
end end
end end
state: JSON_OBJECT state: WSF_JSON_OBJECT
-- Return state which contains the current text and if there is an event handle attached -- Return state which contains the current text and if there is an event handle attached
do do
create Result.make create Result.make
Result.put (create {JSON_STRING}.make_json (text), "text") Result.put_string (text, "text")
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), "callback_change") Result.put_boolean (attached change_event, "callback_change")
end end
feature --Event handling feature --Event handling

View File

@@ -33,17 +33,17 @@ feature {NONE} -- Initialization
feature -- State handling feature -- State handling
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
do do
if attached {JSON_NUMBER} new_state.item ("progress") as new_progress then if attached {JSON_NUMBER} new_state.item ("progress") as new_progress then
progress := new_progress.item.to_integer progress := new_progress.item.to_integer
end end
end end
state: JSON_OBJECT state: WSF_JSON_OBJECT
do do
create Result.make create Result.make
Result.put (create {JSON_NUMBER}.make_integer (progress_value), "progress") Result.put_integer (progress_value, "progress")
end end
feature -- Event handling feature -- Event handling
@@ -51,7 +51,7 @@ feature -- Event handling
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING) handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
do do
if cname.same_string (control_name) and event.same_string ("progress_fetch") then if cname.same_string (control_name) and event.same_string ("progress_fetch") then
state_changes.put (create {JSON_NUMBER}.make_integer (progress_value), "progress") state_changes.put_integer (progress_value, "progress")
end end
end end
@@ -75,7 +75,7 @@ feature -- Change
valid_input_value: p >= 0 and p <= 100 valid_input_value: p >= 0 and p <= 100
do do
progress := p progress := p
state_changes.put (create {JSON_NUMBER}.make_integer (progress), "progress") state_changes.put_integer (progress, "progress")
end end
feature -- Implementation feature -- Implementation

View File

@@ -29,11 +29,11 @@ feature {NONE} -- Initialization
feature -- State handling feature -- State handling
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
do do
end end
state: JSON_OBJECT state: WSF_JSON_OBJECT
do do
create Result.make create Result.make
end end

View File

@@ -35,10 +35,10 @@ feature -- Implementation
feature -- State feature -- State
state: JSON_OBJECT state: WSF_JSON_OBJECT
do do
Result := Precursor Result := Precursor
Result.put (create {JSON_NUMBER}.make_integer (max), "max") Result.put_integer (max, "max")
end end
feature -- Properties feature -- Properties

View File

@@ -35,10 +35,10 @@ feature -- Implementation
feature -- State feature -- State
state: JSON_OBJECT state: WSF_JSON_OBJECT
do do
Result := Precursor Result := Precursor
Result.put (create {JSON_NUMBER}.make_integer (min), "min") Result.put_integer (min, "min")
end end
feature -- Properties feature -- Properties

View File

@@ -40,12 +40,12 @@ feature -- Implementation
feature -- State feature -- State
state: JSON_OBJECT state: WSF_JSON_OBJECT
do do
create Result.make create Result.make
Result.put (create {JSON_STRING}.make_json ("WSF_REGEXP_VALIDATOR"), "name") Result.put_string ("WSF_REGEXP_VALIDATOR", "name")
Result.put (create {JSON_STRING}.make_json (regexp_string), "expression") Result.put_string (regexp_string, "expression")
Result.put (create {JSON_STRING}.make_json (error), "error") Result.put_string (error, "error")
end end
feature -- Properties feature -- Properties

View File

@@ -17,12 +17,12 @@ feature {NONE} -- Initialization
feature -- Access feature -- Access
state: JSON_OBJECT state: WSF_JSON_OBJECT
-- JSON state of this validator -- JSON state of this validator
do do
create Result.make create Result.make
Result.put (create {JSON_STRING}.make_json (generator), "name") Result.put_string (generator, "name")
Result.put (create {JSON_STRING}.make_json (error), "error") Result.put_string (error, "error")
end end
is_valid (input: G): BOOLEAN is_valid (input: G): BOOLEAN

View File

@@ -27,7 +27,7 @@ feature {NONE} -- Initialization
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
-- Restore text from json -- Restore text from json
do do
if attached {JSON_STRING} new_state.item ("text") as new_text then if attached {JSON_STRING} new_state.item ("text") as new_text then
@@ -35,12 +35,12 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
end end
end end
state: JSON_OBJECT state: WSF_JSON_OBJECT
-- Return state which contains the current text and if there is an event handle attached -- Return state which contains the current text and if there is an event handle attached
do do
create Result.make create Result.make
Result.put (create {JSON_STRING}.make_json (text), "text") Result.put_string (text, "text")
Result.put (create {JSON_BOOLEAN}.make_boolean (attached click_event), "callback_click") Result.put_boolean (attached click_event, "callback_click")
end end
feature --Event handling feature --Event handling

View File

@@ -40,49 +40,49 @@ feature -- Actions
start_modal(url:STRING; title:STRING) start_modal(url:STRING; title:STRING)
--Start a modal window containg an other or the same page --Start a modal window containg an other or the same page
local local
modal:JSON_OBJECT modal:WSF_JSON_OBJECT
do do
create modal.make create modal.make
modal.put (create {JSON_STRING}.make_json("start_modal"), "type") modal.put_string ("start_modal", "type")
modal.put (create {JSON_STRING}.make_json(url), "url") modal.put_string (url, "url")
modal.put (create {JSON_STRING}.make_json(title), "title") modal.put_string (title, "title")
actions.add (modal) actions.add (modal)
end end
show_alert(mesage:STRING) show_alert(mesage:STRING)
--Start a modal window containg an other or the same page --Start a modal window containg an other or the same page
local local
modal:JSON_OBJECT modal:WSF_JSON_OBJECT
do do
create modal.make create modal.make
modal.put (create {JSON_STRING}.make_json("show_alert"), "type") modal.put_string ("show_alert", "type")
modal.put (create {JSON_STRING}.make_json(mesage), "message") modal.put_string (mesage, "message")
actions.add (modal) actions.add (modal)
end end
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
load_state (new_states: JSON_OBJECT) load_state (new_states: WSF_JSON_OBJECT)
-- Select state stored with `control_name` as key -- Select state stored with `control_name` as key
do do
if attached {JSON_OBJECT} new_states.item ("state") as new_state_obj then if attached {WSF_JSON_OBJECT} new_states.item ("state") as new_state_obj then
set_state (new_state_obj) set_state (new_state_obj)
end end
end end
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
-- Before we process the callback. We restore the state of control. -- Before we process the callback. We restore the state of control.
deferred deferred
end end
full_state: JSON_OBJECT full_state: WSF_JSON_OBJECT
-- Return state of object -- Return state of object
do do
create Result.make create Result.make
Result.put (state, "state") Result.put (state, "state")
end end
read_state_changes (states: JSON_OBJECT) read_state_changes (states: WSF_JSON_OBJECT)
-- Add a new entry in the `states_changes` JSON object with the `control_name` as key and the `state` as value -- Add a new entry in the `states_changes` JSON object with the `control_name` as key and the `state` as value
do do
if state_changes.count > 0 then if state_changes.count > 0 then
@@ -102,14 +102,14 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
end end
end end
state: JSON_OBJECT state: WSF_JSON_OBJECT
-- Returns the current state of the Control as JSON. This state will be transfered to the client. -- Returns the current state of the Control as JSON. This state will be transfered to the client.
deferred deferred
ensure ensure
controls_not_defined: not (attached Result.item ("controls")) controls_not_defined: not (attached Result.item ("controls"))
end end
state_changes: JSON_OBJECT state_changes: WSF_JSON_OBJECT
feature -- Rendering feature -- Rendering

View File

@@ -48,24 +48,24 @@ feature {NONE} -- Initialization
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
load_state (new_states: JSON_OBJECT) load_state (new_states: WSF_JSON_OBJECT)
-- Pass new_states to subcontrols -- Pass new_states to subcontrols
do do
Precursor (new_states) Precursor (new_states)
if attached {JSON_OBJECT} new_states.item ("controls") as ct and then attached {JSON_OBJECT} ct.item (value_control.control_name) as value_state then if attached {WSF_JSON_OBJECT} new_states.item ("controls") as ct and then attached {WSF_JSON_OBJECT} ct.item (value_control.control_name) as value_state then
value_control.load_state (value_state) value_control.load_state (value_state)
end end
end end
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
-- Set new state -- Set new state
do do
value_control.set_state (new_state) value_control.set_state (new_state)
end end
full_state: JSON_OBJECT full_state: WSF_JSON_OBJECT
local local
controls_state: JSON_OBJECT controls_state: WSF_JSON_OBJECT
do do
Result := Precursor Result := Precursor
create controls_state.make create controls_state.make
@@ -73,14 +73,14 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
Result.put (controls_state, "controls") Result.put (controls_state, "controls")
end end
read_state_changes (states: JSON_OBJECT) read_state_changes (states: WSF_JSON_OBJECT)
-- Read states_changes in subcontrols -- Read states_changes in subcontrols
do do
Precursor (states) Precursor (states)
value_control.read_state_changes (states) value_control.read_state_changes (states)
end end
state: JSON_OBJECT state: WSF_JSON_OBJECT
-- Read state -- Read state
local local
validator_description: JSON_ARRAY validator_description: JSON_ARRAY
@@ -92,7 +92,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
loop loop
validator_description.add (v.item.state) validator_description.add (v.item.state)
end end
Result.put (create {JSON_STRING}.make_json (value_control.control_name), "value_control") Result.put_string (value_control.control_name, "value_control")
Result.put (validator_description, "validators") Result.put (validator_description, "validators")
end end

View File

@@ -25,7 +25,7 @@ feature {NONE} -- Initialization
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
-- Restore html from json -- Restore html from json
do do
if attached {JSON_STRING} new_state.item ("html") as new_html then if attached {JSON_STRING} new_state.item ("html") as new_html then
@@ -33,11 +33,11 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
end end
end end
state: JSON_OBJECT state: WSF_JSON_OBJECT
-- Return state which contains the current html and if there is an event handle attached -- Return state which contains the current html and if there is an event handle attached
do do
create Result.make create Result.make
Result.put (create {JSON_STRING}.make_json (html), "html") Result.put_string (html, "html")
end end
feature --Event handling feature --Event handling
@@ -58,7 +58,7 @@ feature -- Implementation
do do
if not t.same_string (html) then if not t.same_string (html) then
html := t html := t
state_changes.replace (create {JSON_STRING}.make_json (html), "html") state_changes.replace_with_string (html, "html")
end end
end end

View File

@@ -0,0 +1,130 @@
note
description: "Summary description for {WSF_JSON_OBJECT}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
WSF_JSON_OBJECT
inherit
JSON_OBJECT
create
make
feature
put_string (value: READABLE_STRING_GENERAL; key: JSON_STRING)
-- Assuming there is no item of key `key',
-- insert `value' with `key'.
require
key_not_present: not has_key (key)
local
l_value: JSON_STRING
do
create l_value.make_json_from_string_32 (value.as_string_32)
put (l_value, key)
end
put_integer (value: INTEGER_64; key: JSON_STRING)
-- Assuming there is no item of key `key',
-- insert `value' with `key'.
require
key_not_present: not has_key (key)
local
l_value: JSON_NUMBER
do
create l_value.make_integer (value)
put (l_value, key)
end
put_natural (value: NATURAL_64; key: JSON_STRING)
-- Assuming there is no item of key `key',
-- insert `value' with `key'.
require
key_not_present: not has_key (key)
local
l_value: JSON_NUMBER
do
create l_value.make_natural (value)
put (l_value, key)
end
put_real (value: DOUBLE; key: JSON_STRING)
-- Assuming there is no item of key `key',
-- insert `value' with `key'.
require
key_not_present: not has_key (key)
local
l_value: JSON_NUMBER
do
create l_value.make_real (value)
put (l_value, key)
end
put_boolean (value: BOOLEAN; key: JSON_STRING)
-- Assuming there is no item of key `key',
-- insert `value' with `key'.
require
key_not_present: not has_key (key)
local
l_value: JSON_BOOLEAN
do
create l_value.make_boolean (value)
put (l_value, key)
end
replace_with_string (value: READABLE_STRING_GENERAL; key: JSON_STRING)
-- Assuming there is no item of key `key',
-- insert `value' with `key'.
local
l_value: JSON_STRING
do
create l_value.make_json_from_string_32 (value.as_string_32)
replace (l_value, key)
end
replace_with_integer (value: INTEGER_64; key: JSON_STRING)
-- Assuming there is no item of key `key',
-- insert `value' with `key'.
local
l_value: JSON_NUMBER
do
create l_value.make_integer (value)
replace (l_value, key)
end
replace_with_with_natural (value: NATURAL_64; key: JSON_STRING)
-- Assuming there is no item of key `key',
-- insert `value' with `key'.
local
l_value: JSON_NUMBER
do
create l_value.make_natural (value)
replace (l_value, key)
end
replace_with_real (value: DOUBLE; key: JSON_STRING)
-- Assuming there is no item of key `key',
-- insert `value' with `key'.
local
l_value: JSON_NUMBER
do
create l_value.make_real (value)
replace (l_value, key)
end
replace_with_boolean (value: BOOLEAN; key: JSON_STRING)
-- Assuming there is no item of key `key',
-- insert `value' with `key'.
local
l_value: JSON_BOOLEAN
do
create l_value.make_boolean (value)
replace (l_value, key)
end
end

View File

@@ -36,16 +36,16 @@ feature {NONE} -- Initialization
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
load_state (new_states: JSON_OBJECT) load_state (new_states: WSF_JSON_OBJECT)
-- Pass new_states to subcontrols -- Pass new_states to subcontrols
do do
Precursor (new_states) Precursor (new_states)
if attached {JSON_OBJECT} new_states.item ("controls") as ct then if attached {WSF_JSON_OBJECT} new_states.item ("controls") as ct then
across across
controls as c controls as c
loop loop
if attached {WSF_CONTROL} c.item as cont then if attached {WSF_CONTROL} c.item as cont then
if attached {JSON_OBJECT} ct.item (cont.control_name) as value_state then if attached {WSF_JSON_OBJECT} ct.item (cont.control_name) as value_state then
cont.load_state (value_state) cont.load_state (value_state)
end end
end end
@@ -53,15 +53,15 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
end end
end end
set_state (new_state: JSON_OBJECT) set_state (new_state: WSF_JSON_OBJECT)
-- Before we process the callback. We restore the state of control. -- Before we process the callback. We restore the state of control.
do do
end end
full_state: JSON_OBJECT full_state: WSF_JSON_OBJECT
-- Read states in subcontrols -- Read states in subcontrols
local local
controls_state: JSON_OBJECT controls_state: WSF_JSON_OBJECT
do do
Result := Precursor Result := Precursor
create controls_state.make create controls_state.make
@@ -75,7 +75,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
Result.put (controls_state, "controls") Result.put (controls_state, "controls")
end end
read_state_changes (states: JSON_OBJECT) read_state_changes (states: WSF_JSON_OBJECT)
-- Read states_changes in subcontrols -- Read states_changes in subcontrols
do do
Precursor (states) Precursor (states)
@@ -88,7 +88,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
end end
end end
state: JSON_OBJECT state: WSF_JSON_OBJECT
--Read state --Read state
do do
create Result.make create Result.make

View File

@@ -60,7 +60,7 @@ feature -- Implementation
event_parameter: detachable STRING event_parameter: detachable STRING
event_control_name: detachable STRING event_control_name: detachable STRING
states: STRING states: STRING
states_changes: JSON_OBJECT states_changes: WSF_JSON_OBJECT
json_parser: JSON_PARSER json_parser: JSON_PARSER
do do
event_control_name := get_parameter ("control_name") event_control_name := get_parameter ("control_name")
@@ -70,7 +70,7 @@ feature -- Implementation
create states.make_empty create states.make_empty
request.read_input_data_into (states) request.read_input_data_into (states)
create json_parser.make_parser (states) create json_parser.make_parser (states)
if attached {JSON_OBJECT} json_parser.parse_json as sp then if attached {WSF_JSON_OBJECT} json_parser.parse_json as sp then
set_state (sp) set_state (sp)
end end
handle_callback (event_control_name, event, event_parameter) handle_callback (event_control_name, event, event_parameter)
@@ -126,7 +126,7 @@ feature -- Implementation
end end
read_state_changes (states: JSON_OBJECT) read_state_changes (states: WSF_JSON_OBJECT)
-- Add a new entry in the `states_changes` JSON object with the `control_name` as key and the `state` as value -- Add a new entry in the `states_changes` JSON object with the `control_name` as key and the `state` as value
do do
Precursor (states) Precursor (states)
@@ -155,24 +155,24 @@ feature -- Event handling
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
state: JSON_OBJECT state: WSF_JSON_OBJECT
do do
create Result.make create Result.make
Result.put (create {JSON_STRING}.make_json (control_name), "id") Result.put_string (control_name, "id")
Result.put (create {JSON_STRING}.make_json (request.path_info), "url") Result.put_string (request.path_info, "url")
Result.put (create {JSON_STRING}.make_json (request.query_string), "url_params") Result.put_string (request.query_string, "url_params")
end end
set_state (sp: JSON_OBJECT) set_state (sp: WSF_JSON_OBJECT)
do do
if attached {JSON_OBJECT} sp.item ("controls") as ct and then attached {JSON_OBJECT} ct.item (control.control_name) as value_state then if attached {WSF_JSON_OBJECT} sp.item ("controls") as ct and then attached {WSF_JSON_OBJECT} ct.item (control.control_name) as value_state then
control.load_state (value_state) control.load_state (value_state)
end end
end end
full_state: JSON_OBJECT full_state: WSF_JSON_OBJECT
local local
controls_state: JSON_OBJECT controls_state: WSF_JSON_OBJECT
do do
create Result.make create Result.make
create controls_state.make create controls_state.make