Escribiendo Codgo en Java sin
list.xhtml
new.xhtml
view.xhtml
CONTROLLER
@Named
@ViewScoped
@Getter
@Setter
public class RolController implements Serializable, IController {
// <editor-fold defaultstate="collapsed" desc="fields">
private static final long serialVersionUID = 1L;
private Boolean writable = false;
//DataModel
private RolDataModel rolDataModel;
Integer page = 1;
Integer rowPage = 25;
List<Integer> pages = new ArrayList<>();
//Entity
Rol rol = new Rol();
Rol rolSelected;
Rol rolSearch = new Rol();
//List
List<Rol> rolList = new ArrayList<>();
//Repository
@Inject
RolRepository rolRepository;
//Services
@Inject
AutoincrementableServices autoincrementableServices;
@Inject
ErrorInfoServices errorServices;
@Inject
RolServices rolServices;
@Inject
ResourcesFiles rf;
@Inject
Printer printer;
//List of Relations
//Repository of Relations
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="getter/setter">
public List<Integer> getPages() {
return rolRepository.listOfPage(rowPage);
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="constructor">
public RolController() {
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="init">
@PostConstruct
public void init() {
try {
/*
configurar el ambiente del controller
*/
HashMap parameters = new HashMap();
Usuario jmoordb_user = (Usuario) JmoordbContext.get("jmoordb_user");
// parameters.put("P_EMPRESA", jmoordb_user.getEmpresa().getDescripcion());
JmoordbControllerEnvironment jmc = new JmoordbControllerEnvironment.Builder()
.withController(this)
.withRepository(rolRepository)
.withEntity(rol)
.withService(rolServices)
.withNameFieldOfPage("page")
.withNameFieldOfRowPage("rowPage")
.withSearchbysecondarykey(false)
.withPathReportDetail("/resources/reportes/rol/details.jasper")
.withPathReportAll("/resources/reportes/rol/all.jasper")
.withparameters(parameters)
.build();
start();
} catch (Exception e) {
errorServices.errorMessage(nameOfClass(), nameOfMethod(), e.getLocalizedMessage());
}
}// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="handleSelect">
public void handleSelect(SelectEvent event) {
try {
} catch (Exception e) {
errorServices.errorMessage(nameOfClass(), nameOfMethod(), e.getLocalizedMessage());
}
}// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="move(Integer page)">
@Override
public void move(Integer page) {
try {
this.page = page;
rolDataModel = new RolDataModel(rolList);
Document doc;
switch ((String) JmoordbContext.get("searchrol")) {
case "_init":
case "_autocomplete":
rolList = rolRepository.findPagination(page, rowPage);
break;
case "idrol":
if (JmoordbContext.get("_fieldsearchrol") != null) {
rolSearch.setIdrol(JmoordbContext.get("_fieldsearchrol").toString());
doc = new Document("idrol", JmoordbContext.get("_fieldsearchrol").toString());
rolList = rolRepository.findPagination(doc, page, rowPage, new Document("idrol", -1));
} else {
rolList = rolRepository.findPagination(page, rowPage);
}
break;
case "activo":
if (JmoordbContext.get("_fieldsearchrol") != null) {
rolSearch.setActivo(JmoordbContext.get("_fieldsearchrol").toString());
doc = new Document("activo", rolSearch.getActivo());
rolList = rolRepository.findPagination(doc, page, rowPage, new Document("idrol", -1));
} else {
rolList = rolRepository.findPagination(page, rowPage);
}
break;
default:
rolList = rolRepository.findPagination(page, rowPage);
break;
}
rolDataModel = new RolDataModel(rolList);
} catch (Exception e) {
errorServices.errorMessage(nameOfClass(), nameOfMethod(), e.getLocalizedMessage());
}
}// </editor-fold>
}
Comentarios
Publicar un comentario