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
@@ -25,19 +25,19 @@ feature --Event handling
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
do
create Result.make
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
Result.put (create {JSON_NULL}, "sort_column")
end
Result.put (create {JSON_BOOLEAN}.make_boolean (sort_direction), "sort_direction")
Result.put_boolean (sort_direction, "sort_direction")
end
set_state (new_state: JSON_OBJECT)
set_state (new_state: WSF_JSON_OBJECT)
-- Restore sort_column and sort_direction from json
do
if attached {JSON_STRING} new_state.item ("sort_column") as new_sort_column then
@@ -35,16 +35,16 @@ feature --Event handling
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
do
Result := Precursor
Result.put (create {JSON_NUMBER}.make_integer (page), "page")
Result.put (create {JSON_NUMBER}.make_integer (page_size), "page_size")
Result.put (create {JSON_NUMBER}.make_integer (row_count), "row_count")
Result.put_integer (page, "page")
Result.put_integer (page_size, "page_size")
Result.put_integer (row_count, "row_count")
end
set_state (new_state: JSON_OBJECT)
set_state (new_state: WSF_JSON_OBJECT)
-- Restore page, page_size and row_count from json
do
Precursor (new_state)
@@ -26,13 +26,13 @@ feature {NONE}
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
state: JSON_OBJECT
state: WSF_JSON_OBJECT
-- Return empty
do
create Result.make
end
set_state (new_state: JSON_OBJECT)
set_state (new_state: WSF_JSON_OBJECT)
-- There is no state to restore states
do
end
@@ -38,15 +38,15 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
state_changes.replace (datasource.state, "datasource")
end
set_state (new_state: JSON_OBJECT)
set_state (new_state: WSF_JSON_OBJECT)
-- Restore datasource state from json
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)
end
end
state: JSON_OBJECT
state: WSF_JSON_OBJECT
-- Return state which contains the current datasource state
do
create Result.make