【问题标题】:Adding PrimeFaces notificationBar makes my code stop working添加 PrimeFaces 通知栏使我的代码停止工作
【发布时间】:2012-04-20 19:59:59
【问题描述】:

PrimeFaces 的 NotificationBar 有一个奇怪的问题。

我的代码可以正常工作,但是添加 NotificationBar 会使它以一种奇怪的方式运行!

我在 DataTable 中显示来自会话 Bean 的数据。 一切都很好,但是,一旦我添加了这个 NotificationBar,数据表就会变空并且没有内容被获取:/

这里有一些代码:

<!-- NOTIFICATION BAR headerMain.xhtml -->
    <h:form>
        <pou:poll autoStart="#{loginBean.logged}" global="false" interval="5" oncomplete="notificationBar.toggle()" update=":notificationBar"/>
    </h:form>


    <pou:notificationBar effect="slide" id="notificationBar" rendered="#{messagesBean.checkDaNotificare()}" widgetVar="notificationBar">                            
        <h:outputLink value="./faces/messaggi.xhtml">                                        
            <h:outputText value="Hai 1 messaggio da leggere" rendered="#{messagesBean.daNotificare==1}"/>
            <h:outputText value="Hai #{messagesBean.daNotificare} messaggi da leggere" rendered="#{messagesBean.daNotificare > 1}"/>
        </h:outputLink> 
    </pou:notificationBar>

_

<!-- DATATABLE IN messaggi.xhtml -->
<pou:dataTable editable="false" id="conversationList" resizableColumns="false" rowKey="#{conversazione}" selection="#{messagesBean.destinatario}" selectionMode="single" value="#{messagesBean.listaConversazioni}" var="conversazione" widgetVar="conversationList" paginator="true" paginatorPosition="bottom" rows="20">
                        <pou:ajax event="rowSelect" oncomplete="conversationDialog.show()" update=":conversationDialog, :menuPanel"/>
                        <pou:column>
                            <f:facet name="header">
                                <div style="padding-left: 45%">
                                    <h:outputText value="Conversazioni"/>                                                                                                                            
                                    <h:form>
                                        <pou:commandButton value="+" onclick="newMessageDialog.show()" style="margin-left: 67%"/>
                                    </h:form>
                                </div>
                            </f:facet>
                            <h:outputText value="#{conversazione.username}"/>
                        </pou:column>
                    </pou:dataTable>

_

//Method used by NotificationBar to see if it has to be rendered
public boolean checkDaNotificare() {
    System.err.println(daNotificare);
    daNotificare = 0; //Riazzero, quelli precedenti li avrò già notificati
    for (Messaggio m : getMessaggiDaLeggere()) {
        System.err.println("Controllo " + m);
        if (!messaggiNotificati.contains(m)) { //Conto i messaggi da notificare, che sono quelli da leggere meno quelli già notificati
            System.err.println("___Non l'avevo ancora notificato!");
            daNotificare++;
            messaggiNotificati.add(m);
        }
    }
    return (daNotificare > 0);
}

_

//Method used by the datatable to fetch data
public List<Utente> getListaConversazioni() {
    listaConversazioni = messageManager.getUtentiConversazioni(utente);
    return listaConversazioni;
}

/**
 * PostConstruct method to initialize things
 */
@PostConstruct
public void init() {
    listaConversazioni = messageManager.getUtentiConversazioni(utente);
    messaggiNotificati = new LinkedList<>();
}

我留下了意大利语的代码,因为它很简单,因为它没有做任何“特别”的事情。

我做错了什么?我几乎尝试了所有方法,但没有成功:(

提前致谢!

编辑: 我试过将notificationBar的代码移到另一个页面,一切正常……事情变得很奇怪;/

【问题讨论】:

  • 只是一个猜测,也许它与 ./faces/messaggi.xhtml" 的相对路径有关?在其他页面上可以,但在第一个页面上不行?
  • 不,这只是一个链接...仍然无法弄清楚问题是什么,但即使 NotificationBar 为空,我也能解决
  • 您好,您解决了这个问题吗?我有类似的行为.... thnx

标签: jsf datatable primefaces ejb


【解决方案1】:

StepTNT...我相信您需要在数据表中指定filteredValue。通常你在 filtersValue 中设置一个新的 ArrayList() 实例,但最近我遇到了这个问题,它对我来说用 filtersValue 没有任何实例。

【讨论】:

  • 你好 Darkness,在 Stack Overflow 上,最佳答案包含代码以及该代码如何解决问题的说明。任何低于此值的帖子都可能是噪音。考虑使用edit 来改进这篇文章。祝你好运! :)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-05-16
  • 2018-05-13
  • 1970-01-01
  • 1970-01-01
  • 2019-09-25
  • 2012-12-09
  • 1970-01-01
相关资源
最近更新 更多