Add Grid Widget

This commit is contained in:
YNH Webdev
2013-09-13 00:20:27 +02:00
parent 8fc405fef1
commit 36368aff0b
9 changed files with 355 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ feature {NONE} -- Initialization
do
-- router.map (create {WSF_URI_MAPPING}.make ("/hello", create {WSF_AGENT_URI_HANDLER}.make (agent execute_hello)))
map_agent_uri ("/", agent execute_hello, Void)
map_agent_uri ("/grid", agent grid_demo, Void)
map_agent_uri ("/widget.js", agent load_js, Void)
end
@@ -55,6 +56,16 @@ feature -- Execution
page.execute
end
grid_demo (req: WSF_REQUEST; res: WSF_RESPONSE)
local
page: GRID_PAGE
do
-- To send a response we need to setup, the status code and
-- the response headers.
create page.make (req, res)
page.execute
end
load_js (req: WSF_REQUEST; res: WSF_RESPONSE)
local
f: WSF_FILE_RESPONSE

View File

@@ -0,0 +1,45 @@
note
description: "Summary description for {DEMO_DATA}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
DEMO_DATA
inherit
WSF_ENTITY
create
make
feature {NONE}
make (a_id: INTEGER; a_name, a_description: STRING)
do
id := a_id
name := a_name
description := a_description
end
feature
id: INTEGER
name: STRING
description: STRING
get (field: STRING): detachable ANY
do
if field.is_equal ("id") then
Result := id
elseif field.is_equal ("name") then
Result := name
elseif field.is_equal ("description") then
Result := description
end
end
end

View File

@@ -0,0 +1,38 @@
note
description: "Summary description for {DEMO_DATASOURCE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
DEMO_DATASOURCE
inherit
WSF_DATASOURCE [DEMO_DATA]
create
make_demo
feature
make_demo
do
page := 1
page_size := 10
end
data: ITERABLE [DEMO_DATA]
local
list: LINKED_LIST [DEMO_DATA]
do
create list.make
across
((page - 1) * page_size) |..| (page * page_size - 1) as c
loop
list.extend (create {DEMO_DATA}.make(c.item,"Name"+c.item.out,"desc "+c.item.out))
end
Result := list
end
end

View File

@@ -0,0 +1,34 @@
note
description: "Summary description for {GRID_PAGE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
GRID_PAGE
inherit
WSF_PAGE_CONTROL
create
make
feature
initialize_controls
local
ds: DEMO_DATASOURCE
do
create ds.make_demo
create grid.make_grid ("mygrid", <<create {WSF_GRID_COLUMN}.make_column ("#", "id"), create {WSF_GRID_COLUMN}.make_column ("Name", "name"), create {WSF_GRID_COLUMN}.make_column ("Description", "description")>>, ds)
control := grid
end
process
do
end
grid: WSF_GRID_CONTROL [DEMO_DATA]
end