Class: SWS::CheckBox
- Inherits:
-
FormElement
- Object
- Component
- FormElement
- SWS::CheckBox
- Defined in:
- lib/sws/Core/components/CheckBox/CheckBox.rb
Overview
Represents <INPUT type=checkbox tag. Bindings:
-
checked (settable, required) - if true, the checkbox will be checked. If
checked, the value bound will be set to true.
-
disabled - if true, the checkbox will be rendered inactive.
-
other_tag_string - generic string to add to the HTML tag
Instance Attribute Summary
Attributes inherited from Component
#action_components, #definition_component, #encoding, #html_attrs, #method_to_call, #name, #parameters, #parent, #request, #request_number, #slots, #subcomponents, #tokens
Instance Method Summary collapse
- #append_to_response(response) ⇒ Object
-
#generate_html ⇒ Object
Generates HTML code for the HTML checkbox form element.
- #process_bindings ⇒ Object
Methods inherited from FormElement
Methods inherited from Component
#api_filename, #app, #awake, #container?, #content?, create, #create_component_tree, #definition_filename, #initialize, #page, #perform_action, #process_parameters, #process_request, #remove_subcomponents, #session, #set_request_subcomponents, #sleep, #slot_bound?, #subcomponent_for_name, synchronize_slot, #synchronize_slot?, #synchronize_slots, #template_filename, #tokenize_binding, #update_binding, #url_string
Constructor Details
This class inherits a constructor from SWS::Component
Instance Method Details
#append_to_response(response) ⇒ Object
23 24 25 |
# File 'lib/sws/Core/components/CheckBox/CheckBox.rb', line 23 def append_to_response ( response ) response << generate_html() end |
#generate_html ⇒ Object
Generates HTML code for the HTML checkbox form element
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sws/Core/components/CheckBox/CheckBox.rb', line 29 def generate_html () string = "<INPUT type=\"checkbox\" name=\"#{element_name()}.checked\"" if ( @slots["checked"].value() ) string << " checked" end if ( slot_bound?( "disabled" ) && @slots["disabled"] ) string << " disabled" end string << generic_attr_string() << ">" return string end |
#process_bindings ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/sws/Core/components/CheckBox/CheckBox.rb', line 12 def process_bindings () if ( @parameters["checked"] == "on" ) @slots["checked"].value = true else @slots["checked"].value = false end end |