2 Replies Latest reply on Dec 18, 2009 5:33 AM by jsfgeeks

    Problem in polling

    jsfgeeks

      Hi all,

       

      I am trying to use polling in my application. What I am doing is, I have a textfield in which I sets the value from JS. It works well. I want that value from the backbean via polling. I can do it also. At that place the problem is, if I place that textfield outside of the polling form, then it can't get the value in backbean. But, if I put that textfield in the same form in which the a4j:poll is located, then it works fine. That also ok. But my main issue is like after getting the value of textfield, I want to clear that textfield, I am trying to clear the value, but no luck.

       

      My jsp code is something like below,

       

      <a4j:region>
                  <h:form>
                      <a4j:poll id="poll" interval="3000" enabled="true" reRender="poll,test">
                          <a4j:support event="oncomplete" action="#{poll_test.test_polling}"/>
                      </a4j:poll>
                      <h:inputText id="test" binding="#{poll_test.test}" value="#{poll_test.txt_value}" style="left: 50px; top: 100px; position: absolute"/>
                  </h:form>
              </a4j:region>
              <h:form id="form1">
                  <h:outputText value="#{poll_test.txt_value}" style="left: 50px; top: 150px; position: absolute"/>
              </h:form>

       

      And my backbean function is like below,

       

      public String test_polling()
          {
              System.out.println("\n\t Test Polling called...");
              if(txt_value!=null && txt_value.length()>0)
              {
                  System.out.println("\n\t The value of textfield is : "+txt_value);
                  txt_value = "";
                  test.setValue("");
                  System.out.println("\n\t test.getValue : "+test.getValue());
              }
              return null;
          }

       

      So, basically I want that whenever the polling function gets the value from the textfield, and enter it in db and then clear it at that time.

       

      Any help will be appreciated.

       

      Thanks in advance,

      JSF GEEKS

        • 1. Re: Problem in polling
          yyq2009

              Hi, jsf geeks, I think you should do it like this:

           

          <a4j:region>
                      <h:form>
                          <a4j:poll id="poll" interval="3000" action="#{poll_test.test_polling}" enabled="true" reRender="poll,test">
                          </a4j:poll>
                          <h:inputText id="test" binding="#{poll_test.test}" value="#{poll_test.txt_value}" style="left: 50px; top: 100px; position: absolute"/>
                      </h:form>
                  </a4j:region>
                  <h:form id="form1">
                      <h:outputText value="#{poll_test.txt_value}" style="left: 50px; top: 150px; position: absolute"/>
                  </h:form>

          Or

           

          <a4j:region>
                      <h:form>
                          <a4j:poll id="poll" interval="3000" enabled="true" reRender="poll,test">
                              <a4j:support event="oncomplete" action="#{poll_test.test_polling}" reRender="test"/>
                          </a4j:poll>
                          <h:inputText id="test" binding="#{poll_test.test}" value="#{poll_test.txt_value}" style="left: 50px; top: 100px; position: absolute"/>
                      </h:form>
                  </a4j:region>
                  <h:form id="form1">
                      <h:outputText value="#{poll_test.txt_value}" style="left: 50px; top: 150px; position: absolute"/>
                  </h:form>

           

          Maybe it can work for you.

          Good luck.

          • 2. Re: Problem in polling
            jsfgeeks

            Thanks Daniel,

             

            It's working. Cooooooool...

             

            Thanks for your time and reply,

            JSF GEEKS