Merge pull request #2 from jocelyn/widget_first_review

Minor changes
This commit is contained in:
ynh
2013-09-20 03:34:36 -07:00
22 changed files with 201 additions and 161 deletions

View File

@@ -9,12 +9,22 @@ class
inherit
WSF_ROUTED_SERVICE
rename
execute as execute_router
end
WSF_FILTERED_SERVICE
WSF_DEFAULT_SERVICE
redefine
initialize
end
WSF_FILTER
rename
execute as execute_router
end
create
make_and_launch
@@ -24,10 +34,47 @@ feature {NONE} -- Initialization
-- Initialize current service.
do
initialize_router
initialize_filter
Precursor
set_service_option ("port", 9090)
end
feature {NONE} -- Initialization
feature -- Router and Filter
create_filter
-- Create `filter'
local
f, l_filter: detachable WSF_FILTER
do
l_filter := Void
-- Maintenance
create {WSF_MAINTENANCE_FILTER} f
f.set_next (l_filter)
l_filter := f
-- Logging
create {WSF_LOGGING_FILTER} f
f.set_next (l_filter)
l_filter := f
filter := l_filter
end
setup_filter
-- Setup `filter'
local
f: WSF_FILTER
do
from
f := filter
until
not attached f.next as l_next
loop
f := l_next
end
f.set_next (Current)
end
setup_router
do
@@ -35,6 +82,9 @@ feature {NONE} -- Initialization
map_agent_uri ("/", agent execute_hello, Void)
map_agent_uri ("/grid", agent grid_demo, Void)
map_agent_uri ("/repeater", agent repeater_demo, Void)
-- NOTE: you could put all those files in a specific folder, and use WSF_FILE_SYSTEM_HANDLER with "/"
-- this way, it handles the caching and so on
map_agent_uri ("/widget.js", agent load_file("widget.js", ?, ?), Void)
map_agent_uri ("/jquery.min.js", agent load_file("jquery.min.js", ?, ?), Void)
map_agent_uri ("/typeahead.min.js", agent load_file("typeahead.min.js", ?, ?), Void)

View File

@@ -16,7 +16,7 @@ create
feature {NONE} -- Initialization
make ()
make
do
template := "{{=value}}";
end
@@ -25,26 +25,24 @@ feature -- Implementation
autocompletion (input: STRING): JSON_ARRAY
local
cl: LIBCURL_HTTP_CLIENT
sess: HTTP_CLIENT_SESSION
l_json: detachable READABLE_STRING_8
o: JSON_OBJECT
l_result: INTEGER
l_curl_string: CURL_STRING
json_parser: JSON_PARSER
query_str: STRING
do
query_str := input
query_str.replace_substring_all (" ", "+")
curl_handle := curl_easy.init
create cl.make
sess := cl.new_session ("http://google.com")
if attached sess.get ("/complete/search?client=chrome&q=" + query_str, Void) as resp and then not resp.error_occurred then
l_json := resp.body
end
create Result.make_array
if curl_handle /= default_pointer then
create l_curl_string.make_empty
curl_easy.setopt_string (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_url, "http://google.com/complete/search?client=chrome&q=" + query_str)
curl_easy.set_write_function (curl_handle)
curl_easy.setopt_integer (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_writedata, l_curl_string.object_id)
l_result := curl_easy.perform (curl_handle)
-- Always cleanup
curl_easy.cleanup (curl_handle)
create json_parser.make_parser (l_curl_string.out)
if l_json /= Void and then not l_json.is_empty then
create json_parser.make_parser (l_json)
if attached {JSON_ARRAY} json_parser.parse_json as data and then attached {JSON_ARRAY} data.i_th (2) as list then
across
1 |..| list.count as c
@@ -59,14 +57,4 @@ feature -- Implementation
end
end
feature {NONE} -- Implementation
curl_easy: CURL_EASY_EXTERNALS
once
create Result
end
curl_handle: POINTER;
-- cURL handle
end

View File

