Hans Koch
Hans Koch

Reputation: 4481

BE AJAX request delivers empty repository

I want to build an BE extension that is reading the repository from another extension and delivers the data as CSV/XSL/XSLX without saving it on the server. e.g Outputs the data in a blank window with modified headers.

The BE AJAX request is fired properly with

$TYPO3_CONF_VARS['BE']['AJAX']['tx_myext::ajaxID'] = 'filename:object->method';

The repository if called from the backend does work fine too.

public function ajaxAction() {
...
$this->extRepository =& t3lib_div::makeInstance('Tx_MySecondExt_Domain_Repository_DataRepository');
...
}

but when called from domain.tld/typo3/ajax.php?ajaxID=tx_myext::ajaxID it doesnt find Tx_MySecondExt_Domain_Repository_DataRepository also if i call the repository of the second repository with the findAll() methode directly by AJAX. It does only return NULL.

also when setting the QuerySettings by hand

public function findAllexport() {
    $query = $this->createQuery();        
    $query->getQuerySettings()->setRespectStoragePage(FALSE);

    return $query->execute();
}

Also FYI its on 4.5

Edit:

Calling the repository with the ObjectManager doesn't work too

$objectManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');    
$this->extRepository = $objectManager->get('Tx_MySecondExt_Domain_Repository_DataRepository');

Upvotes: 0

Views: 296

Answers (2)

Jay Böttcher
Jay Böttcher

Reputation: 534

Did you make sure that the other extension is loaded before your own extension is loaded? Look at your localconf.php. Normally you need to specify the dependencies in your ext_emconf.php before you install your extension.

Also make sure that you have added both extension's configurations to the Static Includes of your TypoScript template.

Upvotes: 1

Hans Koch
Hans Koch

Reputation: 4481

inside the export action

... Repository to file generation

header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="data.xls"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header ('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header ('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); // always modified
header ('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header ('Pragma: public'); // HTTP/1.0

... output file
exit;

done, no ajax plus pretty simple and stupid ;)

still if somone knows a awnser to the intial probelem i would appreciate it.

Upvotes: 0

Related Questions