Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.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
jsf轮询更新清除输入字段_Jsf_Jsf 2_Primefaces_Jsf 2.2 - Fatal编程技术网

jsf轮询更新清除输入字段

jsf轮询更新清除输入字段,jsf,jsf-2,primefaces,jsf-2.2,Jsf,Jsf 2,Primefaces,Jsf 2.2,我已经为此挣扎了好几天了 我有一个primefaces的选项卡视图,下面的值是对象的集合 <p:tabView id="allChats" value="#{userCalcChatRoom.userChats.userListChats}" var="userChat" activeIndex="#{userCalcChatRoom.userChats.activeChat}" dynamic="true" cache="true" scr

我已经为此挣扎了好几天了

我有一个primefaces的选项卡视图,下面的值是对象的集合

<p:tabView id="allChats"
        value="#{userCalcChatRoom.userChats.userListChats}" var="userChat"
        activeIndex="#{userCalcChatRoom.userChats.activeChat}" dynamic="true" cache="true"
        scrollable="true">

        <p:tab title="#{userChat.getTitle()}">

            <h:form id="chats">
                <div class="chatBottom">

                    <p:dataList id="dataListMessages"
                        value="#{userChat.chat.messages}" var="message"
                        rendered="#{not empty userChat.chat.messages}" type="none">
                        <p>
                            <span class="username"># message.user.username}: </span> <span
                                class="message">#{message.message}</span>
                        </p>
                    </p:dataList>

                </div>

                <div class="divAddNewMessage">
                    <p:inputText autocomplete="false" value="#{userChat.inputAddNewMessage}" required="true" />
                    <p:commandButton process="@form" update="@form"
                        actionListener="#{userChat.addNewMessage() }" styleClass="hidden" />
                </div>
            </h:form>

        </p:tab>
    </p:tabView>


#message.user.username}:#{message.message}

此集合可能会在服务器上更改,因此我需要每X秒更新一次此选项卡视图,我可以使用poll:

问题是我在每个选项卡上都有输入字段,它们的值在每次轮询时都会丢失

有没有办法更新选项卡视图而不更新输入字段

我尝试过使用一个简单的html字段,但每次投票时都会重新呈现这个字段。 我不能使用ID,因为输入字段在tabview中,我需要更新tabview,因为服务器中的选项卡数量可以更改


谢谢

我找到了一个简单而伟大的解决方案,在p:poll中添加resetValues=“false”:

<p:poll resetValues="false" interval="3" listener="#{counterView.increment}" update="txt_count" />


谢谢

但我需要更新tabview集合,tabview将所有组件分组……我是否应该保存bean类上的每个输入字段更改?“我是否应该保存bean类上的每个输入字段更改?”归结起来就是。。。使用ajax实现它。。。也许用推而不是拉更好。只有在有需要更新的内容时才需要更新。每2秒更新一个聚焦的
inputField
不是一个好主意:每次光标都会跳转。我会考虑将div <代码> divaNeDebug >代码>从<代码> < /代码>中移出。您应该能够使用tabChange事件跟踪活动选项卡,从而允许向活动选项卡发送新消息。