I am developing an application using java and PrimeFaces. Below is the java code i have written:
class ShowRecordsManagedBean{
private List<RecordDTO> recordInfoList = null;
...
..
public List<RecordDTO> getRecordList() {
boolean flag=true;
try {
if(dataList==null){
//logic here
flag=false;
}
if(dataList!=null && flag){
//Logic here
}
} catch (Exception e) {
}
return dataList;
}
Issue is when page loads each time the control has to go the below if condition:
if(dataList==null){
//logic here
flag=false;
}
But only for the time time, its going to the above mentioned if(..) condition, later even if i refresh the page its going to other if(..) present.
if(dataList!=null && flag){
//Logic here
}
How to modify the condition , that each time when i refresh the page it has to go to first if(..) condition, basically the object values are not becoming null even when page loads.I initialized all object to null initally while declaring. I need to close the browser or delete the cache to make control enter into other if(dataList!=null && flag) condition.
Modified as below:
@ManagedBean
@ViewScoped
public class ShowRecordsManagedBean {
//fields declaration
private List<RecordsDTO> recordInfoList = null;
@PostConstruct
public void init() {
recordInfoList = null;
}
//getters, setters and other methods...
public List<RecordDTO> getRecordList(){
..
}
}
Still the problem not yet solved. When i refresh the page dataList should become null, but its holding previous value. Please suggest. Thanks.