@@ -18,18 +18,21 @@ feature {NONE}
make_from_json (json: JSON_OBJECT)
do
if attached {JSON_STRING} json.item (create {JSON_STRING}.make_json ("title")) as a_title then
title := a_title.unescaped_string_32
if attached {JSON_STRING} json.item ("title") as l_title then
title := l_title.unescaped_string_32
end
if attached {JSON_STRING} json.item (create {JSON_STRING}.make_json ("content")) as a_content then
content := a_content.unescaped_string_32
if attached {JSON_STRING} json.item ("content") as l_content then
content := l_content.unescaped_string_32
end
if attached {JSON_OBJECT} json.item (create {JSON_STRING}.make_json ("image")) as img and then attached {JSON_STRING} img.item (create {JSON_STRING}.make_json ("url")) as a_image then
image := a_image.item
if
attached {JSON_OBJECT} json.item ("image") as img and then
attached {JSON_STRING} img.item ("url") as l_image
then
image := l_image.item
end
end
feature
feature -- Access
title: detachable STRING
@@ -37,13 +40,14 @@ feature
image: detachable STRING
get (field: STRING): detachable ANY
item (a_field: READABLE_STRING_GENERAL): detachable ANY
-- <Precursor>
do
if field.is_equal ("title") then
if a_field.same_string ("title") then
Result := title
elseif field.is_equal ("content") then
elseif a_field.same_string ("content") then
Result := content
elseif field.is_equal ("image") then
elseif a_field.same_string ("image") then
Result := image
end
end

View File

@@ -47,26 +47,28 @@ feature
data: ITERABLE [GOOGLE_NEWS]
local
list: LINKED_LIST [GOOGLE_NEWS]
l_result: INTEGER
l_curl_string: CURL_STRING
l_json: detachable READABLE_STRING_8
json_parser: JSON_PARSER
query_str: STRING
cl: LIBCURL_HTTP_CLIENT
sess: HTTP_CLIENT_SESSION
do
curl_handle := curl_easy.init
create list.make
row_count := 0
if curl_handle /= default_pointer then
create l_curl_string.make_empty
query_str := query.out
query_str.replace_substring_all (" ", "+")
curl_easy.setopt_string (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_url, "https://ajax.googleapis.com/ajax/services/search/news?v=1.0&q=" + query_str + "&rsz=" + page_size.out + "&start=" + (page_size * (page - 1)).out)
curl_easy.set_write_function (curl_handle)
curl_easy.setopt_integer (curl_handle, {CURL_OPT_CONSTANTS}.curlopt_writedata, l_curl_string.object_id)
l_result := curl_easy.perform (curl_handle)
-- Always cleanup
curl_easy.cleanup (curl_handle)
create json_parser.make_parser (l_curl_string.out)
create cl.make
sess := cl.new_session ("https://ajax.googleapis.com/ajax/services/search")
sess.set_is_insecure (True)
if sess.is_available then
if attached {HTTP_CLIENT_RESPONSE} sess.get ("/news?v=1.0&q=" + query_str + "&rsz=" + page_size.out + "&start=" + (page_size * (page - 1)).out, Void) as l_response then
if not l_response.error_occurred then
l_json := l_response.body
end
end
end
if l_json /= Void and then not l_json.is_empty then
create json_parser.make_parser (l_json)
if attached {JSON_OBJECT} json_parser.parse_json as sp then
if attached {JSON_OBJECT} sp.item (create {JSON_STRING}.make_json ("responseData")) as responsedata and then attached {JSON_ARRAY} responsedata.item (create {JSON_STRING}.make_json ("results")) as results then
if attached {JSON_OBJECT} responsedata.item (create {JSON_STRING}.make_json ("cursor")) as cursor and then attached {JSON_STRING} cursor.item (create {JSON_STRING}.make_json ("estimatedResultCount")) as count then
@@ -94,14 +96,4 @@ feature
query: STRING
feature {NONE} -- Implementation
curl_easy: CURL_EASY_EXTERNALS
once
create Result
end
curl_handle: POINTER;
-- cURL handle
end

View File

@@ -29,7 +29,8 @@ feature
search_query.set_change_event (agent change_query)
container.add_control (search_query)
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h2","","Results"))
create grid.make_grid ("mygrid", <<create {WSF_GRID_COLUMN}.make_column ("Title", "title"), create {WSF_GRID_COLUMN}.make_column ("Content", "content")>>, datasource)
create grid.make_grid ("mygrid", <<create {WSF_GRID_COLUMN}.make ("Title", "title"),
create {WSF_GRID_COLUMN}.make ("Content", "content")>>, datasource)
container.add_control (grid)
control := container
end

