How to get the value of the lazy attribute of the first datatable in the Bean?

4

To get the value of the selectionMode attribute of the datatable (primefaces) in MB:

DataTable dt = (DataTable) FacesContext.getCurrentInstance().getViewRoot().findComponent("IdForm:IdDataTable");
String sm = dt.getSelectionMode();

And how do I get the value of the lazy attribute?

    
asked by anonymous 16.04.2015 / 16:45

1 answer

2

To get any attribute of a JSF component you just need to have an instance of type UIComponent of it, which with the method getAttributes() returns any desired attribute by passing only a key to the Map<String, Object> returned.

For your problem it can be used like this:

UIComponent dt = FacesContext.getCurrentInstance().getViewRoot().findComponent("IdForm:IdDataTable");
boolean lazy = (boolean)dt.getAttributes().get("lazy"));
    
25.04.2015 / 19:37