Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/361.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 更改选项卡后无法刷新jsf中的datatable_Java_Javascript_Jquery_Jsf_Datatable - Fatal编程技术网

Java 更改选项卡后无法刷新jsf中的datatable

Java 更改选项卡后无法刷新jsf中的datatable,java,javascript,jquery,jsf,datatable,Java,Javascript,Jquery,Jsf,Datatable,这是我的要求。我应该添加一条记录,在成功添加并单击“视图”选项卡后,datatable应该刷新,但该表保持不变。我使用getter方法从一个支持bean将数据提取到datatable中 数据表内部: <p:dataTable id="ci_table" value="#{ciConfigBean.ciList}" var="cid" scrollable="true" selectionMode="single" selection="#{ciConfigBean.ciConfigSave

这是我的要求。我应该添加一条记录,在成功添加并单击“视图”选项卡后,datatable应该刷新,但该表保持不变。我使用getter方法从一个支持bean将数据提取到datatable中

数据表内部:

<p:dataTable id="ci_table" value="#{ciConfigBean.ciList}" var="cid" scrollable="true" selectionMode="single" selection="#{ciConfigBean.ciConfigSave}"
            rowKey="#{cid.ciConfigId}" editable="true" resizableColumns="true">
第二功能:

var oTable;
            $(document).ready(function() {
                    oTable = $('#ci_table').dataTable({
                        "bProcessing" : true,
                        "bServerSide" : true,
                        "sAjaxSource" : '${request.contextPath}'
                                + '/ciConfigBean/getCiList'
                        });
                        oTable.fnReloadAjax();
                });
选项卡更改代码:

<p:tab id="ci" title="CI">
            <p:tabView id="insideCi" onTabChange="onLoad()"
                activeIndex="#{home.activeInner}">
                <p:tab id="ciList" title="CI List">
                    <ui:include src="ci/ciList.xhtml" />
                </p:tab>
                <p:tab id="newCi" title="New CI">
                    <ui:include src="ci/newCi.xhtml" />
                </p:tab>
            </p:tabView>
        </p:tab>


但似乎什么都不管用。对此有何建议?

尝试在选项卡视图标签上添加dynamic=“true”。假设你的save方法有效,我从你的帖子中看不到,这应该可以做到。不需要JavaScript。

@Andre,当我刷新整个页面时,datatable将更新。但当我更改选项卡时,它不会更新。以下是my bean中的Save方法:

public void saveCiConfig() throws SystemException {
    long ciId = CounterLocalServiceUtil.increment(CIConfig.class
                    .getName());
            ciConfigSave.setCiConfigId(ciId);
            ciConfigSave.setProjectId(0);
            ciConfigSave.setParentCIConfigId(0);
            ciConfigSave.setCreatedDate(new Date());
            ciConfigSave.setCreatedBy(FacesUtil.getUserId());
            ciConfigSave.setUpdatedDate(null);
            ciConfigSave.setUpdatedBy(0);
            if (enable == Boolean.TRUE) {
                ciConfigSave.setStatus(DataConstant.STATUS_ACTIVE);
            } else {
                ciConfigSave.setStatus(DataConstant.STATUS_INACTIVE);
            }
            ciConfigSave.setSetupComplete(Boolean.FALSE);
            try {
                  CIConfigLocalServiceUtil.addCIConfig(ciConfigSave);
                FacesMessageUtil
                        .addGlobalInfoMessage("ci.message.submitSuccess");
                new Home().setActiveOuter(0);
                new Home().setActiveInner(1);
                setEditMode(Boolean.FALSE);
                resetInit();
            } catch (SystemException e) {
                FacesMessageUtil
                        .addGlobalErrorMessage("ci.message.submitFailed");
                log.error("error while saving the CI Configuration", e);
            }

好吧,我想没有合适的方法。。。因此,作为一种解决方法,我添加了一个commandbutton来手动刷新。

我尝试使用“动态”属性。但仍然没有结果。我正在“新建CI”选项卡中添加一条新记录,并已成功保存该记录。在此之后,如果单击“视图”选项卡,列表将不会刷新。我尝试使用dynamic=“true”,但它不起作用。每当我在“新建CI”选项卡中创建新值时,它都会成功地保存到数据库中。但是当我选择CI>列表时,datatable中没有填充新值。您可以查询实际的数据库并查看记录是否确实存在吗?如果是这样,当您刷新整个页面时,datatable是否会更新?您使用的是惰性数据表吗?同样,如果你发布你的bean代码,帮助你会容易得多。我已经检查了数据库,它成功地保存了,但是新增加的值没有反映在datatable中。只有当我再次重新加载整个页面时,datatable才会用新值更新,直到datatable中没有任何更改。您不是在使用惰性数据模型吗?如果没有,则必须手动重新加载馈送到dataTable组件的列表。
public void saveCiConfig() throws SystemException {
    long ciId = CounterLocalServiceUtil.increment(CIConfig.class
                    .getName());
            ciConfigSave.setCiConfigId(ciId);
            ciConfigSave.setProjectId(0);
            ciConfigSave.setParentCIConfigId(0);
            ciConfigSave.setCreatedDate(new Date());
            ciConfigSave.setCreatedBy(FacesUtil.getUserId());
            ciConfigSave.setUpdatedDate(null);
            ciConfigSave.setUpdatedBy(0);
            if (enable == Boolean.TRUE) {
                ciConfigSave.setStatus(DataConstant.STATUS_ACTIVE);
            } else {
                ciConfigSave.setStatus(DataConstant.STATUS_INACTIVE);
            }
            ciConfigSave.setSetupComplete(Boolean.FALSE);
            try {
                  CIConfigLocalServiceUtil.addCIConfig(ciConfigSave);
                FacesMessageUtil
                        .addGlobalInfoMessage("ci.message.submitSuccess");
                new Home().setActiveOuter(0);
                new Home().setActiveInner(1);
                setEditMode(Boolean.FALSE);
                resetInit();
            } catch (SystemException e) {
                FacesMessageUtil
                        .addGlobalErrorMessage("ci.message.submitFailed");
                log.error("error while saving the CI Configuration", e);
            }