0

In my JEE application, I have an emails list extraction process. I need to display a counter which be incremented after adding a mail to the list. The idea is to display the size of this list and update it every 1 seconde using primeface poll. I procced like this:

EmailsExtraction.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

But the count value is not updated.

Reem
  • 169
  • 1
  • 4
  • 15
  • @user1983983 the mails extraction method works very well and all mails are persisted in my data base with succes, I have only this problem of dislpaying the list size in real time. – Reem Mar 31 '14 at 14:06
  • Is there another form wrapping the `commandButton` and the `dialog`? Check the browser console and see if there are requests going out and if check the respones which are coming in. – user1983983 Mar 31 '14 at 14:09
  • the commandButton is wrapped by the main form with some inputTexts and the dialog is aside. – Reem Mar 31 '14 at 14:13
  • @Susanna - an `` should not be contained in another ``, i.e. no nested forms – kolossus Apr 01 '14 at 05:25
  • @kolossus no nested forms in my xhtml page. There are two forms: the first contains inputTexts and the commandButton and the second inside the modal dialog. – Reem Apr 01 '14 at 07:53
  • Please show the second form here @Susanna – kolossus Apr 01 '14 at 11:44
  • @kolossus please check update. – Reem Apr 01 '14 at 13:57
  • None of this looks right. Why is `dlgPoll` followed by another `` after you'd previously closed the body tag? – kolossus Apr 01 '14 at 14:59
  • @kolossus it's just a copy paste mistake :) – Reem Apr 01 '14 at 15:11
  • If you're sure the method is being executed, look in the network tab in your browser's developer tools console for clues as to what's wrong with the response to the ajax request @Susanna – kolossus Apr 01 '14 at 16:43

0 Answers0