public void postConstruct() { cmbTipoNotificacion.setCodigoLista(Constante.LISTA.CODIGO.TIPO_NOTI); cmbTipoNotificacion.setInputPrompt("Tipo Notificacion"); cmbEstadoNotificacion.setCodigoLista(Constante.LISTA.CODIGO.ESTADO_NOTI); cmbEstadoNotificacion.setInputPrompt("Estado Notificacion"); List<Dependencia> dependencias = dependenciaService.buscar(null); BeanItemContainer<Dependencia> containerDependencia = new BeanItemContainer<Dependencia>(Dependencia.class, dependencias); cmbUnidadProcuraduria.setContainerDataSource(containerDependencia); cmbUnidadProcuraduria.setItemCaptionPropertyId("nombre"); cmbUnidadProcuraduria.setInputPrompt("Unidad Procuraduria"); dtFechaRecepcion.setInputPrompt("Fecha Recepcion Notificacion"); dtFechaVencimiento.setInputPrompt("Fecha Vencimiento PRI"); dtFechaPlazo.setInputPrompt("Fecha Plazo Fundamentar"); btnGuardar.addListener(this); cargarDatos(); }
@Override public void postConstruct() { flagNuevoUsuario = true; btnCrearUsuario.setIcon(Constante.ICONOS.SAVE); btnEliminarUsuario.setIcon(Constante.ICONOS.DELETE); btnAgregarPolicia.setIcon(Constante.ICONOS.CREATE); lstRoles = rolService.buscar(null); BeanItemContainer<Rol> bicRoles = new BeanItemContainer<Rol>(Rol.class, lstRoles); cmbRol.setInputPrompt("Rol"); cmbRol.setContainerDataSource(bicRoles); cmbRol.setItemCaptionPropertyId("nombre"); cmbRol.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS); cmbRol.setImmediate(true); cmbRol.addListener((ValueChangeListener) this); lstPolicias = policiaService.buscar(null); BeanItemContainer<Policia> bicPolicias = new BeanItemContainer<Policia>(Policia.class, lstPolicias); cmbPolicia.setInputPrompt("Policia"); cmbPolicia.setContainerDataSource(bicPolicias); cmbPolicia.setItemCaptionPropertyId("nombreCompleto"); cmbPolicia.setImmediate(true); cmbPolicia.addListener( new ValueChangeListener() { private static final long serialVersionUID = 4418094011985520491L; @Override public void valueChange(ValueChangeEvent event) { pintarPersona(event); } private void pintarPersona(ValueChangeEvent event) { if (cmbPolicia.getValue() != null) { Policia policia = (Policia) cmbPolicia.getValue(); txtApellidoPaterno.setValue(policia.getPersona().getApePaterno()); txtApellidoMaterno.setValue(policia.getPersona().getApeMaterno()); txtNombres.setValue(policia.getPersona().getNombres()); txtCargo.setValue( policia.getCargo() != null ? policia.getCargo().getNombre() : StringUtils.EMPTY); } } }); cmbPolicia.addListener((ValueChangeListener) this); cmbOficina.setItemCaptionPropertyId("nombre"); cmbOficina.setInputPrompt("Oficina"); lstDependencias = dependenciasService.buscar(null); BeanItemContainer<Dependencia> bicDependencias = new BeanItemContainer<Dependencia>(Dependencia.class, lstDependencias); cmbOficina.setContainerDataSource(bicDependencias); cmbOficina.setFilteringMode(Filtering.FILTERINGMODE_CONTAINS); cmbOficina.setImmediate(true); cmbOficina.addListener((ValueChangeListener) this); tblUsuarios.setSelectable(true); tblUsuarios.setImmediate(true); tblUsuarios.setNullSelectionAllowed(true); tblUsuarios.setNullSelectionItemId(null); habilitarBoton(false); btnCrearUsuario.addListener((ClickListener) this); btnEliminarUsuario.addListener((ClickListener) this); btnAgregarPolicia.addListener((ClickListener) this); tblUsuarios.addListener( new ValueChangeListener() { private static final long serialVersionUID = -6124596484581515359L; @Override public void valueChange(ValueChangeEvent event) { boolean esModoNuevo = tblUsuarios.getValue() == null; habilitarBoton(!esModoNuevo); limpiar(); if (esModoNuevo) { tblUsuarios.setValue(null); habilitarEdicion(esModoNuevo); } else { Item item = tblUsuarios.getItem(tblUsuarios.getValue()); clave = item.getItemProperty("clave").getValue().toString(); txtUsuario.setValue(item.getItemProperty("usuario").getValue()); txtNombres.setValue(item.getItemProperty("nombres").getValue()); txtApellidoPaterno.setValue(item.getItemProperty("apePat").getValue()); txtApellidoMaterno.setValue(item.getItemProperty("apeMat").getValue()); cmbPolicia.select(item.getItemProperty("policia").getValue()); cmbOficina.select(item.getItemProperty("dependencia").getValue()); cmbRol.select(item.getItemProperty("rol").getValue()); txtCargo.setValue( item.getItemProperty("cargo").getValue() != null ? item.getItemProperty("cargo").getValue() : StringUtils.EMPTY); txtCargoDescripcion.setValue( item.getItemProperty("descCargo").getValue() != null ? item.getItemProperty("descCargo").getValue() : StringUtils.EMPTY); habilitarEdicion(esModoNuevo); } } }); txtFiltroUsuario.addShortcutListener( new ShortcutListener("", KeyCode.ENTER, null) { private static final long serialVersionUID = 4068232062569621771L; @Override public void handleAction(Object sender, Object target) { shortCutEnter(sender, target); } }); txtFiltroNombres.addShortcutListener( new ShortcutListener("", KeyCode.ENTER, null) { private static final long serialVersionUID = 4068232062569621771L; @Override public void handleAction(Object sender, Object target) { shortCutEnter(sender, target); } }); txtFiltroApePaterno.addShortcutListener( new ShortcutListener("", KeyCode.ENTER, null) { private static final long serialVersionUID = 4068232062569621771L; @Override public void handleAction(Object sender, Object target) { shortCutEnter(sender, target); } }); txtFiltroApeMaterno.addShortcutListener( new ShortcutListener("", KeyCode.ENTER, null) { private static final long serialVersionUID = 4068232062569621771L; @Override public void handleAction(Object sender, Object target) { shortCutEnter(sender, target); } }); txtFiltroCargo.addShortcutListener( new ShortcutListener("", KeyCode.ENTER, null) { private static final long serialVersionUID = 4068232062569621771L; @Override public void handleAction(Object sender, Object target) { shortCutEnter(sender, target); } }); txtFiltroOficina.addShortcutListener( new ShortcutListener("", KeyCode.ENTER, null) { private static final long serialVersionUID = 4068232062569621771L; @Override public void handleAction(Object sender, Object target) { shortCutEnter(sender, target); } }); txtUsuario.setImmediate(true); txtNombres.setImmediate(true); txtApellidoPaterno.setImmediate(true); txtApellidoMaterno.setImmediate(true); txtCargo.setImmediate(true); txtFiltroOficina.setImmediate(true); txtUsuario.addListener((TextChangeListener) this); txtNombres.addListener((TextChangeListener) this); txtApellidoPaterno.addListener((TextChangeListener) this); txtApellidoMaterno.addListener((TextChangeListener) this); txtCargo.addListener((TextChangeListener) this); txtFiltroOficina.addListener((TextChangeListener) this); lstUsuarios = usuarioService.buscar(null); cargarUsuarios(lstUsuarios, true); }