Class: SWS::FileUpload
- Inherits:
-
FormElement
- Object
- Component
- FormElement
- SWS::FileUpload
- Defined in:
- lib/sws/Core/components/FileUpload/FileUpload.rb
Overview
Represents a <INPUT type=fileā¦ field HTML tag. Bindings:
-
filename (settable) - name of the uploaded file
-
data (settable) - contents of the uploaded file
-
content_type (settable) - content type of the uploaded file
-
charset (settable) - charset of the uploaded file
-
disabled (default: false) - if true, the component 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
-
#container? ⇒ Boolean
This component cannot be a container, so this method returns false.
- #generate_html ⇒ Object
- #process_bindings ⇒ Object
Methods inherited from FormElement
Methods inherited from Component
#api_filename, #app, #awake, #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
44 45 46 |
# File 'lib/sws/Core/components/FileUpload/FileUpload.rb', line 44 def append_to_response ( response ) response << generate_html() end |
#container? ⇒ Boolean
This component cannot be a container, so this method returns false.
16 17 18 |
# File 'lib/sws/Core/components/FileUpload/FileUpload.rb', line 16 def container? () return false end |
#generate_html ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/sws/Core/components/FileUpload/FileUpload.rb', line 49 def generate_html () string = "<INPUT type=\"file\" name=\"#{element_name()}.file_data\"" if ( slot_bound?( "disabled" ) && @slots["disabled"].value() == true ) string << " disabled" end string << generic_attr_string() << ">" return string end |
#process_bindings ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/sws/Core/components/FileUpload/FileUpload.rb', line 21 def process_bindings () file_data = @parameters["file_data"] if ( file_data ) if ( file_data.is_a?( FileData ) ) if ( slot_bound?( "data" ) ) then @slots["data"].value = file_data.contents end # .sub is a workaround for stupid IE behaviour (sending FULL filename # path, so the application developer knows exactly where on your disk # you took the file from) if ( slot_bound?( "filename" ) ) then @slots["filename"].value = file_data.filename.sub( /^.*\\/,"" ) end if ( slot_bound?( "content_type" ) ) then @slots["content_type"].value = file_data.content_type end if ( slot_bound?( "charset" ) ) then @slots["charset"].value = file_data.charset end elsif ( file_data.is_a?( ::String ) ) @slots["filename"].value = file_data end end end |