Files
EWF/examples/widgetapp/sample_page.e
2013-09-15 00:44:20 +02:00

114 lines
3.7 KiB
Plaintext

note
description: "Summary description for {SAMPLE_PAGE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
SAMPLE_PAGE
inherit
WSF_PAGE_CONTROL
create
make
feature
initialize_controls
local
container: WSF_MULTI_CONTROL [WSF_STATELESS_CONTROL]
navbar: WSF_NAVBAR_CONTROL
form: WSF_FORM_CONTROL
n1_container: WSF_FORM_ELEMENT_CONTROL [STRING]
n2_container: WSF_FORM_ELEMENT_CONTROL [STRING]
n3_container: WSF_FORM_ELEMENT_CONTROL [STRING]
cats_container: WSF_FORM_ELEMENT_CONTROL [LIST [STRING]]
link1: WSF_BASIC_CONTROL
link2: WSF_BASIC_CONTROL
s: FLAG_AUTOCOMPLETION
do
create s.make (<<["dz", "Algeria"], ["be", "Belgium"], ["ca", "Canada"], ["de", "Deutschland"], ["england", "England"], ["fi", "Finland"], ["gr", "Greece"], ["hu", "Hungary"]>>)
create container.make_multi_control ("container")
create navbar.make_navbar ("Sample Page")
create textbox1.make_input ("txtBox1", "1")
create textbox2.make_input ("txtBox2", "2")
create autocompletion1.make_autocomplete ("autocompletion1", s)
create button1.make_button ("sample_button1", "SUM")
create textbox_result.make_html ("txtBox3", "p", "")
create link1.make_control ("a")
create link2.make_control ("a")
link1.set_content ("Home")
link1.set_attributes ("href=%"#%"")
link2.set_content ("About")
link2.set_attributes ("href=%"#%"")
navbar.add_element (link1)
navbar.add_element_right (link2)
button1.set_click_event (agent handle_click)
button1.add_class ("col-lg-offset-2")
create form.make_form_control ("panel")
form.add_class ("form-horizontal")
create cklist.make_checkbox_list_control ("categories")
cklist.add_control (create {WSF_CHECKBOX_CONTROL}.make_checkbox ("net", "Network", "net"))
cklist.add_control (create {WSF_CHECKBOX_CONTROL}.make_checkbox ("os", "Operating Systems", "os"))
create n1_container.make_form_element ("Number1", textbox1)
n1_container.add_validator (create {WSF_DECIMAL_VALIDATOR}.make_decimal_validator ("Invalid Number"))
n1_container.add_validator (create {OWN_VALIDATOR}.make_own)
create n2_container.make_form_element ("Number2", textbox2)
n2_container.add_validator (create {WSF_DECIMAL_VALIDATOR}.make_decimal_validator ("Invalid Number"))
create n3_container.make_form_element ("Autoc1", autocompletion1)
form.add_control (n1_container)
form.add_control (n2_container)
form.add_control (n3_container)
create cats_container.make_form_element ("Categories", cklist)
cats_container.add_validator (create {WSF_MIN_VALIDATOR [STRING]}.make_min_validator (1, "Choose at least one category"))
cats_container.add_validator (create {WSF_MAX_VALIDATOR [STRING]}.make_max_validator (1, "Choose at most one category"))
form.add_control (cats_container)
form.add_control (button1)
form.add_control (create {WSF_FORM_ELEMENT_CONTROL [STRING]}.make_form_element ("Result", textbox_result))
container.add_control (navbar)
container.add_control (form)
control := container
end
handle_click
local
text: STRING
do
if attached {WSF_FORM_CONTROL} control as form then
form.validate
if form.is_valid then
text := textbox1.text + " + " + textbox2.text + " = " + (textbox1.text.to_integer_64 + textbox2.text.to_integer_64).out
text.append ("<ul>")
across
cklist.value as s
loop
text.append ("<li>" + s.item + "</li>")
end
text.append ("</ul>")
textbox_result.set_html (text)
else
textbox_result.set_html ("VALIDATION ERROR")
end
end
end
process
do
end
button1: WSF_BUTTON_CONTROL
textbox1: WSF_INPUT_CONTROL
textbox2: WSF_INPUT_CONTROL
autocompletion1: WSF_AUTOCOMPLETE_CONTROL
cklist: WSF_CHECKBOX_LIST_CONTROL
textbox_result: WSF_HTML_CONTROL
end