JSF2使用Ajax重新呈现/更新ui:重复列表

时间:2022-12-24 20:10:16

I have a ui:repeat list which pulls a bunch of values off my DB & I use it in a jQuery based news-ticker. I am trying to get this list to update/re-render via ajax periodically as I am effectively displaying the latest news entries into my db, using the primefaces p:poll method.

我有一个ui:重复列表,从我的数据库中提取了一堆值,我在基于jQuery的新闻自动收录器中使用它。我正在尝试通过ajax定期更新/重新呈现此列表,因为我使用primefaces p:poll方法有效地将最新的新闻条目显示到我的数据库中。

Alternatively I already have a p:poll ajax function working already, that polls the number of items I have stored in my db, which I would like to link to my ui:repeat list to update based on this figure changing, but for now I am simply trying to get it to update!

或者我已经有ap:poll ajax函数已经工作,它会轮询我存储在我的数据库中的项目数,我想链接到我的ui:重复列表,根据这个数字更改更新,但是现在我是只是想让它更新!

Here is how the ui:repeat list is compiled:

以下是编译ui:repeat列表的方法:

                        <h:form>
                        <div id="ticker-wrapper" class="no-js">
                            <ui:repeat id="newsTickerList" value="#{dbWidgetBean.latestNewsList}" var="newsItem">           
                                <ul id="js-news" class="js-hidden">

                                    <li class="news-item">                                               
                                        <h:outputLink  value="#{newsItem.rssLink}" target="_blank">
                                            <b><h:outputText value="#{newsItem.indexName}: "/></b>
                                            <h:outputText value="#{newsItem.testFeedLatest}"/>
                                        </h:outputLink>
                                    </li>

                                </ul>
                            </ui:repeat>
                        </div>
                        <p:poll interval="60" listener="#{dbWidgetBean.latestNewsList}" update="newsTickerList"/>
                    </h:form>

I have tried various derivatives of the above code & the list is built fine within the @PostConstruct element, but I cant get the list to update!

我已经尝试了上述代码的各种衍生产品,并且列表在@PostConstruct元素中构建得很好,但我无法让列表更新!

Any help would be greatly appreciated!

任何帮助将不胜感激!

Cheers

1 个解决方案

#1


0  

Have you tried updating the surrounding div "ticker-wrapper" tag? If that doesn't work, replace the div with p:outputPanle and update that.

你有没有尝试更新周围的div“ticker-wrapper”标签?如果这不起作用,请用p:outputPanle替换div并更新它。

#1


0  

Have you tried updating the surrounding div "ticker-wrapper" tag? If that doesn't work, replace the div with p:outputPanle and update that.

你有没有尝试更新周围的div“ticker-wrapper”标签?如果这不起作用,请用p:outputPanle替换div并更新它。