Workin file upload
This commit is contained in:
@@ -32,6 +32,9 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
if attached {JSON_STRING} new_state.item ("file") as new_name and attached {JSON_STRING} new_state.item ("type") as new_type and attached {JSON_NUMBER} new_state.item ("size") as new_size then
|
||||
create file.make (new_name.unescaped_string_32, new_type.unescaped_string_32, new_size.item.to_integer_32);
|
||||
end
|
||||
if attached {JSON_STRING} new_state.item ("upload_file") as f then
|
||||
upload_file:=f.unescaped_string_32;
|
||||
end
|
||||
end
|
||||
|
||||
state: WSF_JSON_OBJECT
|
||||
@@ -41,7 +44,18 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- State management
|
||||
Result.put_boolean (attached change_event, "callback_change")
|
||||
end
|
||||
|
||||
feature --Event handling
|
||||
feature -- Uploaded Files
|
||||
|
||||
set_uploaded_file (p: detachable STRING)
|
||||
-- Store link to uploaded file in control state. In order to make it availabe for future callbacks
|
||||
do
|
||||
if attached p as a_p then
|
||||
upload_file := a_p
|
||||
state_changes.put_string (a_p, "upload_file")
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Event handling
|
||||
|
||||
set_change_event (e: attached like change_event)
|
||||
-- Set text change event handle
|
||||
@@ -49,11 +63,20 @@ feature --Event handling
|
||||
change_event := e
|
||||
end
|
||||
|
||||
set_upload_function (e: attached like upload_function)
|
||||
-- Set button click event handle
|
||||
do
|
||||
upload_function := e
|
||||
end
|
||||
|
||||
handle_callback (cname: LIST [STRING]; event: STRING; event_parameter: detachable ANY)
|
||||
do
|
||||
if Current.control_name.same_string (cname [1]) and attached change_event as cevent then
|
||||
if event.same_string ("change") then
|
||||
if Current.control_name.same_string (cname [1]) then
|
||||
if attached change_event as cevent and event.same_string ("change") then
|
||||
cevent.call (Void)
|
||||
elseif attached upload_function as ufunction and event.same_string ("uploadfile") and attached {ITERABLE[WSF_UPLOADED_FILE]}event_parameter as files then
|
||||
|
||||
set_uploaded_file(ufunction.item ([files]))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -89,4 +112,10 @@ feature -- Properties
|
||||
change_event: detachable PROCEDURE [ANY, TUPLE]
|
||||
-- Procedure to be execued on change
|
||||
|
||||
upload_function: detachable FUNCTION [ANY, TUPLE[ITERABLE[WSF_UPLOADED_FILE]],detachable STRING]
|
||||
-- Procedure to be execued on change
|
||||
|
||||
upload_file: detachable STRING
|
||||
-- Link to uploaded file
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user