Class: SWS::Select
- Inherits:
-
MultipleSelectionList
- Object
- Component
- FormElement
- ListElement
- MultipleSelectionList
- SWS::Select
- Defined in:
- lib/sws/Core/components/Select/Select.rb
Overview
-
size (default: 5) - size attribute of the tag
-
multiple (required) - if true, multiple object can be selected
-
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
Methods inherited from MultipleSelectionList
#process_bindings, #selections, #selections=
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_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, #update_binding, #url_string
Constructor Details
This class inherits a constructor from SWS::Component
Instance Method Details
#generate_html ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/sws/Core/components/Select/Select.rb', line 20 def generate_html () string = "<SELECT name=\"#{element_name()}.selections\" " string << @slots["size"].to_tag_attribute() if ( @slots["multiple"].value() == true ) string << " multiple" end if ( slot_bound?( "disabled" ) && @slots["disabled"].value() == true ) string << " disabled" end string << generic_attr_string() << ">" if ( slot_bound?( "empty_string" ) ) string << "<OPTION value=__empty_string>" string << @slots["empty_string"].value() string << "</OPTION>" end 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 string << "<OPTION value=#{index}" if ( (selections().is_a?(Array) && selections().include?(item)) || (selections() == item) ) string << " selected" end string << ">#{display_string}</OPTION>" end string << "</SELECT>" return string end |