public function generateAction()
    {
        /**
         * Determine if it comes from an ajax call
         * so we can send back different datas with the html
         */
        $isXmlHttpRequest = false;
        if ($this->getRequest()->isXmlHttpRequest()) {
            $isXmlHttpRequest = true;
        }

        /**
         * Get the params from php call
         */
        $appconfigpath = $this->params()->fromRoute('appconfigpath', '/');
        $keyView = $this->params()->fromRoute('keyview', 'melis');

        /**
         * Else get the params from GET if ajax
         */
        $datasParameters = [];
        if ($isXmlHttpRequest) {
            $appconfigpath = $this->getRequest()->getQuery('cpath');
            $lastKey = explode('/', $appconfigpath);
            $keyView = $lastKey[count($lastKey) - 1];
        }

        /**
         * Forcing to set the request to http request
         */
        if ($this->getRequest()->getQuery('forceFlagXmlHttpRequestTofalse', false))
            $isXmlHttpRequest = false;

        /**
         * Get the appConfig
         */
        $melisAppConfig = $this->getServiceLocator()->get('MelisCoreConfig');

        /**
         * Get the real path, from the MelisKey, if needed
         */
        $melisKeys = $melisAppConfig->getMelisKeys();

        if (!empty($melisKeys[$appconfigpath])) {
            $appconfigpath = $melisKeys[$appconfigpath];
        }

        $appsConfig = $melisAppConfig->getItem($appconfigpath);

        if ($isXmlHttpRequest && !empty($appsConfig['interface'])) {
            $appsConfig['interface'] = $this->orderInterfaceChildren($keyView, $appsConfig['interface']);
        }

        list($jsCallBacks, $datasCallback) = $melisAppConfig->getJsCallbacksDatas($appsConfig);


        /**
         * Generate the views recursively
         * and add the corresponding appConfig part to make it accessible in the view
         */
        $zoneView = $this->generateRec($keyView, $appconfigpath, $datasParameters);
        $zoneView->setVariable('zoneconfig', $appsConfig);
        $zoneView->setVariable('parameters', $datasParameters);
        $zoneView->setVariable('keyInterface', $keyView);

        /**
         * Add JS calls and datas found in config,
         * so that it will be added in head when generating
         */
        if (!empty($zoneView->getVariable('jsCallBacks')) && is_array($zoneView->getVariable('jsCallBacks')))
        {
            $jsCallBacks = ArrayUtils::merge($zoneView->getVariable('jsCallBacks'), $jsCallBacks);
        }
        $zoneView->setVariable('jsCallBacks', $jsCallBacks);

        if (!empty($zoneView->getVariable('datasCallback')) && is_array($zoneView->getVariable('datasCallback')))
        {
            $datasCallback = ArrayUtils::merge($zoneView->getVariable('datasCallback'), $datasCallback);
        }
        $zoneView->setVariable('datasCallback', $datasCallback);

        /**
         * If ajax, return json
         * else, return the normal view
         */
        if ($isXmlHttpRequest) {
            $htmlZoneView = $this->renderViewRec($zoneView);

            $jsonModel = new JsonModel();
            $jsonModel->setVariables([
                'html' => $htmlZoneView,
                'jsCallbacks' => $jsCallBacks,
                'jsDatas' => $datasCallback,
            ]);

            return $jsonModel;
        } else {
            /**
             * Return view
             */
            return $zoneView;
        }
    }