Class: SWS::TextField
- Inherits:
-
FormElement
- Object
- Component
- FormElement
- SWS::TextField
- Defined in:
- lib/sws/Core/components/TextField/TextField.rb
Overview
Represents tag <INPUT type=text Bindings:
-
value (required,settable) - contents of the textfield
-
format - method of “value” object to be used before updating it (eg. for a
Float you can use to_i() method here to get Fixnum object)
-
other_tag_string - generic string to add to the 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
-
#update_binding(key, value) ⇒ Object
If the “format” slot value has been set, uses it to format “value” slot value.
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_bindings, #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, #url_string
Constructor Details
This class inherits a constructor from SWS::Component
Instance Method Details
#append_to_response(response) ⇒ Object
22 23 24 |
# File 'lib/sws/Core/components/TextField/TextField.rb', line 22 def append_to_response ( response ) response << generate_html() end |
#generate_html ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/sws/Core/components/TextField/TextField.rb', line 12 def generate_html () string = "<INPUT TYPE=\"text\" NAME=\"#{element_name()}.value\" VALUE=\"#{@slots["value"].value}\"" string << bound_slot_string( "size" ) string << "#{generic_attr_string()}>" return string end |
#update_binding(key, value) ⇒ Object
If the “format” slot value has been set, uses it to format “value” slot value
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/sws/Core/components/TextField/TextField.rb', line 29 def update_binding ( key,value ) if ( key == "value" ) if ( slot_bound?("format") ) @slots["value"].value = value.method( @slots["format"].value ).call() else @slots["value"].value = value end else #TODO: not sure if necessary - there are no more settable slots beside "value" super end end |