view Lib/IMPL/Web/TT/Collection.pm @ 127:0dce0470a3d8

In the IMPL::Web::ControllerUnit added the ability to notify a form about a wrong data from a transaction added a relativeUrl function for a usage from a templates IMPL::Web::TT::Form now fully functional
author wizard
date Fri, 11 Jun 2010 20:21:07 +0400
parents ddf0f037d460
children 4369d5458bb6
line wrap: on
line source

package IMPL::Web::TT::Collection;
use strict;

use base qw(IMPL::DOM::Node);

__PACKAGE__->PassThroughArgs;

our $AUTOLOAD;
sub AUTOLOAD {
	my $this = shift;
	my ($method) = ($AUTOLOAD =~ /(\w+)$/);
	
	return if $method eq 'DESTROY';
	
	if ($method =~ /^add(\w+)/) {
		my ($name,$args) = @_;
		return $this->appendChild($this->document->CreateControl($name,$1,$args));
	}
	
	if ( @_ >= 1 ) {
		# set
		# we can't assing a node, so this is a dynamic property
		return $this->nodeProperty($method,@_);
	} else {
		# get
		# try a dynamic property first 
		if ( my $val = $this->nodeProperty($method) ) {
			return $val;
		} else {
		# and return a first child node as last opportunity
			my @result = $this->selectNodes($method);
	
			return $result[0] if @result;
			return;
		}
	}
	die new IMPL::Exception("We shoud never get here, this is a bug!!!");
}

sub as_list {
	$_[0]->childNodes;
}

1;