The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

IWL::Object - Base object module for IWL

DESCRIPTION

This is the base object module for IWL. Every other module will inherit from it.

PROPERTIES

childNodes

An array of child objects for the current object. Null if there are no children.

parentNode

The parent for the current object. Null if it has no parent.

METHODS

firstChild

Returns the first child of the object

lastChild

Returns the last child of the object

nextChild (CURRENT_CHILD)

Obtains the next child of the object. Parameter: CURRENT_CHILD - it's sibling Returns the child object, or null if there is no next child.

prevChild (CURRENT_CHILD)

Obtains the previous child of the object. Parameter: CURRENT_CHILD - it's sibling Returns the child object, or null if there is no previous child.

getChildren

Returns a reference to the array of child objects

nextSibling

Returns the next sibling of the current object.

prevSibling

Returns the previous sibling of the current object.

getParent

Returns the parent object of the current object

appendChild (OBJECT)

Appends OBJECT as a child to the current object.

Parameter: OBJECT - the object to be appended (can be an array of objects)

prependChild (OBJECT)

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)

insertAfter (REFERENCE, OBJECT)

Inserts OBJECT after REFERENCE.

Parameter: OBJECT - the object to be inserted (can be an array of objects)

setChild (OBJECT)

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)

getContent

Returns the markup for the current object and it's children.

print

Prints the current object and all of it's children.

printHTML

Prints the HTML content of current object and all of its children, along with an HTML header.

getObject

Returns the object and it's children as a new object, with a structure needed for JSON

getJSON

Returns a JSON object for the current object and it's 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}}]}}

printJSON

Prints the JSON of current object and all of its children, along with a javascript header.

printJSONHeader

Prints the JSON Header which is used by IWL

printHTMLHeader

Prints the HTML Header which is used by IWL

setAttribute (ATTR, VALUE, ESCAPING)

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 (%ATTRS, ESCAPING)

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)

getAttribute (ATTR, UNESCAPED)

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

hasAttribute (ATTR)

Returns true if attribute ATTR exists, false otherwise.

deleteAttribute (ATTR)

Deletes the given attribute

Parameters: ATTR - the attribute name to be deleted

appendAfter (OBJECT)

Appends an object after the current object

Parameters: OBJECT - the object to be appended

requiredJs [URLS]

Adds the list of urls (relative to JS_DIR) as required by the object

Parameters: URLS - a list of required javascript files

requiredConditionalJs [CONDITION, URLS]

Adds the list of urls inside a conditonal comment (relative to JS_DIR) as required by the object

Parameters: CONDITION - the comment condition, see IWL::Comment(3pm) URLS - a list of required javascript files

cleanStateful

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.

errorList

In scalar context returns the newline separated contents of the error stack. In list context it returns the error stack as a list.

errorSuck

Like errorList() but empties the error stack and resets the bad state.

chompErrors

Removes trailing newlines from the messages on the error stack.

clearErrors

Empties the error stack.

bad

Returns the current bad state.

errors

Returns the number of messages on the error stack.

PROTECTED METHODS

The following methods should only be used by classes that inherit from IWL::Object.

_pushFatalError (STRINGLIST)

Combines _pushError and _setBad to produce a fatal error

_pushError (STRINGLIST)

Push all strings in STRINGLIST onto the error stack and returns false (can be used to return with an error from arbitrary functions).

_setBad (STATE)

Sets the current bad state.

getState

Returns the current state of the form as an IWL::Stash(3pm) object. The form state reflects the state of all of its children of type IWL::Input(3pm).

applyState (STATE)

Returns the current state of the form to STATE, an IWL::Stash(3pm) object. The form state reflects the state of all of its children of type IWL::Input(3pm).

LICENCE AND COPYRIGHT

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:

Around line 858:

You forgot a '=back' before '=head1'

Around line 863:

'=item' outside of any '=over'

Around line 981:

You forgot a '=back' before '=head1'