0
PrimeFaces (5.3)에서 지연 데이터 테이블을 구현하려고하지만 테이블을 렌더링하지 않습니다. 문제는 게으른 모델 클래스의 load() 메서드가 결코 호출되지 않는다는 것입니다. 테이블은 String의 arrayList로부터 빌드되며 각 String [] (길이 5)은 테이블의 행입니다.Primefaces 게으른 데이터 테이블이 비어 있습니다.
보기 (관련 코드)
<h:form id="formHome">
<p:commandButton process="@this" partialSubmit="true" update="@form"
value="obtener tabla"
actionListener="#{mbParametros.init}"
oncomplete="location.reload();">
</p:commandButton>
<p:dataTable id="parametros"
selection="#{mbParametros.lazy.seleccionados}"
rowKey="#{registro[0]}" value="#{mbParameros.lazy}" var="registro"
paginator="true" lazy="true" rows="15" selectionMode="single "
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="15,30,45" resizableColumns="false"
widgetVar="tabla">
<p:ajax event="page" oncomplete="location.reload();" />
<f:facet name="header">
<h:outputText value="Parametros, Fechas y Etiquetas" />
</f:facet>
<!-- COLUMNA DE CHECKBOXES -->
<p:column selectionMode="multiple" />
<!-- COLUMNA DEL ENTORNO GEOGRAFICO -->
<p:column id="col0" headerText="#{mbParametros.lazy.header}">
<h:outputText value="#{registro[0]}" />
</p:column>
<!-- COLUMNA DEL TIPO DE PARAMETRO -->
<p:column id="col1" headerText="Tipo">
<h:outputText value="#{registro[1]}" />
</p:column>
<!-- COLUMNA DEL NOMBRE DEL PARAMETRO -->
<p:column id="col2" headerText="Parametro">
<h:outputText value="#{registro[2]}" />
</p:column>
<!-- COLUMNA DEL VALOR DEL PARAMETRO -->
<p:column id="col3" headerText="Valor">
<h:outputText value="#{registro[3]}" />
</p:column>
<!-- COLUMNA DE LA DESCRIPCION DEL PARAMETRO -->
<p:column id="col4" headerText="Descripcion">
<h:outputText value="#{registro[4]}" />
</p:column>
</p:dataTable>
</h:form>
컨트롤러 (봄 컨트롤러, 주요 봄 3.2.16로 설정 한)
@Scope("session")
@Controller("mbParametros")
public class MBParametros implements Serializable {
private static final Logger LOG = LoggerFactory.getLogger(MBParametros.class);
private static final long serialVersionUID = 1L;
@Autowired
private ResourceBundleMessageSource recursos;
private LazyDataModel<String[]> lazy;
public void init() {
LOG.info("ENTRA AL INIT");
this.setLazy(new ModeloLazy(recursos) {
private static final long serialVersionUID = 1L;
});
}
public LazyDataModel<String[]> getLazy() {
return lazy;
}
public void setLazy(LazyDataModel<String[]> lazy) {
this.lazy = lazy;
}
게으른 모델 클래스 (관련 코드 만)
public class ModeloLazy extends LazyDataModel<String[]> {
// ArrayList of Strings that represent all table rows
private List<String[]> tabla;
public List<String[]> getTabla() {
return tabla;
}
public void setTabla(List<String[]> tabla) {
this.tabla = tabla;
}
// all other fields, getters, setters, init, etc.....
// constructor
public ModeloLazy(ResourceBundleMessageSource recursos) {
this.recursos = recursos;
this.init();
}
// load never gets called by the framework, so its an error somewhere else
@Override
public List<String[]> load(int first, int pageSize, String sortField, SortOrder sortOrder, Map<String, Object> filters) {
this.setRowCount(15);
return this.getTabla();
}
// init() calls this method for building the table
// after execution, tabla is not null nor empty.
private void construir(DTOResponse result, DTORequest request) {
List<DTORegistro> registros = bsd.join(result, request); //OK
for (DTORegistro dtoRegistro : registros) {
String tipo;
switch(dtoRegistro.getParametro().getTipo()) {
case 'p':
tipo = "Parametro";
break;
case 'e':
tipo = "Etiqueta";
break;
default:
tipo = "Fecha";
}
String[] reg = {dtoRegistro.getDto().getNombre() + tipo
+ dtoRegistro.getParametro().getValor() + dtoRegistro.getParametro().getDescripcion()};
this.getTabla().add(reg);
}
}
}
이것은 PF 쇼케이스에서 볼 수 있습니다! – Kukeltje