public function executeAction($reportUri, Request $request) {
        //Decode the report uri
        $decodedReportUri = urldecode($reportUri);

        //Get the form again
        $form = $this->container->get('mesd.jasper.report.client')->buildReportInputForm(
            $decodedReportUri, null, array('data' => $request->request->get('form')));

        //Process the form
        $form->handleRequest($request);

        //If any errors
        if (!$form->isValid()) {
            //Get form errors
            $errors = FormErrorConverter::convertToArray($form);
            return new JsonResponse(array('success' => false, 'errors' => $errors));
        }

        //Build the report
        $rb = $this->container->get('mesd.jasper.report.client')->createReportBuilder($decodedReportUri);
        $rb->setInputParametersArray($form->getData());
        $rb->setFormat('html');
        $rb->setPage(1);
        //Run the report and get the request id back
        $requestId = $rb->runReport();

        //Load the first page of the report for the output
        $response = $this->loadPage($requestId, 1);

        //Setup the links for the toolbar
        $response['toolbar'] = $this->container->get('mesd.jasper.reportviewer.linkhelper')->generateToolbarLinks(
            $requestId, $response['page'], $response['totalPages']);

        //Return the json response
        return new JsonResponse($response);
    }
public function executeAction($reportUri, Request $request) {
        //Decode the report uri
        $decodedReportUri = urldecode($reportUri);

        //Get the form again
        $form = $this->container->get('mesd.jasper.report.client')->buildReportInputForm(
            $decodedReportUri, null, array('data' => $request->request->get('form')));

        //Process the form
        $form->handleRequest($request);

        //If any errors
        if (!$form->isValid()) {
            //Get form errors
            $errors = FormErrorConverter::convertToArray($form);
            return new JsonResponse(array('success' => false, 'errors' => $errors));
        }

        //Build the report
        $rb = $this->container->get('mesd.jasper.report.client')->createReportBuilder($decodedReportUri);
        $rb->setInputParametersArray($form->getData());
        $rb->setFormat('html');
        $rb->setPage(1);
        //Run the report and get the request id back
        $requestId = $rb->runReport();

        //Load the first page of the report for the output
        $response = $this->loadPage($requestId, 1);

        //Setup the links for the toolbar
        $response['toolbar'] = $this->container->get('mesd.jasper.reportviewer.linkhelper')->generateToolbarLinks(
            $requestId, $response['page'], $response['totalPages']);

        //Return the json response
        return new JsonResponse($response);
    }
public function executeAction ( $ reportUri , Request $ request ) { //Decode the report uri $ decodedReportUri = urldecode ( $ reportUri ) ; //Get the form again $ form = $ this -> container -> get ( 'mesd.jasper.report.client' ) -> buildReportInputForm ( $ decodedReportUri , null , array ( 'data' => $ request -> request -> get ( 'form' ) ) ) ; //Process the form $ form -> handleRequest ( $ request ) ; //If any errors if ( ! $ form -> isValid ( ) ) { //Get form errors $ errors = FormErrorConverter :: convertToArray ( $ form ) ; return new JsonResponse ( array ( 'success' => false , 'errors' => $ errors ) ) ; } //Build the report $ rb = $ this -> container -> get ( 'mesd.jasper.report.client' ) -> createReportBuilder ( $ decodedReportUri ) ; $ rb -> setInputParametersArray ( $ form -> getData ( ) ) ; $ rb -> setFormat ( 'html' ) ; $ rb -> setPage ( 1 ) ; //Run the report and get the request id back $ requestId = $ rb -> runReport ( ) ; //Load the first page of the report for the output $ response = $ this -> loadPage ( $ requestId , 1 ) ; //Setup the links for the toolbar $ response [ 'toolbar' ] = $ this -> container -> get ( 'mesd.jasper.reportviewer.linkhelper' ) -> generateToolbarLinks ( $ requestId , $ response [ 'page' ] , $ response [ 'totalPages' ] ) ; //Return the json response return new JsonResponse ( $ response ) ; }
Runs a report

@param  string  $reportUri The jasper server uri for the report
@param  Request $request   The request from the submitted request input form

@return JsonResponse       Json Response giving links to the output or what errors occured
Runs a report