I have some problems with PrimeFaces 5.2 and client components update mechanism
I created a web page with a button that triggers a server side method. This method update a List of objects and finally a datatable will be updated with new contents of the List.
<h:form>
...
<p:commandButton value="Add parameters" action="#{adminBean.addParams}"
update=":growl :#{tblSensors.clientId}" />
</h:form>
<h:form>
<p:dataTable id="tblSensors"
var="sensorElem" value="#{adminBean.sensors}"
binding="#{tblSensors}"
>
...
</p:dataTable>
</h:form>
Unfortunatelly when the procedure callback is over, my data table are not updated .. Sincerlly I'm not able to find the problem.
There are no exception in debug phase and I saw nothing in Response data from Firebug.
UPDATE: I saw that when the bean method is called and some variable has been changed; this changes aren't persistent and they are missed every time the method is called
UPDATE 2: as requested, I add the bean code:
@ManagedBean(name="adminBean")
@SessionScoped
public class AdminBean implements Serializable{
private List<Sensor> sensors;
public List<Sensor> getSensors() {
return sensors;
}
public void setSensors(List<Sensor> sensors) {
this.sensors = sensors;
}
//...
@PostConstruct
public void init(){
//...
//initialize sensor list
this.sensors = new ArrayList<Sensor>();
//...
}
//method for adding new sensor
public void addParams(){
try{
//add new sensor element to the list
this.sensors.add(new Sensor(this.param_name,Double.parseDouble(this.min_val),Double.parseDouble(this.max_val),
this.unit, this.selectedChartType, this.selectedFieldType, id_counter++));
}catch(Exception e){
System.out.println("Error "+e.getMessage());
System.out.println("stack "+e.getStackTrace());
}
FacesContext.getCurrentInstance().addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_INFO,"Successful", "New sensor added!"));
}
//...
}
UPDATE 3: fix some namespace errors.