git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/AdmVenta/Web/trunk/ventaboletos@54935 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
5124c67b82
commit
ddb3349189
|
@ -0,0 +1,123 @@
|
|||
package com.rjconsultores.ventaboletos.web.gui.controladores.catalogos;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.GrupoCategoria;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.paginacion.HibernateSearchObject;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.paginacion.PagedListWrapper;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.render.RenderGrupoCategoria;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.zkoss.util.resource.Labels;
|
||||
import org.zkoss.zhtml.Messagebox;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zul.Paging;
|
||||
import org.zkoss.zul.Textbox;
|
||||
|
||||
@Controller("busquedaGrupoCategoriaController")
|
||||
@Scope("prototype")
|
||||
public class BusquedaGrupoCategoriaController extends MyGenericForwardComposer {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Autowired
|
||||
private transient PagedListWrapper<GrupoCategoria> plwGrupoCategoria;
|
||||
private MyListbox grupoCategoriaList;
|
||||
private Paging pagingGrupoCategoria;
|
||||
private Textbox txtDesc;
|
||||
|
||||
public Paging getPagingGrupoCategoria() {
|
||||
return pagingGrupoCategoria;
|
||||
}
|
||||
|
||||
public void setPagingGrupoCategoria(Paging pagingGrupoCategoria) {
|
||||
this.pagingGrupoCategoria = pagingGrupoCategoria;
|
||||
}
|
||||
|
||||
public MyListbox getGrupoCategoriaList() {
|
||||
return grupoCategoriaList;
|
||||
}
|
||||
|
||||
public void setGrupoCategoriaList(MyListbox grupoCategoriaList) {
|
||||
this.grupoCategoriaList = grupoCategoriaList;
|
||||
}
|
||||
|
||||
public PagedListWrapper<GrupoCategoria> getPlwGrupoCategoria() {
|
||||
return plwGrupoCategoria;
|
||||
}
|
||||
|
||||
public void setPlwGrupoCategoria(PagedListWrapper<GrupoCategoria> plwGrupoCategoria) {
|
||||
this.plwGrupoCategoria = plwGrupoCategoria;
|
||||
}
|
||||
|
||||
public void onClick$btnPesquisa(Event ev) throws InterruptedException {
|
||||
refreshLista();
|
||||
}
|
||||
|
||||
public void onClick$btnRefresh(Event ev) {
|
||||
refreshLista();
|
||||
}
|
||||
|
||||
public void onClick$btnNovo(Event ev) {
|
||||
verPeriodo(new GrupoCategoria());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
|
||||
grupoCategoriaList.setItemRenderer(new RenderGrupoCategoria());
|
||||
grupoCategoriaList.addEventListener("onDoubleClick", new EventListener() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
GrupoCategoria c = (GrupoCategoria) grupoCategoriaList.getSelected();
|
||||
verPeriodo(c);
|
||||
}
|
||||
});
|
||||
|
||||
refreshLista();
|
||||
|
||||
txtDesc.focus();
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
private void verPeriodo(GrupoCategoria c) {
|
||||
if (c == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map args = new HashMap();
|
||||
args.put("grupoCategoria", c);
|
||||
args.put("grupoCategoriaList", grupoCategoriaList);
|
||||
args.put("busquedaGrupoCategoriaController", this);
|
||||
|
||||
openWindow("/gui/catalogos/editarGrupoCategoria.zul",
|
||||
Labels.getLabel("editarGrupoCategoriaController.window.title"), args, MODAL);
|
||||
}
|
||||
|
||||
public void refreshLista() {
|
||||
HibernateSearchObject<GrupoCategoria> claseServicioBusqueda =
|
||||
new HibernateSearchObject<GrupoCategoria>(GrupoCategoria.class, pagingGrupoCategoria.getPageSize());
|
||||
|
||||
claseServicioBusqueda.addFilterLike("descGrupo", "%" + txtDesc.getText().trim().concat("%"));
|
||||
claseServicioBusqueda.addFilterEqual("activo", Boolean.TRUE);
|
||||
claseServicioBusqueda.addSortAsc("descGrupo");
|
||||
|
||||
plwGrupoCategoria.init(claseServicioBusqueda, grupoCategoriaList, pagingGrupoCategoria);
|
||||
if (grupoCategoriaList.getData().length == 0) {
|
||||
try {
|
||||
Messagebox.show(Labels.getLabel("MSG.ningunRegistro"),
|
||||
Labels.getLabel("busquedaGrupoCategoriaController.window.title"),
|
||||
Messagebox.OK, Messagebox.INFORMATION);
|
||||
} catch (InterruptedException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,139 @@
|
|||
package com.rjconsultores.ventaboletos.web.gui.controladores.catalogos;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.zkoss.util.resource.Labels;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zul.Messagebox;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.GrupoCategoria;
|
||||
import com.rjconsultores.ventaboletos.service.GrupoCategoriaService;
|
||||
import com.rjconsultores.ventaboletos.utilerias.UsuarioLogado;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyGenericForwardComposer;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyListbox;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.MyTextbox;
|
||||
|
||||
@Controller("editarGrupoCategoriaController")
|
||||
@Scope("prototype")
|
||||
public class EditarGrupoCategoriaController extends MyGenericForwardComposer {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@Autowired
|
||||
private GrupoCategoriaService grupoCategoriaService;
|
||||
|
||||
private GrupoCategoria grupoCategoria;
|
||||
private MyListbox grupoCategoriaList;
|
||||
private static Logger log = Logger.getLogger(EditarGrupoCategoriaController.class);
|
||||
private MyTextbox txtDesc;
|
||||
private BusquedaGrupoCategoriaController busquedaGrupoCategoriaController;
|
||||
|
||||
@Override
|
||||
public void doAfterCompose(Component comp) throws Exception {
|
||||
super.doAfterCompose(comp);
|
||||
grupoCategoria = (GrupoCategoria) Executions.getCurrent().getArg().get("grupoCategoria");
|
||||
grupoCategoriaList = (MyListbox) Executions.getCurrent().getArg().get("grupoCategoriaList");
|
||||
busquedaGrupoCategoriaController = (BusquedaGrupoCategoriaController) Executions.getCurrent().getArg().get("busquedaGrupoCategoriaController");
|
||||
txtDesc.focus();
|
||||
}
|
||||
|
||||
public void onClick$btnSalvar(Event ev) throws InterruptedException {
|
||||
txtDesc.getValue();
|
||||
try {
|
||||
grupoCategoria.setActivo(true);
|
||||
grupoCategoria.setFecmodif(Calendar.getInstance().getTime());
|
||||
grupoCategoria.setUsuarioId(UsuarioLogado.getUsuarioLogado().getUsuarioId());
|
||||
|
||||
if (grupoCategoria.getGrupoCategoriaId() == null) {
|
||||
List<GrupoCategoria> lsGrupoCategoria = grupoCategoriaService.buscar(grupoCategoria.getDescGrupo().trim());
|
||||
|
||||
if (lsGrupoCategoria.isEmpty()) {
|
||||
grupoCategoriaService.suscribir(grupoCategoria);
|
||||
grupoCategoriaList.addItemNovo(grupoCategoria);
|
||||
busquedaGrupoCategoriaController.refreshLista();
|
||||
Messagebox.show(
|
||||
Labels.getLabel("editarCategoriaController.MSG.suscribirOK"),
|
||||
Labels.getLabel("editarCategoriaController.window.title"),
|
||||
Messagebox.OK, Messagebox.INFORMATION);
|
||||
|
||||
} else {
|
||||
Messagebox.show(
|
||||
Labels.getLabel("MSG.Registro.Existe"),
|
||||
Labels.getLabel("editarCategoriaController.window.title"),
|
||||
Messagebox.OK, Messagebox.EXCLAMATION);
|
||||
}
|
||||
} else {
|
||||
grupoCategoriaService.actualizacion(grupoCategoria);
|
||||
grupoCategoriaList.updateItem(grupoCategoria);
|
||||
busquedaGrupoCategoriaController.refreshLista();
|
||||
Messagebox.show(
|
||||
Labels.getLabel("editarCategoriaController.MSG.suscribirOK"),
|
||||
Labels.getLabel("editarCategoriaController.window.title"),
|
||||
Messagebox.OK, Messagebox.INFORMATION);
|
||||
|
||||
}
|
||||
|
||||
closeWindow();
|
||||
} catch (Exception ex) {
|
||||
log.error("editarCategoriaController: " + ex);
|
||||
Messagebox.show(
|
||||
Labels.getLabel("MSG.Error"),
|
||||
Labels.getLabel("editarCategoriaController.window.title"),
|
||||
Messagebox.OK, Messagebox.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public void onClick$btnApagar(Event ev) throws InterruptedException {
|
||||
|
||||
int resp = Messagebox.show(
|
||||
Labels.getLabel("editarCategoriaController.MSG.borrarPergunta"),
|
||||
Labels.getLabel("editarCategoriaController.window.title"),
|
||||
Messagebox.YES | Messagebox.NO, Messagebox.QUESTION);
|
||||
|
||||
if (resp == Messagebox.YES) {
|
||||
|
||||
grupoCategoriaService.borrar(grupoCategoria);
|
||||
busquedaGrupoCategoriaController.refreshLista();
|
||||
|
||||
Messagebox.show(
|
||||
Labels.getLabel("editarCategoriaController.MSG.borrarOK"),
|
||||
Labels.getLabel("editarCategoriaController.window.title"),
|
||||
Messagebox.OK, Messagebox.INFORMATION);
|
||||
|
||||
grupoCategoriaList.removeItem(grupoCategoria);
|
||||
|
||||
closeWindow();
|
||||
}
|
||||
}
|
||||
|
||||
public GrupoCategoria getGrupoCategoria() {
|
||||
return grupoCategoria;
|
||||
}
|
||||
|
||||
public void setGrupoCategoria(GrupoCategoria grupoCategoria) {
|
||||
this.grupoCategoria = grupoCategoria;
|
||||
}
|
||||
|
||||
public MyListbox getGrupoCategoriaList() {
|
||||
return grupoCategoriaList;
|
||||
}
|
||||
|
||||
public void setGrupoCategoriaList(MyListbox grupoCategoriaList) {
|
||||
this.grupoCategoriaList = grupoCategoriaList;
|
||||
}
|
||||
|
||||
public GrupoCategoriaService getGrupoCategoriaService() {
|
||||
return grupoCategoriaService;
|
||||
}
|
||||
|
||||
public void setGrupoCategoriaService(GrupoCategoriaService grupoCategoriaService) {
|
||||
this.grupoCategoriaService = grupoCategoriaService;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.rjconsultores.ventaboletos.web.utilerias.menu.item.catalogos;
|
||||
|
||||
import org.zkoss.util.resource.Labels;
|
||||
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.PantallaUtileria;
|
||||
import com.rjconsultores.ventaboletos.web.utilerias.menu.DefaultItemMenuSistema;
|
||||
|
||||
public class ItemMenuGrupoCategoria extends DefaultItemMenuSistema {
|
||||
|
||||
public ItemMenuGrupoCategoria() {
|
||||
super("indexController.mniGrupoCategoria.label");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClaveMenu() {
|
||||
return "COM.RJCONSULTORES.ADMINISTRACION.GUI.CATALOGO.MENU.GRUPOCATEGORIA";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ejecutar() {
|
||||
PantallaUtileria.openWindow("/gui/catalogos/busquedaGrupoCategoria.zul",
|
||||
Labels.getLabel("busquedaGrupoCategoriaController.window.title"),
|
||||
getArgs() ,desktop);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package com.rjconsultores.ventaboletos.web.utilerias.render;
|
||||
|
||||
import com.rjconsultores.ventaboletos.entidad.GrupoCategoria;
|
||||
|
||||
import org.zkoss.zul.Listcell;
|
||||
import org.zkoss.zul.Listitem;
|
||||
import org.zkoss.zul.ListitemRenderer;
|
||||
|
||||
public class RenderGrupoCategoria implements ListitemRenderer {
|
||||
|
||||
public void render(Listitem lstm, Object o) throws Exception {
|
||||
GrupoCategoria grupoCategoria = (GrupoCategoria) o;
|
||||
|
||||
Listcell lc = new Listcell();
|
||||
|
||||
lc = new Listcell(grupoCategoria.getGrupoCategoriaId().toString());
|
||||
lc.setParent(lstm);
|
||||
|
||||
lc = new Listcell(grupoCategoria.getDescGrupo());
|
||||
lc.setParent(lstm);
|
||||
|
||||
lstm.setAttribute("data", grupoCategoria);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?page contentType="text/html;charset=UTF-8"?>
|
||||
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winBusquedaGrupoCategoria"?>
|
||||
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
|
||||
|
||||
<zk xmlns="http://www.zkoss.org/2005/zul">
|
||||
<window id="winBusquedaGrupoCategoria" title="${c:l('busquedaGrupoCategoriaController.window.title')}"
|
||||
apply="${busquedaGrupoCategoriaController}" contentStyle="overflow:auto"
|
||||
height="500px" width="600px" border="normal" >
|
||||
<toolbar>
|
||||
<button id="btnRefresh" image="/gui/img/refresh.png" width="35px"
|
||||
tooltiptext="${c:l('busquedaCategoriaController.btnRefresh.tooltiptext')}" />
|
||||
<separator orient="vertical" />
|
||||
<button id="btnNovo" image="/gui/img/add.png" width="35px"
|
||||
tooltiptext="${c:l('busquedaCategoriaController.btnNovo.tooltiptext')}" />
|
||||
<separator orient="vertical" />
|
||||
<button id="btnCerrar" onClick="winBusquedaCategoria.detach()" image="/gui/img/exit.png" width="35px"
|
||||
tooltiptext="${c:l('busquedaCategoriaController.btnCerrar.tooltiptext')}"/>
|
||||
</toolbar>
|
||||
|
||||
<grid fixedLayout="true">
|
||||
<columns>
|
||||
<column width="30%" />
|
||||
<column width="70%" />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label value="${c:l('usquedaGrupoCategoriaController.txtDesc.label')}"/>
|
||||
<textbox id="txtDesc" width="200px"
|
||||
use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
|
||||
<toolbar>
|
||||
<button id="btnPesquisa" image="/gui/img/find.png"
|
||||
label="${c:l('busquedaCategoriaController.btnPesquisa.label')}"/>
|
||||
</toolbar>
|
||||
|
||||
<paging id="pagingGrupoCategoria" pageSize="20" />
|
||||
<listbox id="grupoCategoriaList" use="com.rjconsultores.ventaboletos.web.utilerias.MyListbox"
|
||||
vflex="true" multiple="false" height="80%">
|
||||
<listhead sizable="true">
|
||||
<listheader width="70px" image="/gui/img/builder.gif"
|
||||
label="${c:l('busquedaGrupoCategoriaController.lhId.label')}"
|
||||
sort="auto(grupoCategoriaId)"/>
|
||||
<listheader id="lhDesc" image="/gui/img/builder.gif"
|
||||
label="${c:l('busquedaGrupoCategoriaController.txtDesc.label')}"
|
||||
sort="auto(descGrupo)"/>
|
||||
</listhead>
|
||||
</listbox>
|
||||
</window>
|
||||
</zk>
|
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?page contentType="text/html;charset=UTF-8"?>
|
||||
<?variable-resolver class="org.zkoss.zkplus.spring.DelegatingVariableResolver"?>
|
||||
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" arg0="winEditarGrupoCategoria"?>
|
||||
<?taglib uri="http://www.zkoss.org/dsp/web/core" prefix="c"?>
|
||||
|
||||
<zk xmlns="http://www.zkoss.org/2005/zul">
|
||||
<window id="winEditarGrupoCategoria" border="normal"
|
||||
apply="${editarGrupoCategoriaController}"
|
||||
width="400px" height="457x" contentStyle="overflow:auto"
|
||||
title="${c:l('editarGrupoCategoriaController.window.title')}">
|
||||
<toolbar>
|
||||
<hbox spacing="5px" style="padding:1px" align="right">
|
||||
<button id="btnApagar" height="20"
|
||||
image="/gui/img/remove.png" width="35px"
|
||||
tooltiptext="${c:l('editarCategoriaController.btnApagar.tooltiptext')}"/>
|
||||
<button id="btnSalvar" height="20"
|
||||
image="/gui/img/save.png" width="35px"
|
||||
tooltiptext="${c:l('editarCategoriaController.btnSalvar.tooltiptext')}"/>
|
||||
<button id="btnFechar" height="20"
|
||||
image="/gui/img/exit.png" width="35px"
|
||||
onClick="winEditarCategoria.detach()"
|
||||
tooltiptext="${c:l('editarCategoriaController.btnFechar.tooltiptext')}"/>
|
||||
</hbox>
|
||||
</toolbar>
|
||||
|
||||
<grid fixedLayout="true">
|
||||
<columns>
|
||||
<column width="40%" />
|
||||
<column width="60%" />
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<label id="lbDesc" value="${c:l('editarGrupoCategoriaController.lbDesc.value')}"/>
|
||||
<textbox id="txtDesc" constraint="no empty" width="100%" maxlength="30"
|
||||
value="@{winEditarGrupoCategoria$composer.grupoCategoria.descGrupo}"
|
||||
use="com.rjconsultores.ventaboletos.web.utilerias.MyTextbox"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</window>
|
||||
</zk>
|
Loading…
Reference in New Issue