Add Grid Widget
This commit is contained in:
@@ -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
|
||||
|
||||
45
examples/widgetapp/demo_data.e
Normal file
45
examples/widgetapp/demo_data.e
Normal 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
|
||||
38
examples/widgetapp/demo_datasource.e
Normal file
38
examples/widgetapp/demo_datasource.e
Normal 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
|
||||
34
examples/widgetapp/grid_page.e
Normal file
34
examples/widgetapp/grid_page.e
Normal 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
|
||||
Reference in New Issue
Block a user