Class HtmlContainer
This widget represents a collection of HTML object tags and
defines a set of methods to manipulate the collection
and to render the collection, making this class suitable for
use as a base class for more complex widgets which are composed
of several HTML objects. (ie. It defines a tipical Composition pattern
method interface).
add widget ...
Adds one or more widgets into the container.
|
clear
Empties the container.
|
constructor [widget ...]
Initializes and adds one or more widgets into the container.
|
get attribName
Fetches the value of an attribute.
|
getWidgets
Fetches a list with the widgets it contains.
|
init attribList
Initializes the values of a set of attributes.
|
render
Renders the container and its contents by generating the apropriate
HTML text.
|
render-epilogue
Renders a suffix to the collection of objects.
|
render-prologue
Renders a prefix to the collection of objects.
|
set attribName attribValue
Changes the values of one of the widget attributes.
|
|
add
HtmlContainer add widget ...
Adds one or more widgets into the container.
- Parameters:
- widget -
An object of any type, supposedly a widget, that must respond
to a render method. It can also be a string.
- Returns:
-
A reference to the object for which the method was called.
-
Inserts the widgets received as arguments to the end of the list
of widgets managed by this container.
If one of the arguments is a string
an HtmlPlainString is automatically created and
initialized with that
string. The HtmlPlainString is then added to the
container.
clear
HtmlContainer clear
Empties the container.
- Returns:
-
A reference to the object for which the method was called.
-
Removes all the widgets it had received through the add
method. The container is thus emptied.
constructor
HtmlContainer constructor [widget ...]
Initializes and adds one or more widgets into the container.
- Parameters:
- widget -
An object of any type, supposedly a widget, that must respond
to a render method.
-
Initializes the container such that it now contains the widgets
received as arguments.
get
HtmlContainer get attribName
Fetches the value of an attribute.
- Parameters:
- attribName -
Symbol identifying the attribute whose value is being fetched.
- Returns:
-
The value of the
attribName attribute.
-
The
attribName argument must be the same as one of the
symbols passed to the init method.
getWidgets
HtmlContainer getWidgets
Fetches a list with the widgets it contains.
- Returns:
-
A list with the widgets it contains.
-
The list that gets returned contains all the widgets received
with the add method, in the same order by which
they got added.
init
HtmlContainer init attribList
Initializes the values of a set of attributes.
- Parameters:
- attribList -
A list with the attributes and its values.
- Returns:
-
A reference to the object for which the method was called.
-
Specifies and initializes the attributes of the widget. These
will be the attributes known to the set and
get methods.
The attribList argument contains the attributes
names and values. It is a list where each
element specifies an attribute. Each element
is a two element list: a symbol identifying the attribute and
its new value.
render
HtmlContainer render
Renders the container and its contents by generating the apropriate
HTML text.
- Returns:
-
A reference to the object for which the method was called.
-
Generates the HTML representation of the HtmlContainer
and its contents by eventually calling the render
method for each
of the widgets it contains. The exact procedure is as follows.
The HtmlContainer starts by invoking the
render-prologue method
on itself. Then calls render for every widget
received with its add method. The calls are
performed in the same order the widgets were received. Finally
invokes render-epilogue on itself.
The render-prologue and render-epilogue
methods are supposed to be redefined in classes derived from
HtmlContainer.
render-epilogue
HtmlContainer render-epilogue
Renders a suffix to the collection of objects.
-
The implementation of this method at HtmlContainer
does nothing. The purpose of this method is to allow derived classes
to override/extend its definition. (Example: An HtmlForm derived class
with define this method to render a
</form>
HTML tag after rendering all HTML objects contained in the form.)
render-prologue
HtmlContainer render-prologue
Renders a prefix to the collection of objects.
-
The implementation of this method at HtmlContainer
does nothing. The purpose of this method is to allow derived classes
to override/extend its definition. (Example: An HtmlForm derived class
will define this method to render a
<form>
HTML tag, before rendering other HTML objects contained within the form.)
set
HtmlContainer set attribName attribValue
Changes the values of one of the widget attributes.
- Parameters:
- attribName -
Symbol identifying the attribute whose value will be modified.
- attribValue -
The new value of the attribute.
- Returns:
-
A reference to the object for which the method was called.
-
The
attribName argument must be the same as one of the
symbols passed to the init method, otherwise a
runtime error will occur. Although attribValue can
be of any type each attribute expects values of a certain type.
Report a bug or request new features
© 2013