View File

@@ -8,7 +8,6 @@ class
REPEATER_PAGE
inherit
BASE_PAGE
redefine
initialize_controls
@@ -22,13 +21,13 @@ feature
initialize_controls
do
Precursor
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h1","","Repeater Demo"))
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body ("h1", ""," Repeater Demo"))
create datasource.make_news
create search_query.make_autocomplete ("query", create {GOOGLE_AUTOCOMPLETION}.make)
search_query.add_class ("form-control")
search_query.set_change_event (agent change_query)
container.add_control (search_query)
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h2","","Results"))
container.add_control (create {WSF_BASIC_CONTROL}.make_with_body("h2", "", "Results"))
create repeater.make_repeater ("myrepeater", datasource)
container.add_control (repeater)
end

View File

@@ -1,33 +1,32 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-10-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-10-0 http://www.eiffel.com/developers/xml/configuration-1-10-0.xsd" name="widgetapp" uuid="C28C4F53-9963-46C0-A080-8F13E94E7486" library_target="widgetapp">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-11-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-11-0 http://www.eiffel.com/developers/xml/configuration-1-11-0.xsd" name="widgetapp" uuid="C28C4F53-9963-46C0-A080-8F13E94E7486" library_target="widgetapp">
<target name="common" abstract="true">
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
<option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="curl" location="$ISE_LIBRARY\library\cURL\cURL-safe.ecf"/>
<library name="http" location="..\..\library\network\protocol\http\http-safe.ecf"/>
<library name="http_client" location="$ISE_LIBRARY\contrib\library\network\http_client\http_client-safe.ecf"/>
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf"/>
<library name="wsf_html" location="..\..\library\server\wsf_html\wsf_html-safe.ecf"/>
<library name="wsf_html" location="..\..\library\server\wsf_html\wsf_html-safe.ecf" readonly="false"/>
</target>
<target name="widgetapp_nino" extends="common">
<root class="APPLICATION" feature="make_and_launch"/>
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
<option warning="true" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf"/>
<library name="json" location="..\..\contrib\library\text\parser\json\library\json-safe.ecf"/>
<cluster name="widgetapp" location=".\" recursive="true">
</cluster>
<cluster name="widgetapp" location=".\" recursive="true"/>
</target>
<target name="widgetapp_cgi" extends="common">
<root class="APPLICATION" feature="make_and_launch"/>
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
<option warning="true" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<library name="default_cgi" location="..\..\library\server\wsf\default\cgi-safe.ecf"/>
@@ -35,7 +34,7 @@
</target>
<target name="widgetapp_libfcgi" extends="common">
<root class="APPLICATION" feature="make_and_launch"/>
<option warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
<option warning="true" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<library name="default_libfcgi" location="..\..\library\server\wsf\default\libfcgi-safe.ecf"/>

View File

