changeset 302:673581380e79

Added templates provider functionality to controls minor fixes
author cin
date Mon, 01 Apr 2013 00:41:48 +0400
parents aeeb57a12046
children a5eb64c6e6f7
files Lib/IMPL/Web/Application/ResourceContract.pm Lib/IMPL/Web/NotAllowedException.pm Lib/IMPL/Web/View/TTControl.pm
diffstat 3 files changed, 30 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Lib/IMPL/Web/Application/ResourceContract.pm	Mon Mar 25 02:04:18 2013 +0400
+++ b/Lib/IMPL/Web/Application/ResourceContract.pm	Mon Apr 01 00:41:48 2013 +0400
@@ -1,5 +1,7 @@
 package IMPL::Web::Application::ResourceContract;
 use strict;
+
+use IMPL::lang;
 use IMPL::Const qw(:prop);
 use IMPL::declare {
 	require => {
@@ -40,7 +42,12 @@
 	my %nameMap;
 
 	foreach my $res (@$resources) {
+		if (ref $res->{contract} eq 'HASH') {
+		    $res->{contract} = __PACKAGE__->new(%{$res->{contract}});
+		}
+		
 		next unless $res->{contract};
+		
 		if ( my $name = $res->{name} ) {
 			$nameMap{$name} = $res;
 		}
--- a/Lib/IMPL/Web/NotAllowedException.pm	Mon Mar 25 02:04:18 2013 +0400
+++ b/Lib/IMPL/Web/NotAllowedException.pm	Mon Apr 01 00:41:48 2013 +0400
@@ -4,13 +4,14 @@
 use IMPL::Const qw(:prop);
 use IMPL::declare {
     base => [
-        'IMPL::Web::Exception' => sub {
-            my %args = @_;
-            $args{Message};
-        }
+        'IMPL::Web::Exception' => '@_'
     ]
 };
 
+use IMPL::Resources::Strings {
+    message => "The requested method isn't allowed"
+};
+
 sub CTOR {
     my $this = shift;
     my %args = @_;
--- a/Lib/IMPL/Web/View/TTControl.pm	Mon Mar 25 02:04:18 2013 +0400
+++ b/Lib/IMPL/Web/View/TTControl.pm	Mon Apr 01 00:41:48 2013 +0400
@@ -89,6 +89,24 @@
     );
 }
 
+sub GetTemplate {
+    my ($this,$name) = @_;
+    
+    return eval { $this->context->template($name) }; 
+}
+
+sub Include {
+    my ($this,$template, $args) = @_;
+    
+    my $tpl = $this->GetTemplate($template)
+        or die OperationException->new("The specified template isn't found", $template);
+        
+    return $this->context->include(
+        $tpl,
+        $args
+    );
+}
+
 sub AUTOLOAD {
     our $AUTOLOAD;