ASP4x::Linker::Widget - A single item that should be persisted via links.
use ASP4x::Linker; my $linker = ASP4x::Linker->new(); # Add a widget: $linker->add_widget( name => 'albums', attrs => [qw( page_number page_size sort_col sort_dir )] ); # Get the widget: my $widget = $linker->widget('albums'); # Change some attributes: $widget->set( page_size => 10 ); $widget->set( page_number => 4 ); # Get the value of some attributes: $widget->get( 'page_size' ); # 10 $widget->get( 'page_number' ); # 4 # Make page_number reset to 1 if the page_size is changed: $widget->on_change( page_size => sub { my $s = shift; $s->set( page_number => 1 ); }); $widget->set( page_size => 20 ); print $widget->get( 'page_number' ); # 1 # Set multiple values at once: $widget->set( %args ); # Set multiple values at once and get the uri: warn $widget->set( %args )->uri(); # Set multiple values by chaining and get the uri: warn $widget->set( foo => 'bar' )->set( baz => 'bux' )->uri();
ASP4x::Linker::Widget provides a simple, simple interface to a "thing" on your web page (which we'll call a "widget").
ASP4x::Linker::Widget
A "widget" can be anything. My experience generally means that a widget is a data grid that supports paging and sorting through multiple records. However a widget could represent anything you want it to, as long as you can describe it with a name and and arrayref of attrs (attributes). The attrs arrayref for a data grid might look like what you see in the example above:
attrs => [qw( page_number page_size sort_col sort_dir )]
In English, a "widget" can be anything. The word "widget" could be replaced with "thing" - so in this case a "widget" is just a "thing" - anything (with a name and attributes).
Returns a hashref of all name/value pairs of attributes and their current values.
Returns an array of the names of the widget's attributes.
Restores the widget's vars to its original state - as it was when the widget was first instantiated.
vars
Changes the value of an attribute to a new value.
NOTE: As of version , attempts to apply a value to a non-existant attribute will result in a runtime exception.
Returns the current value of the attribute.
Adds a trigger to the widget that will be called when the given attribute's value is changed via set().
set()
Just a wrapper around the widget's parent ASP4x::Linker object.
ASP4x::Linker
John Drago <jdrago_999@yahoo.com>
This software is Free software and may be used and redistributed under the same terms as Perl itself.
To install ASP4x::Linker, copy and paste the appropriate command in to your terminal.
cpanm
cpanm ASP4x::Linker
CPAN shell
perl -MCPAN -e shell install ASP4x::Linker
For more information on module installation, please visit the detailed CPAN module installation guide.