POD: Typo in Autor-Abschnitt verbessert.
[kivitendo-erp.git] / SL / Controller / Base.pm
index a233a0e..01da48b 100644 (file)
@@ -13,7 +13,8 @@ use SL::Presenter;
 
 use Rose::Object::MakeMethods::Generic
 (
-  scalar => [ qw(action_name) ],
+  scalar                  => [ qw(action_name) ],
+  'scalar --get_set_init' => [ qw(js) ],
 );
 
 #
@@ -98,6 +99,18 @@ sub render {
     $options->{layout} = 0 if $options->{type} ne 'html';
   }
 
+  # Let the presenter do the rest of the work.
+  my $output;
+  {
+    local $::form->{title} = $locals{title} if $locals{title};
+    $output = $self->presenter->render(
+      $template,
+      { type => $options->{type}, process => $options->{process} },
+      %locals,
+      SELF => $self,
+    );
+  }
+
   if ($options->{header}) {
     # Output the HTTP response and the layout in case of HTML output.
 
@@ -120,14 +133,6 @@ sub render {
     }
   }
 
-  # Let the presenter do the rest of the work.
-  my $output = $self->presenter->render(
-    $template,
-    { type => $options->{type}, process => $options->{process} },
-    %locals,
-    SELF => $self,
-  );
-
   # Print the output if wanted.
   print $output if $options->{output};
 
@@ -161,6 +166,8 @@ sub send_file {
   } else {
     $::locale->with_raw_io(\*STDOUT, sub { print $$file_name_or_content });
   }
+
+  return 1;
 }
 
 sub presenter {
@@ -173,6 +180,10 @@ sub controller_name {
   return $class;
 }
 
+sub init_js {
+  SL::ClientJS->new(controller => $_[0])
+}
+
 #
 # Before/after run hooks
 #
@@ -611,6 +622,10 @@ name the dispatching resolved to.
 Returns the global presenter object by calling
 L<SL::Presenter/get>.
 
+=item C<js>
+
+Returns an L<SL::ClientJS> instance for this controller.
+
 =back
 
 =head2 PRIVATE FUNCTIONS