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

    a4j:poll running just once!

    sgthawk

      Hello,
      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?

      <a4j:form>
       <h:panelGrid columns="5" border="2">
       <f:facet name="header">
       <h:outputLabel value="Komponenten" />
       </f:facet>
       <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>
       </a4j:region>
       <h:outputText value="#{component.component.dimension}" />
       </h:panelGrid>
       </a4j:form>


      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){
       System.out.println("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";
       db.executeQuery(query);
       CachedRowSet rst = db.getResult();
       rst.next();
       actualValue.setValue(context, rst.getDouble(2));
       } catch (Exception e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
       }
       }
      
      }


      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?