public function handleDatasource($name, $method, array $preloadedData, array &$templateVariables)
    {
        $this->name = $name;

        $datasource = ActionUtils::createActionDatasource($name,$method);

        // set the variables for use
        $this->templateVars =& $templateVariables;

        $this->currentDatasource = $datasource;

        // set the current datasource
        $this->currentActionOrDatasource = $datasource;

        $methodResolved = ActionUtils::parseMethod($method);

        $this->currentMethod = $methodResolved;

        //if(LOG_ENABLE) System::log(self::$logType, 'Datasource: ['.$datasource.']');

        // if we did an action and the datasource is already set, use it
        if(self::$actionBoundDatasource == $datasource)
            return $this;

        if(!method_exists($this, $methodResolved))
            throw new Exception('Method ['.$methodResolved.'] does not exist on class ['.get_class($this).']');

        // clear the data first
        $this->setData(null);

        // set preloaded data (from Renderer)
        if(!empty($preloadedData))
            $this->setData($preloadedData);

        $this->preDatasource();

        //if(LOG_ENABLE) System::log(self::$logType, 'Executing method ['.$methodResolved.']');

        $result = null;

        $result = $this->$methodResolved();

        if($result == null)
            $result = array();

        // bind to datasource
        $this->setData($result);

        $this->postDatasource();

        return $this; // for chaining
    }