diff --git a/library/server/wsf_html/webcontrol/wsf_button_control.e b/library/server/wsf_html/webcontrol/wsf_button_control.e index a1f4958a..2e9a901d 100644 --- a/library/server/wsf_html/webcontrol/wsf_button_control.e +++ b/library/server/wsf_html/webcontrol/wsf_button_control.e @@ -59,7 +59,7 @@ feature render: STRING do - Result := render_tag ( text, "") + Result := render_tag (text, "") end set_text (t: STRING) diff --git a/library/server/wsf_html/webcontrol/wsf_checkbox_control.e b/library/server/wsf_html/webcontrol/wsf_checkbox_control.e new file mode 100644 index 00000000..91c67778 --- /dev/null +++ b/library/server/wsf_html/webcontrol/wsf_checkbox_control.e @@ -0,0 +1,83 @@ +note + description: "Summary description for {WSF_CHECKBOX_CONTROL}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_CHECKBOX_CONTROL +inherit + WSF_VALUE_CONTROL[BOOLEAN] +create + make_checkbox + +feature {NONE} + + make_checkbox (n: STRING; l: STRING) + do + make (n, "input") + label := l + end + +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 + checked := new_checked.item + 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_BOOLEAN}.make_boolean (checked), create {JSON_STRING}.make_json ("checked")) + Result.put (create {JSON_BOOLEAN}.make_boolean (attached change_event), create {JSON_STRING}.make_json ("callback_change")) + end + +feature --EVENT HANDLING + + set_change_event (e: attached like change_event) + -- Set text change event handle + do + change_event := e + end + + handle_callback (cname: STRING; event: STRING) + do + if Current.control_name.is_equal (cname) and attached change_event as cevent then + if event.is_equal ("change") then + cevent.call ([]) + end + end + end + +feature -- Implementation + + render: STRING + local + attributes: STRING + do + attributes := "type=%"checkbox%"" + if checked then + attributes := attributes + " checked" + end + Result := render_tag ("", attributes) + end + + value: BOOLEAN + do + Result := checked + end + +feature + + label: STRING + + checked: BOOLEAN + + change_event: detachable PROCEDURE [ANY, TUPLE []] + +end diff --git a/library/server/wsf_html/webcontrol/wsf_control.e b/library/server/wsf_html/webcontrol/wsf_control.e index d6fd106f..daa55405 100644 --- a/library/server/wsf_html/webcontrol/wsf_control.e +++ b/library/server/wsf_html/webcontrol/wsf_control.e @@ -91,7 +91,8 @@ feature if not css_classes_string.is_empty then css_classes_string := " class=%"" + css_classes_string + "%"" end - Result := "<" + tag_name + " data-name=%"" + control_name + "%" data-type=%"" + generator + "%" " + attributes + css_classes_string + + Result := "<" + tag_name + " id=%"" + control_name + "%" data-name=%"" + control_name + "%" data-type=%"" + generator + "%" " + attributes + css_classes_string if body.is_empty and not tag_name.is_equal("textarea") then Result := Result + " />" else diff --git a/library/server/wsf_html/webcontrol/wsf_form_element_control.e b/library/server/wsf_html/webcontrol/wsf_form_element_control.e index edf35709..d350aaa0 100644 --- a/library/server/wsf_html/webcontrol/wsf_form_element_control.e +++ b/library/server/wsf_html/webcontrol/wsf_form_element_control.e @@ -10,6 +10,9 @@ class inherit WSF_CONTROL + redefine + read_state_changes + end create make_form_element, make_form_element_with_validators diff --git a/library/server/wsf_html/webcontrol/wsf_text_control.e b/library/server/wsf_html/webcontrol/wsf_text_control.e index 63dc34a3..3a03340f 100644 --- a/library/server/wsf_html/webcontrol/wsf_text_control.e +++ b/library/server/wsf_html/webcontrol/wsf_text_control.e @@ -9,8 +9,6 @@ class inherit - WSF_CONTROL - WSF_VALUE_CONTROL [STRING] create @@ -63,7 +61,7 @@ feature -- Implementation render: STRING do - Result := render_tag ("", "value=%"" + text + "%"") + Result := render_tag ("", "type=%"text%" value=%"" + text + "%"") end set_text (t: STRING) diff --git a/library/server/wsf_html/webcontrol/wsf_textarea_control.e b/library/server/wsf_html/webcontrol/wsf_textarea_control.e index 1ee25a96..c447e73b 100644 --- a/library/server/wsf_html/webcontrol/wsf_textarea_control.e +++ b/library/server/wsf_html/webcontrol/wsf_textarea_control.e @@ -22,13 +22,14 @@ feature {NONE} make_textarea (n, t: STRING) do make_text (n, t) - tag_name := "textarea" + tag_name := "textarea" end + feature render: STRING do - Result :=render_tag(text,"") + Result := render_tag (text, "") end end