0

在我的 JEE 应用程序中,我有一个电子邮件列表提取过程。我需要显示一个在将邮件添加到列表后递增的计数器。这个想法是显示这个列表的大小,并使用 primeface poll 每 1 秒更新一次。我是这样处理的:

电子邮件提取.xhtml:

<h:body>
    <h:form>
        <h:panelGroup id="formblock" style="margin-top: 40px" layout="block" >
            <p:panelGrid columns="2">
                <p:outputLabel for="Keyword" value="Keywords: " />  
                <p:inputText id="Keyword"   type="search" requiredMessage="Keyword is required" style="width: 600px"
                             value="#{mailMB.keyword}" required="true" label="Keyword">    
                </p:inputText> 
                  <p:outputLabel for="Emailsnbr" value="Emails amount:" />  
                <p:inputText  id="Emailsnbr"   requiredMessage="Emails number is required" style="width: 590px"
                              value="#{mailMB.number}" required="true" label="Emailsnbr"> 
                </p:inputText> 
            </p:panelGrid>
        </h:panelGroup>
        <p:spacer height="5px" />
        <p:commandButton   value="Start" style="width: 12%;height: 100%"  id="extractbutton" ajax="true" widgetVar="ButtonExtract"
                           actionListener="#{mailMB.searchEmailsRym()}" 
                           styleClass="ui-priority-primary"
                           onstart="blockUIWidget1.show();" oncomplete="play(); blockUIWidget1.hide(); if (args &amp;&amp; !args.validationFailed) freeMails();"> 
        </p:commandButton> 

    </h:form>

                            <p:dialog  widgetVar="blockUIWidget1" header="Hitonclick"  modal="true" resizable="false" closable="false"  >                                
                                <table border="0" style="width: 500px">
                                    <tbody > 
                                        <tr>  
                                            <td>
                                                <p:graphicImage url="pictures/loading81.gif" width="200" height="200" alt="animated-loading-bar"/>
                                            </td>
                                            <td>
                                                <h:form >
                                                    <p:outputLabel value="#{mailMB.count}" id="countOutPut"/>
                                                    <p:poll interval="1" update="countOutPut" listener="#{mailMB.increment}"/>

                                                    <div id="countdown_text">0</div>
                                                    <br></br>
                                                    <p:commandButton ajax="false" style="width: 100px;height: 40px" actionListener="#{mailMB.abortSearch()}"   value="Cancel" styleClass="ui-priority-primary" title="Cancel" oncomplete="clearForm('formcounter'), clearForm('searchForm')"/>  

                                                </h:form>
                                            </td>
                                        </tr>
                                        <div align="right">                                    
                                        </div>
                                    </tbody>
                                </table>
                            </p:dialog>
</h:body>

ManagedBean.java:

 private int count=0;
 public void increment(){
 count=mails.size();
 }
 // count getter & setter

但是计数值没有更新。

4

0 回答 0