public function render()
 {
     //add default raw js
     $viewModel = ViewModel::getInstance();
     $js = 'function site_config(key) {return {"base_url":"' . Config::getInstance()->get('main_server') . '","window_id":' . mt_rand(1, 1000000) . '}[key.toLowerCase()];}';
     $viewModel->addRawJs($js);
     $action = $this->_controller->getAction();
     //find the correct template
     $template = TemplateManager::getInstance()->findTemplate($action);
     return $template->render();
 }
 public function run($action_name = null)
 {
     //load templates
     \ORC\Util\TemplateManager::getInstance();
     if (!defined('DIR_APP_PUBLIC')) {
         throw new \ORC\Exception\SystemException('const DIR_APP_PUBLIC not defined!');
     }
     if (empty($action_name)) {
         $action_name = $this->getController()->dispatch();
     }
     try {
         $this->getController()->execute($action_name);
     } catch (\ORC\Exception\Exception $ex) {
         $this->getController()->getRequest()->set('exception', $ex);
         $this->getController()->execute('Default.Exception');
     } catch (\Exception $ex) {
         $this->getController()->getRequest()->set('exception', $ex);
         $this->getController()->execute('Default.Exception');
     }
 }