moved handle for image buttons to UI::Window
[catagits/Reaction.git] / lib / Reaction / UI / Window.pm
index 610a935..0289b39 100644 (file)
@@ -50,15 +50,30 @@ sub flush_events {
 
   foreach my $type (qw/query body/) {
     my $meth = "${type}_parameters";
-    my $param_hash = { %{$ctx->req->$meth} }; # yeah, FocusStack deletes it
-    $self->focus_stack->apply_events($param_hash)
-      if keys %$param_hash;
+    my $req_param = $ctx->req->$meth;
+    my $param_hash = { 
+        map {
+            $_ =~ m/(^r.+\:\w+)\.(x|y)/ ? # for <input type="image"... buttons
+              ( $1 => $req_param->{$_} )
+              : ( $_ => $req_param->{$_} )
+        } keys %$req_param
+    }; # yeah, FocusStack deletes it
+    my @param_keys = keys %$param_hash;
+    if (@param_keys) {
+        for (@param_keys) {
+            utf8::decode($param_hash->{$_})
+                unless (utf8::is_utf8($param_hash->{$_}));
+        }
+        $self->focus_stack->apply_events($param_hash);
+    }
   }
 };
 sub flush_view {
   my ($self) = @_;
   my $res = $self->ctx->res;
-  $res->body($self->view->render_window($self));
+  my $res_body = $self->view->render_window($self);
+  utf8::encode($res_body) if utf8::is_utf8($res_body);
+  $res->body($res_body);
   $res->content_type($self->content_type);
 };