Class: SWS::RadioButton

Inherits:
FormElement show all
Defined in:
lib/sws/Core/components/RadioButton/RadioButton.rb

Overview

Represens <INPUT type=radio HTML tag. Bindings:

  • checked (required, settable) - if true, the radiobutton will be checked

  • disabled - if true, the radiobutton will be rendered inactive.

  • 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 FormElement

#container?, #element_name

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



22
23
24
# File 'lib/sws/Core/components/RadioButton/RadioButton.rb', line 22

def append_to_response ( response )
	response << generate_html()
end

#generate_htmlObject

Generates HTML output for radiobutton form element



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sws/Core/components/RadioButton/RadioButton.rb', line 28

def generate_html ()

	string = "<INPUT type=\"radio\" name=\"#{element_name()}.checked\""
	if ( @slots["checked"].value() == true  || @slots["checked"].value() == "true" ) 
		string << " checked"
	end
	if ( slot_bound?( "disabled" ) && @slots["disabled"] )
		string << " disabled"
	end
	string << generic_attr_string() << ">"
	return string

end

#process_bindingsObject



11
12
13
14
15
16
17
18
19
# File 'lib/sws/Core/components/RadioButton/RadioButton.rb', line 11

def process_bindings ()

	if ( @parameters["checked"] == "on" )
		@slots["checked"].value = true
	else
		@slots["checked"].value = false
	end

end