First working callback

This commit is contained in:
YNH Webdev
2013-08-28 00:04:42 +02:00
parent ef34217a6d
commit cb7f1f0ee3
7 changed files with 191 additions and 17 deletions

View File

@@ -31,16 +31,21 @@ feature
do
end
handle_callback (event: STRING; cname: STRING; page: WSF_PAGE_CONTROL)
set_click_event (e: PROCEDURE [ANY, TUPLE [WSF_PAGE_CONTROL]])
do
if Current.control_name = cname and attached click_event then
click_event := e
end
handle_callback (cname: STRING; event: STRING; page: WSF_PAGE_CONTROL)
do
if Current.control_name.is_equal (cname) and attached click_event then
click_event.call ([page])
end
end
render: STRING
do
Result := "<button>" + text + "</button>"
Result := "<button data-name=%"" + control_name + "%" data-type=%"WSF_BUTTON_CONTROL%">" + text + "</button>"
end
state: JSON_OBJECT

View File

@@ -13,7 +13,7 @@ feature
feature {WSF_PAGE_CONTROL, WSF_CONTROL}
handle_callback (event: STRING; cname: STRING; page: WSF_PAGE_CONTROL)
handle_callback (cname: STRING; event: STRING; page: WSF_PAGE_CONTROL)
deferred
end

View File

@@ -59,12 +59,25 @@ feature
render
local
data: STRING
page: WSF_PAGE_RESPONSE
states: JSON_OBJECT
do
data := control.render
response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/html"]>>)
response.put_string ("<html><head></head><body>")
response.put_string (data)
response.put_string ("</body></html>")
create states.make
control.read_state (states)
data := "<html><head>"
data.append ("</head><body>")
data.append (control.render)
data.append ("<script type=%"text/javascript%">var states=")
data.append (states.representation)
data.append (";</script>")
data.append ("<script src=%"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js%"></script>")
data.append ("<script src=%"/widget.js%"></script>")
data.append ("</body></html>")
create page.make
page.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/html"]>>)
page.set_body (data)
response.send (page)
end
get_parameter (key: STRING): detachable STRING