@@ -9,7 +9,7 @@ deferred class
feature -- Update event
set_on_update_agent (f: PROCEDURE [ANY, TUPLE []])
set_on_update_agent (f: PROCEDURE [ANY, TUPLE])
do
on_update_agent := f
end
@@ -17,11 +17,11 @@ feature -- Update event
update
do
if attached on_update_agent as a then
a.call ([])
a.call (Void)
end
end
on_update_agent: detachable PROCEDURE [ANY, TUPLE []]
on_update_agent: detachable PROCEDURE [ANY, TUPLE]
feature --State
@@ -30,27 +30,27 @@ feature --State
do
create Result.make
if attached sort_column as a_sort_column then
Result.put (create {JSON_STRING}.make_json (a_sort_column), create {JSON_STRING}.make_json ("sort_column"))
Result.put (create {JSON_STRING}.make_json (a_sort_column), "sort_column")
else
Result.put (create {JSON_NULL}, create {JSON_STRING}.make_json ("sort_column"))
Result.put (create {JSON_NULL}, "sort_column")
end
Result.put (create {JSON_BOOLEAN}.make_boolean (sort_direction), create {JSON_STRING}.make_json ("sort_direction"))
Result.put (create {JSON_BOOLEAN}.make_boolean (sort_direction), "sort_direction")
end
set_state (new_state: JSON_OBJECT)
do
if attached {JSON_NUMBER} new_state.item (create {JSON_STRING}.make_json ("page")) as new_page then
if attached {JSON_NUMBER} new_state.item ("page") as new_page then
page := new_page.integer_type
end
if attached {JSON_NUMBER} new_state.item (create {JSON_STRING}.make_json ("page_size")) as new_page_size then
if attached {JSON_NUMBER} new_state.item ("page_size") as new_page_size then
page_size := new_page_size.integer_type
end
if attached {JSON_STRING} new_state.item (create {JSON_STRING}.make_json ("sort_column")) as new_sort_column then
sort_column := new_sort_column.unescaped_string_32
elseif attached {JSON_NULL} new_state.item (create {JSON_STRING}.make_json ("sort_column")) as new_sort_column then
sort_column := VOID
if attached {JSON_STRING} new_state.item ("sort_column") as new_sort_column then
sort_column := new_sort_column.unescaped_string_32 -- Implicit Conversion !
elseif attached {JSON_NULL} new_state.item ("sort_column") as new_sort_column then
sort_column := Void
end
if attached {JSON_BOOLEAN} new_state.item (create {JSON_STRING}.make_json ("sort_direction")) as new_sort_direction then
if attached {JSON_BOOLEAN} new_state.item ("sort_direction") as new_sort_direction then
sort_direction := new_sort_direction.item
end
end

View File

