DataModel

Crear los DataModel:

  • BodegaDataModel

  • ColorDataModel

  • PaisDataModel

BodegaDataModel

import com.avbravo.microtestingejb.entity.Bodega;
import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;
/**
*
* @author avbravo
*/
public class BodegaDataModel extends ListDataModel<Bodega> implements SelectableDataModel<Bodega>{
public BodegaDataModel() {
}
public BodegaDataModel(List<Bodega>data) {
super(data);
}
@Override
public Bodega getRowData(String rowKey) {
List<Bodega> bodegaList = (List<Bodega>) getWrappedData();
for (Bodega bodega : bodegaList) {
if (bodega.getIdbodega().equals(rowKey)) {
return bodega;
}
}
return null;
}
@Override
public Object getRowKey(Bodega bodega) {
return bodega.getIdbodega();
}
}

ColorDataModel

import com.avbravo.microtestingejb.entity.Color;
import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;
/**
*
* @author avbravo
*/
public class ColorDataModel extends ListDataModel<Color> implements SelectableDataModel<Color>{
public ColorDataModel() {
}
public ColorDataModel(List<Color>data) {
super(data);
}
@Override
public Color getRowData(String rowKey) {
List<Color> colorList = (List<Color>) getWrappedData();
for (Color color : colorList) {
if (color.getIdcolor().equals(rowKey)) {
return color;
}
}
return null;
}
@Override
public Object getRowKey(Color color) {
return color.getIdcolor();
}
}

PaisDataModel

import com.avbravo.microtestingejb.entity.Pais;
import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;
/**
*
* @author avbravo
*/
public class PaisDataModel extends ListDataModel<Pais> implements SelectableDataModel<Pais>{
public PaisDataModel() {
}
public PaisDataModel(List<Pais>data) {
super(data);
}
@Override
public Pais getRowData(String rowKey) {
List<Pais> paisList = (List<Pais>) getWrappedData();
for (Pais pais : paisList) {
if (pais.getIdpais().equals(rowKey)) {
return pais;
}
}
return null;
}
@Override
public Object getRowKey(Pais pais) {
return pais.getIdpais();
}
}