3

我正在尝试将 BIRT 与 Python Django 集成。我在 Django 中创建了一个表单,允许用户将参数输入到报告中。提交表单后,视图获取参数并创建请求并将其发送到 BIRT Tomcat 服务器。现在我正在尝试呈现来自服务器的响应。这是我的看法:

def birt_report(request, report_id, report_url=None, template='report_parameters.html'):
    if request.method == 'POST':
        form = ReportParametersForm(request.POST)
        if form.is_valid():
            report_params = form.save()
            form_id = report_params.id
            url = "http://<hostname>/BIRT-Viewer/frameset?__report=" + report_url + ".rptdesign"
            url += "&param_id=" + str(form_id)
            r = requests.get(url)
            return HttpResponse(content=str(r.content),status=200,content_type='text/html; charset=utf-8')
    else:
        form = ReportParametersForm()
        return render(request,template, {
            'form': form,
            'report_url': report_url,
            'report_id': report_id,
        })

一切正常,直到我尝试渲染 BIRT 服务器发回给我的内容。我得到了默认的 BIRT Web 应用工具栏。但是,页面的报告部分是空白的。这是它的样子:

BIRT报告

该报告在我的 Eclipse Report Designer 预览中正确生成。如何让报告在这里呈现?谢谢!

编辑:

我查看了页面加载时发生的情况,并在我的 Javascript 控制台中收到此错误:

POST http://<hostname>/<Django_URL>/__sessionId=20130410_103510_658?__sessionId=20130410_103510_658 404 (NOT FOUND)
    prototype.js:656
Ajax.Request.Object.extend.request
    prototype.js:656
Ajax.Request.Object.extend.initialize
    prototype.js:631
(anonymous function)
    prototype.js:24
BirtCommunicationManager.connect
    BirtCommunicationManager.js:58
BirtEventDispatcher.sendEvent
    BirtEventDispatcher.js:179
BirtEventDispatcher.broadcastEvent
    BirtEventDispatcher.js:141
Object.extend.__init_pag
e    BirtNavigationBar.js:243
init
    <hostname>:1604
onload
    <hostname>:91

当我通过 BIRT 随附的 BIRT Viewer webapp 访问报告时,Javascript 文件 [b]prototype.js:656[/b] 使用以下 URL:

http://<hostname>/BIRT-Viewer/frameset?__report=<report_name>.rptdesign&param_id=1&__sessionId=20130410_103510_658

代替:

http://<hostname>/<Django_URL>/__sessionId=20130410_103510_658?__sessionId=20130410_103510_658
4

0 回答 0