Move project to wsf_js_widget
This commit is contained in:
57
library/server/wsf_js_widget/webcontrol/wsf_basic_control.e
Normal file
57
library/server/wsf_js_widget/webcontrol/wsf_basic_control.e
Normal file
@@ -0,0 +1,57 @@
|
||||
note
|
||||
description: "Summary description for {WSF_BASIC_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_BASIC_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_STATELESS_CONTROL
|
||||
|
||||
create
|
||||
make_control,
|
||||
make_with_body
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_control (t: STRING)
|
||||
do
|
||||
make_with_body (t, "", "")
|
||||
end
|
||||
|
||||
make_with_body (t,attr,a_content: STRING)
|
||||
do
|
||||
make (t)
|
||||
attributes := attr
|
||||
content := a_content
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
attributes: STRING
|
||||
|
||||
content: STRING
|
||||
|
||||
feature -- Rendering
|
||||
|
||||
render: STRING
|
||||
do
|
||||
Result := render_tag (content, attributes)
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
set_attributes (a: STRING)
|
||||
do
|
||||
attributes := a
|
||||
end
|
||||
|
||||
set_content (c: STRING)
|
||||
do
|
||||
content := c
|
||||
end
|
||||
|
||||
end
|
||||
81
library/server/wsf_js_widget/webcontrol/wsf_button_control.e
Normal file
81
library/server/wsf_js_widget/webcontrol/wsf_button_control.e
Normal file
@@ -0,0 +1,81 @@
|
||||
note
|
||||
description: "Summary description for {WSF_BUTTON_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_BUTTON_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_CONTROL
|
||||
|
||||
create
|
||||
make_button
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_button (n: STRING; t: STRING)
|
||||
do
|
||||
make_control (n, "button")
|
||||
add_class ("btn")
|
||||
add_class ("btn-default")
|
||||
text := t
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore text from json
|
||||
do
|
||||
if attached {JSON_STRING} new_state.item (create {JSON_STRING}.make_json ("text")) as new_text then
|
||||
text := new_text.unescaped_string_32
|
||||
end
|
||||
end
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Return state which contains the current text and if there is an event handle attached
|
||||
do
|
||||
create Result.make
|
||||
Result.put (create {JSON_STRING}.make_json (text), create {JSON_STRING}.make_json ("text"))
|
||||
Result.put (create {JSON_BOOLEAN}.make_boolean (attached click_event), create {JSON_STRING}.make_json ("callback_click"))
|
||||
end
|
||||
|
||||
feature --EVENT HANDLING
|
||||
|
||||
set_click_event (e: attached like click_event)
|
||||
-- Set button click event handle
|
||||
do
|
||||
click_event := e
|
||||
end
|
||||
|
||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||
do
|
||||
if Current.control_name.is_equal (cname) and attached click_event as cevent then
|
||||
cevent.call ([])
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
render: STRING
|
||||
do
|
||||
Result := render_tag (text, "")
|
||||
end
|
||||
|
||||
set_text (t: STRING)
|
||||
do
|
||||
if not t.is_equal (text) then
|
||||
text := t
|
||||
state_changes.replace (create {JSON_STRING}.make_json (text), create {JSON_STRING}.make_json ("text"))
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
text: STRING
|
||||
|
||||
click_event: detachable PROCEDURE [ANY, TUPLE []]
|
||||
|
||||
end
|
||||
97
library/server/wsf_js_widget/webcontrol/wsf_control.e
Normal file
97
library/server/wsf_js_widget/webcontrol/wsf_control.e
Normal file
@@ -0,0 +1,97 @@
|
||||
note
|
||||
description: "Summary description for {WSF_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_STATELESS_CONTROL
|
||||
redefine
|
||||
render_tag
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
control_name: STRING
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_control (n, a_tag_name: STRING)
|
||||
do
|
||||
make (a_tag_name)
|
||||
control_name := n
|
||||
create state_changes.make
|
||||
ensure
|
||||
attached state_changes
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
|
||||
load_state (new_states: JSON_OBJECT)
|
||||
-- Select state stored with `control_name` as key
|
||||
do
|
||||
if attached {JSON_OBJECT} new_states.item (control_name) as new_state_obj then
|
||||
set_state (new_state_obj)
|
||||
end
|
||||
end
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Before we process the callback. We restore the state of control.
|
||||
deferred
|
||||
end
|
||||
|
||||
read_state (states: JSON_OBJECT)
|
||||
-- Add a new entry in the `states` JSON object with the `control_name` as key and the `state` as value
|
||||
do
|
||||
states.put (state, control_name)
|
||||
end
|
||||
|
||||
read_state_changes (states: JSON_OBJECT)
|
||||
-- Add a new entry in the `states_changes` JSON object with the `control_name` as key and the `state` as value
|
||||
do
|
||||
if state_changes.count > 0 then
|
||||
states.put (state_changes, control_name)
|
||||
end
|
||||
end
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Returns the current state of the Control as JSON. This state will be transfered to the client.
|
||||
deferred
|
||||
end
|
||||
|
||||
state_changes: JSON_OBJECT
|
||||
|
||||
feature -- Rendering
|
||||
|
||||
render_tag (body, attrs: STRING): STRING
|
||||
do
|
||||
Result := render_tag_with_generator_name (generator, body, attrs)
|
||||
end
|
||||
|
||||
render_tag_with_generator_name (a_generator, body, attrs: STRING): STRING
|
||||
local
|
||||
css_classes_string: STRING
|
||||
l_attributes: STRING
|
||||
do
|
||||
css_classes_string := ""
|
||||
across
|
||||
css_classes as c
|
||||
loop
|
||||
css_classes_string := css_classes_string + " " + c.item
|
||||
end
|
||||
l_attributes := "id=%"" + control_name + "%" data-name=%"" + control_name + "%" data-type=%"" + a_generator + "%" " + attrs
|
||||
Result := render_tag_with_tagname (tag_name, body, l_attributes, css_classes_string)
|
||||
end
|
||||
|
||||
feature -- EVENT HANDLING
|
||||
|
||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||
-- Method called if any callback received. In this method you can route the callback to the event handler
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
48
library/server/wsf_js_widget/webcontrol/wsf_form_control.e
Normal file
48
library/server/wsf_js_widget/webcontrol/wsf_form_control.e
Normal file
@@ -0,0 +1,48 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_MULTI_CONTROL [WSF_CONTROL]
|
||||
|
||||
WSF_VALIDATABLE
|
||||
|
||||
create
|
||||
make_form_control
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_form_control (n: STRING)
|
||||
do
|
||||
make_multi_control (n)
|
||||
tag_name := "form"
|
||||
end
|
||||
|
||||
feature -- Validation
|
||||
|
||||
validate
|
||||
do
|
||||
is_valid := True
|
||||
across
|
||||
controls as c
|
||||
until
|
||||
is_valid = False
|
||||
loop
|
||||
if attached {WSF_VALIDATABLE} c.item as elem then
|
||||
elem.validate
|
||||
if not elem.is_valid then
|
||||
is_valid := False
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
is_valid: BOOLEAN
|
||||
|
||||
end
|
||||
@@ -0,0 +1,167 @@
|
||||
note
|
||||
description: "Summary description for {WSF_FORM_ELEMENT_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_FORM_ELEMENT_CONTROL [G]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_CONTROL
|
||||
redefine
|
||||
read_state_changes,
|
||||
load_state,
|
||||
read_state
|
||||
end
|
||||
|
||||
WSF_VALIDATABLE
|
||||
|
||||
create
|
||||
make_form_element, make_form_element_with_validators
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_form_element (a_label: STRING; c: WSF_VALUE_CONTROL [G])
|
||||
do
|
||||
make_form_element_with_validators (a_label, c, create {ARRAYED_LIST [WSF_VALIDATOR [G]]}.make (0))
|
||||
end
|
||||
|
||||
make_form_element_with_validators (a_label: STRING; c: WSF_VALUE_CONTROL [G]; v: LIST [WSF_VALIDATOR [G]])
|
||||
do
|
||||
make_control (c.control_name + "_container", "div")
|
||||
add_class ("form-group")
|
||||
if attached {WSF_INPUT_CONTROL} c or attached {WSF_TEXTAREA_CONTROL} c then
|
||||
c.add_class ("form-control")
|
||||
end
|
||||
if attached {WSF_HTML_CONTROL} c then
|
||||
c.add_class ("form-control-static")
|
||||
end
|
||||
value_control := c
|
||||
validators := v
|
||||
label := a_label
|
||||
error := ""
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
|
||||
load_state (new_states: JSON_OBJECT)
|
||||
-- Pass new_states to subcontrols
|
||||
do
|
||||
Precursor (new_states)
|
||||
value_control.load_state (new_states)
|
||||
end
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
do
|
||||
value_control.set_state (new_state)
|
||||
end
|
||||
|
||||
read_state (states: JSON_OBJECT)
|
||||
-- Read states in subcontrols
|
||||
do
|
||||
Precursor (states)
|
||||
value_control.read_state (states)
|
||||
end
|
||||
|
||||
read_state_changes (states: JSON_OBJECT)
|
||||
-- Read states_changes in subcontrols
|
||||
do
|
||||
Precursor (states)
|
||||
value_control.read_state_changes (states)
|
||||
end
|
||||
|
||||
state: JSON_OBJECT
|
||||
--Read state
|
||||
local
|
||||
validator_description: JSON_ARRAY
|
||||
do
|
||||
create Result.make
|
||||
create validator_description.make_array
|
||||
across
|
||||
validators as v
|
||||
loop
|
||||
validator_description.add (v.item.state)
|
||||
end
|
||||
Result.put (create {JSON_STRING}.make_json (value_control.control_name), "value_control")
|
||||
Result.put (validator_description, "validators")
|
||||
end
|
||||
|
||||
feature --EVENT HANDLING
|
||||
|
||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||
-- Pass callback to subcontrols
|
||||
do
|
||||
if cname.same_string (control_name) then
|
||||
if event.same_string ("validate") then
|
||||
validate
|
||||
end
|
||||
else
|
||||
value_control.handle_callback (cname, event, event_parameter)
|
||||
end
|
||||
end
|
||||
|
||||
feature --Implementation
|
||||
|
||||
render: STRING
|
||||
local
|
||||
body: STRING
|
||||
do
|
||||
body := ""
|
||||
if not label.is_empty then
|
||||
body.append ("<label class=%"col-lg-2 control-label%" for=%"" + value_control.control_name + "%">" + label + "</label>")
|
||||
end
|
||||
body.append ("<div class=%"col-lg-10%">")
|
||||
body.append (value_control.render)
|
||||
body.append ("</div>")
|
||||
Result := render_tag (body, "")
|
||||
end
|
||||
|
||||
feature -- Validation
|
||||
|
||||
add_validator (v: WSF_VALIDATOR [G])
|
||||
do
|
||||
validators.extend (v)
|
||||
end
|
||||
|
||||
set_error (e: STRING)
|
||||
do
|
||||
error := e
|
||||
state_changes.replace (create {JSON_STRING}.make_json (e), create {JSON_STRING}.make_json ("error"))
|
||||
end
|
||||
|
||||
validate
|
||||
local
|
||||
current_value: G
|
||||
do
|
||||
current_value := value_control.value
|
||||
is_valid := True
|
||||
across
|
||||
validators as c
|
||||
until
|
||||
not is_valid
|
||||
loop
|
||||
if not c.item.is_valid (current_value) then
|
||||
is_valid := False
|
||||
set_error (c.item.error)
|
||||
end
|
||||
end
|
||||
if is_valid then
|
||||
set_error ("")
|
||||
end
|
||||
end
|
||||
|
||||
is_valid: BOOLEAN
|
||||
|
||||
feature
|
||||
|
||||
value_control: WSF_VALUE_CONTROL [G]
|
||||
|
||||
validators: LIST [WSF_VALIDATOR [G]]
|
||||
|
||||
label: STRING
|
||||
|
||||
error: STRING
|
||||
|
||||
end
|
||||
72
library/server/wsf_js_widget/webcontrol/wsf_html_control.e
Normal file
72
library/server/wsf_js_widget/webcontrol/wsf_html_control.e
Normal file
@@ -0,0 +1,72 @@
|
||||
note
|
||||
description: "Summary description for {WSF_html_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_HTML_CONTROL
|
||||
|
||||
inherit
|
||||
|
||||
WSF_VALUE_CONTROL [STRING]
|
||||
|
||||
create
|
||||
make_html
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make_html (n, t, v: STRING)
|
||||
do
|
||||
make_control (n, t)
|
||||
html := v
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Restore html from json
|
||||
do
|
||||
if attached {JSON_STRING} new_state.item (create {JSON_STRING}.make_json ("html")) as new_html then
|
||||
html := new_html.unescaped_string_32
|
||||
end
|
||||
end
|
||||
|
||||
state: JSON_OBJECT
|
||||
-- Return state which contains the current html and if there is an event handle attached
|
||||
do
|
||||
create Result.make
|
||||
Result.put (create {JSON_STRING}.make_json (html), create {JSON_STRING}.make_json ("html"))
|
||||
end
|
||||
|
||||
feature --EVENT HANDLING
|
||||
|
||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Implementation
|
||||
|
||||
render: STRING
|
||||
do
|
||||
Result := render_tag (html, "")
|
||||
end
|
||||
|
||||
set_html (t: STRING)
|
||||
do
|
||||
if not t.is_equal (html) then
|
||||
html := t
|
||||
state_changes.replace (create {JSON_STRING}.make_json (html), create {JSON_STRING}.make_json ("html"))
|
||||
end
|
||||
end
|
||||
|
||||
value: STRING
|
||||
do
|
||||
Result := html
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
html: STRING
|
||||
|
||||
end
|
||||
126
library/server/wsf_js_widget/webcontrol/wsf_multi_control.e
Normal file
126
library/server/wsf_js_widget/webcontrol/wsf_multi_control.e
Normal file
@@ -0,0 +1,126 @@
|
||||
note
|
||||
description: "Summary description for {WSF_MULTI_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_MULTI_CONTROL [G -> WSF_STATELESS_CONTROL]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_CONTROL
|
||||
redefine
|
||||
read_state,
|
||||
read_state_changes,
|
||||
load_state
|
||||
end
|
||||
|
||||
create
|
||||
make_multi_control, make_with_tag_name
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_multi_control (n: STRING)
|
||||
do
|
||||
make_with_tag_name (n, "div")
|
||||
end
|
||||
|
||||
make_with_tag_name (n, t: STRING)
|
||||
do
|
||||
make_control (n, t)
|
||||
controls := create {LINKED_LIST [G]}.make;
|
||||
end
|
||||
|
||||
feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
|
||||
|
||||
load_state (new_states: JSON_OBJECT)
|
||||
-- Pass new_states to subcontrols
|
||||
do
|
||||
Precursor (new_states)
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
if attached {WSF_CONTROL} c.item as cont then
|
||||
cont.load_state (new_states)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
set_state (new_state: JSON_OBJECT)
|
||||
-- Before we process the callback. We restore the state of control.
|
||||
do
|
||||
end
|
||||
|
||||
read_state (states: JSON_OBJECT)
|
||||
-- Read states in subcontrols
|
||||
do
|
||||
Precursor (states)
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
if attached {WSF_CONTROL} c.item as cont then
|
||||
cont.read_state (states)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
read_state_changes (states: JSON_OBJECT)
|
||||
-- Read states_changes in subcontrols
|
||||
do
|
||||
Precursor (states)
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
if attached {WSF_CONTROL} c.item as cont then
|
||||
cont.read_state_changes (states)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
state: JSON_OBJECT
|
||||
--Read state
|
||||
do
|
||||
create Result.make
|
||||
end
|
||||
|
||||
feature -- EVENT HANDLING
|
||||
|
||||
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
|
||||
-- Pass callback to subcontrols
|
||||
do
|
||||
if equal (cname, control_name) then
|
||||
else
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
if attached {WSF_CONTROL} c.item as cont then
|
||||
cont.handle_callback (cname, event, event_parameter)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
render: STRING
|
||||
do
|
||||
Result := ""
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
Result := c.item.render + Result
|
||||
end
|
||||
Result := render_tag (Result, "")
|
||||
end
|
||||
|
||||
add_control (c: detachable G)
|
||||
do
|
||||
if attached c as d then
|
||||
controls.put_front (d)
|
||||
end
|
||||
end
|
||||
|
||||
controls: LINKED_LIST [G]
|
||||
|
||||
end
|
||||
115
library/server/wsf_js_widget/webcontrol/wsf_page_control.e
Normal file
115
library/server/wsf_js_widget/webcontrol/wsf_page_control.e
Normal file
@@ -0,0 +1,115 @@
|
||||
note
|
||||
description: "Summary description for {WSF_PAGE_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_PAGE_CONTROL
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
request := req
|
||||
response := res
|
||||
initialize_controls
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
request: WSF_REQUEST
|
||||
|
||||
response: WSF_RESPONSE
|
||||
|
||||
feature
|
||||
|
||||
initialize_controls
|
||||
-- Initalize all the controls, all the event handles must be set in this function.
|
||||
deferred
|
||||
ensure
|
||||
attached control
|
||||
end
|
||||
|
||||
process
|
||||
-- Function called on page load (not on callback)
|
||||
deferred
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
execute
|
||||
-- Entry Point: If request is a callback, restore control states and execute handle then return new state json.
|
||||
-- If request is not a callback. Run process and render the html page
|
||||
local
|
||||
event: detachable STRING
|
||||
event_parameter: detachable STRING
|
||||
control_name: detachable STRING
|
||||
states: detachable STRING
|
||||
states_changes: JSON_OBJECT
|
||||
json_parser: JSON_PARSER
|
||||
do
|
||||
control_name := get_parameter ("control_name")
|
||||
event := get_parameter ("event")
|
||||
event_parameter := get_parameter ("event_parameter")
|
||||
states := get_parameter ("states")
|
||||
if attached event and attached control_name and attached control and attached states then
|
||||
create json_parser.make_parser (states)
|
||||
if attached {JSON_OBJECT} json_parser.parse_json as sp then
|
||||
control.load_state (sp)
|
||||
end
|
||||
control.handle_callback (control_name, event, event_parameter)
|
||||
create states_changes.make
|
||||
control.read_state_changes (states_changes)
|
||||
response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "application/json; charset=ISO-8859-1"]>>)
|
||||
response.put_string (states_changes.representation)
|
||||
else
|
||||
process
|
||||
render
|
||||
end
|
||||
end
|
||||
|
||||
render
|
||||
-- Render and send the HTML Page
|
||||
local
|
||||
data: STRING
|
||||
page: WSF_PAGE_RESPONSE
|
||||
states: JSON_OBJECT
|
||||
do
|
||||
data := "<html><head>"
|
||||
data.append ("<link href=%"/bootstrap.min.css%" rel=%"stylesheet%">")
|
||||
data.append ("<link href=%"/widget.css%" rel=%"stylesheet%">")
|
||||
data.append ("</head><body>")
|
||||
data.append (control.render)
|
||||
data.append ("<script type=%"text/javascript%">window.states=")
|
||||
create states.make
|
||||
control.read_state (states)
|
||||
data.append (states.representation)
|
||||
data.append (";</script>")
|
||||
data.append ("<script src=%"/jquery.min.js%"></script>")
|
||||
data.append ("<script src=%"/typeahead.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; charset=ISO-8859-1"]>>)
|
||||
page.set_body (data)
|
||||
response.send (page)
|
||||
end
|
||||
|
||||
get_parameter (key: STRING): detachable STRING
|
||||
-- Read query parameter as string
|
||||
local
|
||||
value: detachable WSF_VALUE
|
||||
do
|
||||
Result := VOID
|
||||
value := request.query_parameter (key)
|
||||
if attached value and then value.is_string then
|
||||
Result := value.as_string.value
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE}
|
||||
|
||||
control: WSF_CONTROL
|
||||
|
||||
end
|
||||
@@ -0,0 +1,77 @@
|
||||
note
|
||||
description: "Summary description for {WSF_STATELESS_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_STATELESS_CONTROL
|
||||
|
||||
feature {NONE}
|
||||
|
||||
make (a_tag_name: STRING)
|
||||
do
|
||||
tag_name := a_tag_name
|
||||
create css_classes.make (0)
|
||||
ensure
|
||||
attached css_classes
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
tag_name: STRING
|
||||
|
||||
css_classes: ARRAYED_LIST [STRING]
|
||||
|
||||
--TODO: Maybe improve
|
||||
|
||||
feature -- Change
|
||||
|
||||
add_class (c: STRING)
|
||||
do
|
||||
css_classes.force (c)
|
||||
end
|
||||
|
||||
render_tag (body, attrs: STRING): STRING
|
||||
local
|
||||
css_classes_string: STRING
|
||||
do
|
||||
create css_classes_string.make_empty
|
||||
across
|
||||
css_classes as c
|
||||
loop
|
||||
css_classes_string.append (" " + c.item)
|
||||
end
|
||||
Result := render_tag_with_tagname (tag_name, body, attrs, css_classes_string)
|
||||
end
|
||||
|
||||
render_tag_with_tagname (tag, body, attrs, css_classes_string: STRING): STRING
|
||||
local
|
||||
l_attributes: STRING
|
||||
do
|
||||
create l_attributes.make_from_string (attrs)
|
||||
if not css_classes_string.is_empty then
|
||||
l_attributes.append (" class=%"")
|
||||
l_attributes.append (css_classes_string)
|
||||
l_attributes.append_character ('%"')
|
||||
end
|
||||
Result := "<" + tag + " " + l_attributes
|
||||
if
|
||||
body.is_empty and
|
||||
not tag.same_string ("textarea") and
|
||||
not tag.same_string ("span") and
|
||||
not tag.same_string ("button") and
|
||||
not tag.same_string ("ul")
|
||||
then
|
||||
Result.append (" />")
|
||||
else
|
||||
Result.append (" >" + body + "</" + tag + ">")
|
||||
end
|
||||
end
|
||||
|
||||
render: STRING
|
||||
-- Return html representation of control
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
@@ -0,0 +1,50 @@
|
||||
note
|
||||
description: "Summary description for {WSF_STATELESS_MULTI_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_STATELESS_MULTI_CONTROL [G -> WSF_STATELESS_CONTROL]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_STATELESS_CONTROL
|
||||
|
||||
create
|
||||
make_multi_control, make_with_tag_name
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make_multi_control
|
||||
do
|
||||
make_with_tag_name ("div")
|
||||
end
|
||||
|
||||
make_with_tag_name (t: STRING)
|
||||
do
|
||||
make (t)
|
||||
controls := create {LINKED_LIST [G]}.make;
|
||||
end
|
||||
|
||||
feature
|
||||
|
||||
render: STRING
|
||||
do
|
||||
Result := ""
|
||||
across
|
||||
controls as c
|
||||
loop
|
||||
Result := c.item.render + Result
|
||||
end
|
||||
Result := render_tag (Result, "")
|
||||
end
|
||||
|
||||
add_control (c: G)
|
||||
do
|
||||
controls.put_front (c)
|
||||
end
|
||||
|
||||
controls: LINKED_LIST [G]
|
||||
|
||||
end
|
||||
20
library/server/wsf_js_widget/webcontrol/wsf_value_control.e
Normal file
20
library/server/wsf_js_widget/webcontrol/wsf_value_control.e
Normal file
@@ -0,0 +1,20 @@
|
||||
note
|
||||
description: "Summary description for {WSF_VALUE_CONTROL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_VALUE_CONTROL [G]
|
||||
|
||||
inherit
|
||||
|
||||
WSF_CONTROL
|
||||
|
||||
feature
|
||||
|
||||
value: G
|
||||
deferred
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user