Class: SWS::RadioButtonList
- Inherits:
-
ListElement
- Object
- Component
- FormElement
- ListElement
- SWS::RadioButtonList
- Defined in:
- lib/sws/Core/components/RadioButtonList/RadioButtonList.rb
Overview
Represents a list of radiobuttons with the same name. Bindings:
-
list (required) - array of object to be displayed in the form of
radiobuttons
-
item (required,settable) - an object to use as list iterator
-
selection (required,settable) - object selected from radiobutton list
-
display_string - string to display (if not set, the item itself will be
used)
-
prefix - HTML code to add before each radiobutton
-
suffix - HTML code to add after each radiobutton
-
disabled - if true, the radiobuttons will be inactive
-
other_tag_string - generic string to add to each <INPUT type=radiobutton
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
- #generate_html ⇒ Object
- #process_bindings ⇒ Object
-
#selection ⇒ Object
Returns value of “selection” slot.
-
#selection=(selection) ⇒ Object
Sets the value of “selection” slot.
Methods inherited from ListElement
#append_to_response, #item, #list
Methods inherited from FormElement
Methods inherited from Component
#api_filename, #app, #append_to_response, #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
#generate_html ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/sws/Core/components/RadioButtonList/RadioButtonList.rb', line 42 def generate_html () string = "" generic_string = generic_attr_string() list().each_index do |index| item = list[index] @slots["item"].value = item if ( slot_bound?( "display_string" ) ) display_string = @slots["display_string"].value() else display_string = item end if ( slot_bound?( "prefix" ) ) string << @slots["prefix"].value() end string << "<INPUT type=\"radio\" name=\"#{element_name()}.selection\" value=#{index}" if ( slot_bound?( "disabled" ) && @slots["disabled"].value() == true ) string << " disabled" end if ( selection == item ) string << " checked" end string << generic_string << ">\n" string << display_string if ( slot_bound?("suffix") ) string << @slots["suffix"].value() end end return string end |
#process_bindings ⇒ Object
37 38 39 |
# File 'lib/sws/Core/components/RadioButtonList/RadioButtonList.rb', line 37 def process_bindings () self.selection = @parameters["selection"] end |
#selection ⇒ Object
Returns value of “selection” slot
20 21 22 |
# File 'lib/sws/Core/components/RadioButtonList/RadioButtonList.rb', line 20 def selection () return @slots["selection"].value() end |
#selection=(selection) ⇒ Object
Sets the value of “selection” slot
26 27 28 29 30 31 32 33 34 |
# File 'lib/sws/Core/components/RadioButtonList/RadioButtonList.rb', line 26 def selection= ( selection ) if ( selection == nil ) @slots["selection"].value = nil else @slots["selection"].value = list[selection.to_i] end end |