3 Replies Latest reply on Jul 4, 2007 2:54 PM by Behzad Daghigh

    a4j:poll running just once!

    Behzad Daghigh Newbie

      this my first post :-)

      I use the newst stable version of Richfaces 3.01 and ajax4jsf 1.1.1.
      I use an outputText component to be updated every 5 sec. So i used poll for this. but i does not work properly.It just makes one request which you can see theroughout my Listener binded to actionListener.Here is the code, so whats wrong with it?

       <h:panelGrid columns="5" border="2">
       <f:facet name="header">
       <h:outputLabel value="Komponenten" />
       <h:outputText value="Komponente: " />
       <h:outputText value="#{component.component.bez}" />
       <h:outputText value="#{component.component.valueTypeMapping}" />
       <a4j:region >
       <h:outputText id="a" value="#{component.component.actualValue}">
       <a4j:poll enabled="#{component.poll}" interval="5000" reRender="a"
       actionListener="#{component.dataDB}" />
       <h:outputText value="#{component.component.dimension}" />

      The BEAN:
      public class ComponentBean {
       private AnalogInput component;
       private boolean poll;
       public boolean isPoll() {
       return poll;
       public void setPoll(boolean poll) {
       this.poll = poll;
       public AnalogInput getComponent() {
       return component;
       public void setComponent(AnalogInput component) {
       this.component = component;
       public void dataDB( ActionEvent event){
       FacesContext context = FacesContext.getCurrentInstance();
       Application app = context.getApplication();
       ValueBinding actualValue = app.createValueBinding("#{component.component.actualValue}");
       Map valueType = DBValueTypeMapping.getDbMapping();
       DBValueTypeMapping.value dbBase= (value) valueType.get(component.getValueTypeMapping());
       DBWrapper db=null;
       try {
       db = new DBWrapper();
       String query= "select dt,mw from "+dbBase.toString()+" where sysid=1 and kmpid= "+component.getId()+" order by dt desc Limit 1";
       CachedRowSet rst = db.getResult();
       actualValue.setValue(context, rst.getDouble(2));
       } catch (Exception e) {
       // TODO Auto-generated catch block

      tThe component bean is at first unintialized, if i set the enabled attribute to true, i obviously get NullPointerException, but thats ok, because the user
      previously chooses data, so it wont happen, but what it makes me wondering is, with the NullpointerException, the request is done every 5 sec.....
      So why does it not work when the bean is properly initialized?