IWL::Object - Base object module for IWL
IWL::Error -> IWL::Object
This is the base object module for IWL. Every other module will inherit from it.
IWL::Object->new (environment => IWL::Environment)
If an IWL::Environment object is given as the value of the environment argument, and the object is a root object, that environment will be used to manage the shared resources of the object and its children.
IWL::Object->newMultiple (ARGS, ARGS, ...)
Returns an array of multiple objects.
Parameters: ARGS - if only one argument is passed, and it is a number, it is used to create that many number of objects. If the first argument is a number, and is followed by other arguments, the first argument will create the number of objects, with the rest of the arguments passed to the constructor. Otherwise, if the arguments are a list of hash references, they will be used to create the objects.
An array of child objects for the current object. Null if there are no children.
The parent for the current object. Null if it has no parent.
Returns the first child of the object
Returns the last child of the object
Obtains the next child of the object. Parameter: CURRENT_CHILD - its sibling Returns the child object, or null if there is no next child.
Obtains the previous child of the object. Parameter: CURRENT_CHILD - its sibling Returns the child object, or null if there is no previous child.
Returns a reference to the array of child objects
Returns the next sibling of the current object.
Returns the previous sibling of the current object.
Returns all siblings, which are after the current object.
Returns all siblings, which are before the current object.
Returns the parent object of the current object
Returns all ancestors of the current object
Returns all the descendants of the current object
Appends OBJECT as a child to the current object.
Parameter: OBJECT - the object to be appended (can be an array of objects)
Appends OBJECT as the first child to the current object, and moves the rest afterward.
Parameter: OBJECT - the object to be prepended (can be an array of objects)
Sets OBJECT as the only child to the current object, replacing any existing children.
Parameter: OBJECT - the object to be set (can be an array of objects)
Inserts OBJECT before REFERENCE.
Parameter: OBJECT - the object to be inserted (can be an array of objects)
Inserts OBJECT after REFERENCE.
Removes OBJECT from the list of children
Parameters: OBJECT - the object to be removed (can be an array of objects)
Removes itself from the child list of its parent
Clones itself and optionally, its children
Parameters: DEPTH - The optional depth limit of the cloning
Note: Copied the implementation from Clone::PP(3pm). Weak pointers are discarded, and not cloned. This is done to ensure that objects, such as the parent node of an object, are not cloned.
Returns the markup for the current object and its children.
Prints the current object and all of its children.
Warning: Deprecated. Please see IWL::Object::send(3pm)
Prints the HTML content of current object and all of its children, along with an HTML header.
Returns the object and its children as a new object, with a structure needed for JSON
Returns a JSON object for the current object and its children.
If the html looks like this: <div attr1="1" attr2="2" style="display: none;"> <child1 /> <child2 attr3="3" /> </div>
The corresponding JSON object will look like this:
{"div": {"attributes": {"attr1": 1, "attr2": 2, "style": {"display": "none"}}, "children": ["child1", "child2": {"attributes": {"attr3": 3}}]}}
Prints the JSON of current object and all of its children, along with a javascript header.
Prints the JSON Header which is used by IWL
Prints the HTML Header which is used by IWL
Prints the Text Header which is used by IWL
Returns the JSON Header which is used by IWL
Returns the HTML Header which is used by IWL
Returns the Text Header which is used by IWL
Appends an attribute to the opening tag. The value gets automatically URI escaped. The function fails and returns false on an attempt to set an illegal attribute. Illegal attributes are attributes that contain non US-ASCII characters or violate the XML specification.
If STRICT_LEVEL in iwl.conf is set to a value greater than 1, an exception is thrown in case of illlegal attributes.
Use setStyle for setting the style attribute
Parameter: ATTR - the attribute name to be appended VALUE - the value of the attribute ESCAPING - optional, sets the method of escaping the value - html - html entity escaping [default] - uri - uri escaping - escape - the string is escaped using IWL::String::escape(3pm) - none
setAttributes is a wrapper to setAttribute. It sets all the attributes in the provided hash
Parameters: %ATTRS - a hash of attributes, ESCAPING - optionally provide a method of escaping (see setAttribute)
Returns the value of the given attribute. Use getStyle for getting the style attribute
Parameters: ATTR - the attribute name to be returned, UNESCAPED - optional, true if the value should be returned unescaped
Returns true if attribute ATTR exists, false otherwise.
Deletes the given attribute
Parameters: ATTR - the attribute name to be deleted
Appends an object after the current object
Parameters: OBJECT - the object to be appended
Adds the list of urls (relative to JS_DIR, or absolute) as required by the object
Parameters: URLS - a list of required javascript files
Adds the list of urls (relative to CSS_DIR, or absolute) as required by the object
Parameters: URLS - a list of required CSS files
Class method that initializes all state data of the library. Stateful data is for example the list of already included javascript helper files. If multiple html pages are generated within one process context, this data has to be cleared, so that new pages will start with fresh data.
You will also need to call this method, when using IWL inside of Catalyst(3pm) when running the application with the built-in http server that does not reload modules for each request.
This method is a class method! You do not need to instantiate an object in order to call it.
Note: Currently does nothing, as there is no state data to be cleaned.
Returns the current state of the form as an IWL::Stash object. The form state reflects the state of all of its children of type IWL::Input.
Returns the current state of the form to STATE, an IWL::Stash object. The form state reflects the state of all of its children of type IWL::Input.
Returns the final response object, used by every IWL::Object
Serializes and sends the object using IWL::Response::send(3pm)
Parameters: %ARGS - a hash of arguments. The following keys are supported:
Serializes the object to the given type, and sends the corresponding header. The following types are supported:
Serializes the object to HTML and sends it with a text/html header
Serializes the object to JSON and sends it with an application/json header
Serializes the object to HTML and sends it with a text/plain header
A hash reference, representing an HTTP header, can be passed. It will extend the default header for those types.
If true, an ETag, generated using Digest::MD5, will be added to the header of the response. If the ETag matches the HTTP_IF_NONE_MATCH, the response will also contain a Status with a value of 304, and no actual content will be passed.
If provided, along with static, it will use the values as an ETag header, instead of using Digest::MD5. This is also useful, since no content needs to exist.
Searches upward along the object stack for objects, matching the criteria set by the options.
In scalar context, returns the first found object. In list context, returns all matching objects. Returns the parent object in scalar context, and parent objects in list context, if no criteria are given.
See IWL::Object::match(3pm) for CRITERIA documentation. If the method is invoked with the second syntax, CRITERIA must be an array reference, instead of a list.
Parameters: OPTIONS - a hash reference, with the following key-value pairs:
If true and in list context, the method will return the last matched object, or the last object in the stack.
Searches downward along the object stack for objects, matching the criteria set by the options.
Searches the next siblings of the object for objects, matching the criteria set by the options.
Searches the previous siblings of the object for objects, matching the criteria set by the options.
Returns the object, if it matches the given criteria. Returns false, otherwise. By default, criteria are evaluated with a logical AND.
Parameters: CRITERIA - the criteria is a list of parameters, which can have the following values:
A short-circuit logical OR operator.
A logical NOT operator. Will reverse the next criterion.
A term is a hash reference. The following key-value pairs are supported by IWL::Object:
The package, which the object belongs to.
An attribute, whose name and value should match an attribute of an object. The value of this option is a arrayref, where the first element is the attribute name, and second is the string value for that name, or a compiled reguler expression.
Other classes can expand the list, if they implement the protected _matchTerm method, which receives the term, and returns true or false, depending on whether the object matches the term.
Returns the IWL::Environment of the object's top ancestor, if an environment is set
The following methods should only be used by classes that inherit from IWL::Object.
Appends SCRIPTS to the list of the object's initialization scripts
Parameters: SCRIPTS - JavaScript code, which will be inserted into an IWL::Script widget upon realization
Realizes the object. It is right before the object is serialized into HTML or JSON
Copyright (c) 2006-2007 Viktor Kojouharov. All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perldoc perlartistic.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
3 POD Errors
The following errors were encountered while parsing the POD:
You forgot a '=back' before '=head1'
'=item' outside of any '=over'
To install IWL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm IWL
CPAN shell
perl -MCPAN -e shell install IWL
For more information on module installation, please visit the detailed CPAN module installation guide.