@@ -1,15 +1,15 @@
note
description: "Summary description for {WSF_ENTITY}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_ENTITY
feature
feature -- Access
get (field: STRING): detachable ANY
item (a_field: READABLE_STRING_GENERAL): detachable ANY
-- Value for field item `a_field'.
deferred
end

View File

@@ -8,11 +8,11 @@ class
WSF_GRID_COLUMN
create
make_column
make
feature {NONE}
make_column (a_header, a_field: STRING)
make (a_header, a_field: STRING)
do
header := a_header
field_name := a_field
@@ -31,7 +31,7 @@ feature
render_column (e: WSF_ENTITY): STRING
do
if attached e.get (field_name) as data then
if attached e.item (field_name) as data then
Result := data.out
else
Result := "[VOID]"

View File

@@ -10,16 +10,18 @@ class
inherit
WSF_GRID_COLUMN
rename
make as make_column
redefine
render_column
end
create
make_image_column
make
feature {NONE}
make_image_column (a_header, a_field: STRING)
make (a_header, a_field: STRING)
do
make_column (a_header, a_field)
end
@@ -28,7 +30,7 @@ feature
render_column (e: WSF_ENTITY): STRING
do
if attached e.get (field_name) as data then
if attached e.item (field_name) as data then
Result := "<img src=%"" + data.out + "%" />"
else
Result := "[VOID]"

View File

@@ -58,7 +58,7 @@ feature
update
do
state_changes.replace (create {JSON_STRING}.make_json (render), create {JSON_STRING}.make_json ("_html"))
state_changes.replace (create {JSON_STRING}.make_json (render), "_html")
end
render: STRING

View File

@@ -34,14 +34,14 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
update
do
state_changes.replace (create {JSON_STRING}.make_json (render_body), create {JSON_STRING}.make_json ("_body"))
state_changes.replace (datasource.state, create {JSON_STRING}.make_json ("datasource"))
state_changes.replace (create {JSON_STRING}.make_json (render_body), "_body")
state_changes.replace (datasource.state, "datasource")
end
set_state (new_state: JSON_OBJECT)
-- Restore html from json
do
if attached {JSON_OBJECT} new_state.item (create {JSON_STRING}.make_json ("datasource")) as datasource_state then
if attached {JSON_OBJECT} new_state.item ("datasource") as datasource_state then
datasource.set_state (datasource_state)
end
end
@@ -50,7 +50,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
-- Return state which contains the current html and if there is an event handle attached
do
create Result.make
Result.put (datasource.state, create {JSON_STRING}.make_json ("datasource"))
Result.put (datasource.state, "datasource")
end
feature --EVENT HANDLING

View File

@@ -28,7 +28,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
set_state (new_state: JSON_OBJECT)
-- Restore text from json
do
if attached {JSON_BOOLEAN} new_state.item (create {JSON_STRING}.make_json ("checked")) as new_checked then
if attached {JSON_BOOLEAN} new_state.item ("checked") as new_checked then
checked := new_checked.item
end
end
@@ -37,9 +37,9 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
-- Return state which contains the current text and if there is an event handle attached
do
create Result.make
Result.put (create {JSON_BOOLEAN}.make_boolean (checked), create {JSON_STRING}.make_json ("checked"))
Result.put (create {JSON_STRING}.make_json (checked_value), create {JSON_STRING}.make_json ("checked_value"))
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), create {JSON_STRING}.make_json ("callback_change"))
Result.put (create {JSON_BOOLEAN}.make_boolean (checked), "checked")
Result.put (create {JSON_STRING}.make_json (checked_value), "checked_value")
Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), "callback_change")
end
feature --EVENT HANDLING
@@ -52,9 +52,9 @@ feature --EVENT HANDLING
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
do
if Current.control_name.is_equal (cname) and attached change_event as cevent then
if event.is_equal ("change") then
cevent.call ([])
if Current.control_name.same_string (cname) and attached change_event as cevent then
if event.same_string ("change") then
cevent.call (Void)
end
end
end
@@ -85,6 +85,6 @@ feature
checked_value: STRING
change_event: detachable PROCEDURE [ANY, TUPLE []]
change_event: detachable PROCEDURE [ANY, TUPLE]
end

View File

@@ -32,7 +32,7 @@ feature
value: LIST [STRING]
do
create {LINKED_LIST [STRING]} Result.make
create {ARRAYED_LIST [STRING]} Result.make (0)
across
controls as c
loop

View File

@@ -70,7 +70,7 @@ feature {NONE} -- Initialization
collapse_button.add_control (icon_bar)
collapse_button.add_control (icon_bar)
collapse_button.add_control (icon_bar)
--collapse_button.set_attributes ("data-target=%".navbar-collapse%" data-toggle=%"collapse%" type=%"button%"")
-- collapse_button.set_attributes ("data-target=%".navbar-collapse%" data-toggle=%"collapse%" type=%"button%"")
brand.add_class ("navbar-brand")
brand.set_attributes ("href=%"#%"")
brand.set_content (b)

View File

@@ -17,15 +17,9 @@ create
feature {NONE} -- Initialization
attributes: STRING
content: STRING
make_control (t: STRING)
do
make (t)
attributes := ""
content := ""
make_with_body (t, "", "")
end
make_with_body (t,attr,a_content: STRING)
@@ -35,6 +29,12 @@ feature {NONE} -- Initialization
content := a_content
end
feature -- Access
attributes: STRING
content: STRING
feature -- Rendering
render: STRING

View File

@@ -34,7 +34,7 @@ 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 (create {JSON_STRING}.make_json (control_name)) as new_state_obj then
if attached {JSON_OBJECT} new_states.item (control_name) as new_state_obj then
set_state (new_state_obj)
end
end
@@ -47,14 +47,14 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
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, create {JSON_STRING}.make_json (control_name))
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, create {JSON_STRING}.make_json (control_name))
states.put (state_changes, control_name)
end
end
@@ -69,7 +69,7 @@ feature -- Rendering
render_tag (body, attrs: STRING): STRING
do
Result:=render_tag_with_generator_name (generator, body, attrs)
Result := render_tag_with_generator_name (generator, body, attrs)
end
render_tag_with_generator_name (a_generator, body, attrs: STRING): STRING
@@ -87,7 +87,7 @@ feature -- Rendering
Result := render_tag_with_tagname (tag_name, body, l_attributes, css_classes_string)
end
feature --EVENT HANDLING
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

View File

@@ -24,14 +24,11 @@ create
feature {NONE}
make_form_element (a_label: STRING; c: WSF_VALUE_CONTROL [G])
local
a_validators: LINKED_LIST [WSF_VALIDATOR [G]]
do
create a_validators.make
make_form_element_with_validators (a_label, c, a_validators)
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: LINKED_LIST [WSF_VALIDATOR [G]])
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")
@@ -87,8 +84,8 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
loop
validator_description.add (v.item.state)
end
Result.put (create {JSON_STRING}.make_json (value_control.control_name), create {JSON_STRING}.make_json ("value_control"))
Result.put (validator_description, create {JSON_STRING}.make_json ("validators"))
Result.put (create {JSON_STRING}.make_json (value_control.control_name), "value_control")
Result.put (validator_description, "validators")
end
feature --EVENT HANDLING
@@ -96,8 +93,8 @@ feature --EVENT HANDLING
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
-- Pass callback to subcontrols
do
if equal (cname, control_name) then
if event.is_equal ("validate") then
if cname.same_string (control_name) then
if event.same_string ("validate") then
validate
end
else
@@ -113,11 +110,11 @@ feature --Implementation
do
body := ""
if not label.is_empty then
body := "<label class=%"col-lg-2 control-label%" for=%"" + value_control.control_name + "%">" + label + "</label>"
body.append ("<label class=%"col-lg-2 control-label%" for=%"" + value_control.control_name + "%">" + label + "</label>")
end
body := body + "<div class=%"col-lg-10%">"
body := body + value_control.render
body := body + "</div>"
body.append ("<div class=%"col-lg-10%">")
body.append (value_control.render)
body.append ("</div>")
Result := render_tag (body, "")
end
@@ -161,7 +158,7 @@ feature
value_control: WSF_VALUE_CONTROL [G]
validators: LINKED_LIST [WSF_VALIDATOR [G]]
validators: LIST [WSF_VALIDATOR [G]]
label: STRING

View File

@@ -52,7 +52,6 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
do
end
read_state (states: JSON_OBJECT)
-- Read states in subcontrols
do
@@ -85,7 +84,7 @@ feature {WSF_PAGE_CONTROL, WSF_CONTROL} -- STATE MANAGEMENT
create Result.make
end
feature --EVENT HANDLING
feature -- EVENT HANDLING
handle_callback (cname: STRING; event: STRING; event_parameter: detachable STRING)
-- Pass callback to subcontrols

View File

@@ -7,40 +7,40 @@ note
deferred class
WSF_STATELESS_CONTROL
feature
tag_name: STRING
css_classes: LINKED_LIST [STRING]
--TODO: Maybe improve
feature {NONE}
make (a_tag_name: STRING)
do
tag_name := a_tag_name
create css_classes.make
create css_classes.make (0)
ensure
attached css_classes
end
feature
feature -- Access
tag_name: STRING
css_classes: ARRAYED_LIST [STRING]
--TODO: Maybe improve
feature -- Change
add_class (c: STRING)
do
css_classes.extend (c)
css_classes.force (c)
end
render_tag (body, attrs: STRING): STRING
local
css_classes_string: STRING
do
css_classes_string := ""
create css_classes_string.make_empty
across
css_classes as c
loop
css_classes_string := css_classes_string + " " + c.item
css_classes_string.append (" " + c.item)
end
Result := render_tag_with_tagname (tag_name, body, attrs, css_classes_string)
end
@@ -49,20 +49,28 @@ feature
local
l_attributes: STRING
do
l_attributes := attrs
create l_attributes.make_from_string (attrs)
if not css_classes_string.is_empty then
l_attributes := l_attributes + " class=%"" + css_classes_string + "%""
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.is_equal ("textarea") and not tag.is_equal ("span") and not tag.is_equal ("button") and not tag.is_equal ("ul") then
Result := Result + " />"
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 := Result + " >" + body + "</" + tag + ">"
Result.append (" >" + body + "</" + tag + ">")
end
end
render: STRING
-- Return html representaion of control
-- Return html representation of control
deferred
end

View File

@@ -56,6 +56,7 @@
<library name="wsf_openshift" location="..\library\server\wsf\connector\openshift-safe.ecf" readonly="false"/>
<library name="wsf_router_context" location="..\library\server\wsf\wsf_router_context-safe.ecf" readonly="false"/>
<library name="wsf_session" location="..\library\server\wsf\wsf_session-safe.ecf" readonly="false"/>
<library name="widgetapp" location="..\examples\widgetapp\widgetapp.ecf" readonly="false"/>
</target>
<target name="all_windows" extends="all">
<description>Compiling as Windows , on other platforms than Windows</description>