简体   繁体   English

按钮在Vaadin中提交

[英]Button Submit in Vaadin

I am Using Vaadin in my application to display the REPORTS on PAGED TABLE from date to to date. 我在我的应用程序中使用Vaadin来显示PAGED TABLE上迄今为止的报告。

The code is working fine, when I click the submit button the data is not showing any where on vaadin ui table but, when I click the header row of that table then the data is showing.I need when the user entered from date to to date then after clicking the submit button the I need to display the reports on table instead of clicking the header row.Here I am top display the reports on the table I am using PAGED TABLE instead of normal Table. 代码运行正常,当我单击``提交''按钮时,数据没有显示在vaadin ui表上的任何位置,但是当我单击该表的标题行时,则显示了数据。当用户输入从日期到日期,然后单击“提交”按钮后,我需要在表格上显示报告,而不是单击标题行。在这里,我将使用PAGED TABLE而不是普通表在表格的顶部显示报告。

I am using this Code for all reports due to this all reports are behaving likesame. 由于所有报告的行为都相同,因此我正在对所有报告使用此代码。

Pls help me here is the code is 请帮我这里的代码是

Button executeReportButton = new Button("Submit");
executeReportButton.addListener(new Button.ClickListener() {
    @Override
    public void buttonClick(ClickEvent event) {

        if ((Date) tatFromDate.getValue() != null
            && (Date) tatToDate.getValue() != null) {
            runDBReport(reportTable, (Date) tatFromDate.getValue(),
                (Date) tatToDate.getValue());
        } else
    showWarningNotification("Error loading check list report.",
        "Date entered is not valid.");
    }
});

private void runDBReport(PagedTable reportTable, Date fromDate, Date toDate) {

    final PagedTable _reportTable = reportTable;
    final Date _fromDate = fromDate;
    final Date _toDate = toDate;

    HibernateUtils.getCurrentSession().doWork(new Work() {
        @Override
        public void execute(Connection connection) throws SQLException {
            String reportCall = "{ call RP_PROC_CHECKLIST_AUDIT(?, ?, ?) }";

            CallableStatement stmt = null;
            ResultSet rs = null;

            try {
                stmt = connection.prepareCall(reportCall);

                // register the type of the out param - an Oracle specific
                // type
                stmt.registerOutParameter(3, OracleTypesHelper.INSTANCE
                    .getOracleCursorTypeSqlType());

                // set the in param
                stmt.setDate(1, new java.sql.Date(_fromDate.getTime()));
                stmt.setDate(2, new java.sql.Date(_toDate.getTime()));

                // execute and retrieve the result set
                stmt.execute();
                rs = (ResultSet) stmt.getObject(3);

                // get the results
                while (rs.next()) {
                    Object TATDataRowId = _reportTable.addItem();
                    _reportTable.getItem(TATDataRowId)
                        .getItemProperty("checklistid")
                        .setValue(rs.getString(1));
                    _reportTable.getItem(TATDataRowId)
                        .getItemProperty("checklistdescription")
                        .setValue(rs.getString(2));
                    // ... a trillion more

                }

            } catch (Exception e) {
                logger.error(
                        "Error loading check list report. Exception: {}",
                        e.getMessage());
                logger.debug("Error loading check list report.", e);
                showWarningNotification(
                        "Error loading check list report. Please contact admin",
                        "Error message is : " + e.getMessage());

            } finally {

                rs.close();
                stmt.close();
            }

        }
    });

}

I think that your HibernateUtils.getCurrentSession().doWork(new Work().... is starting a background thread and, when the report is finished fills in the table. 我认为您的HibernateUtils.getCurrentSession()。doWork(new Work()....正在启动后台线程,并且当报告完成时会填入表格。

For background threads updating the UI in vaadin, there a special rules on how to do it. 对于在vaadin中更新UI的后台线程,有专门的规则来做到这一点。 When you don't follow them, then the serverside changes are only visible on the next client->server interaction. 如果不遵循它们,则服务器端更改仅在下一次客户端->服务器交互中可见。

https://vaadin.com/book/vaadin7/-/page/advanced.push.html#advanced.push.running https://vaadin.com/book/vaadin7/-/page/advanced.push.html#advanced.push.running

Don't forget to also look at server push/polling, since the webbrowser must be notified for the new content 不要忘记也要查看服务器的推送/轮询,因为必须通知Web浏览器新内容

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM