private void deleteValue(Component btn) { CfgValue deleteCfgValue = (CfgValue) btn.getAttribute("cfgValue"); CfgValue parent = deleteCfgValue.getParent(); if (parent.getCfgInfo().getType().isStruct()) { buttonPanel.appendChild(createAddPartBtn(deleteCfgValue.getCfgInfo())); addBtn.setVisible(true); } parent.removeValue(deleteCfgValue); ((Component) btn.getAttribute("partPane")).setParent(null); }
/** Get converted value and original value of this Binding. */ private Object[] getAttributeValues(Component comp) { if (!isSavable() || _attr.startsWith("_") || DataBinder.isTemplate(comp) || comp.getPage() == null) { return null; // cannot save, a control attribute, or a detached component, skip! } Object rawval = null; try { rawval = Fields.get(comp, _attr); } catch (NoSuchMethodException ex) { // Bug #1813278, Annotations do not work with xhtml tags if (comp instanceof DynamicPropertied) { final DynamicPropertied dpcomp = (DynamicPropertied) comp; if (dpcomp.hasDynamicProperty(_attr)) { rawval = dpcomp.getDynamicProperty(_attr); } else { throw UiException.Aide.wrap(ex); } } else if (comp.getAttributes() .containsKey( _attr)) { // Feature #2855116. Get value from component custom-attribute(also a // variable in ZK5). rawval = comp.getAttribute(_attr); } else { throw UiException.Aide.wrap(ex); } } try { final Object val = (_converter == null) ? rawval : _converter.coerceToBean(rawval, comp); return val == TypeConverter.IGNORE ? null : new Object[] {val, rawval}; } catch (ClassCastException ex) { throw UiException.Aide.wrap(ex); } }
private void addPart(Component btn) { CfgInfo cfgInfo = (CfgInfo) btn.getAttribute("cfgInfo"); CfgValue newPartValue = CfgParser.buildCfgValue(cfgInfo, null, 1, 1); btn.setParent(null); if (buttonPanel.getChildren().isEmpty()) { addBtn.setVisible(false); } addValue_(newPartValue); }
/*package*/ void registerLoadEvents(Component comp) { if (isLoadable()) { // bug 1804356 if (_loadWhenEvents != null) { for (String expr : _loadWhenEvents) { final Object[] objs = ComponentsCtrl.parseEventExpression(comp, expr, comp, false); // objs[0] component, objs[1] event name final Component target = (Component) objs[0]; final String evtname = (String) objs[1]; if (target == null) { throw new NullPointerException("component not found , expr is " + expr); } LoadEventListener listener = (LoadEventListener) target.getAttribute("zk.LoadEventListener." + evtname); if (listener == null) { listener = new LoadEventListener(); target.setAttribute("zk.LoadEventListener." + evtname, listener); target.addEventListener(1000, evtname, listener); } listener.addDataTarget(this, comp); } } if (_loadAfterEvents != null) { for (String expr : _loadAfterEvents) { final Object[] objs = ComponentsCtrl.parseEventExpression(comp, expr, comp, false); // objs[0] component, objs[1] event name final Component target = (Component) objs[0]; final String evtname = (String) objs[1]; LoadAfterEventListener listener = (LoadAfterEventListener) target.getAttribute("zk.LoadAfterEventListener." + evtname); if (listener == null) { listener = new LoadAfterEventListener(); target.setAttribute("zk.LoadAfterEventListener." + evtname, listener); target.addEventListener(evtname, listener); target.addEventListener(evtname + "LoadAfter", listener); } listener.addDataTarget(this, comp); } } } }
private void processAllComponentsBindings(Component comp) { final Binder selfBinder = (Binder) comp.getAttribute(BinderImpl.BINDER); // check if a component was binded already(by any binder) if (selfBinder != null) // this component already binded ! skip all of its children return; processComponentBindings0(comp); for (final Iterator<Component> it = comp.getChildren().iterator(); it.hasNext(); ) { final Component kid = it.next(); processAllComponentsBindings(kid); // recursive to each child } }
/*package*/ void registerSaveEvents(Component comp) { if (isSavable()) { // bug 1804356 if (_saveWhenEvents != null) { for (String expr : _saveWhenEvents) { final Object[] objs = ComponentsCtrl.parseEventExpression(comp, expr, comp, false); // objs[0] component, objs[1] event name final Component target = (Component) objs[0]; final String evtname = (String) objs[1]; SaveEventListener listener = (SaveEventListener) target.getAttribute("zk.SaveEventListener." + evtname); if (listener == null) { listener = new SaveEventListener(); target.setAttribute("zk.SaveEventListener." + evtname, listener); target.addEventListener(1000, evtname, listener); } listener.addDataTarget(this, comp); } } if (_saveAfterEvents != null) { for (final Iterator it = _saveAfterEvents.iterator(); it.hasNext(); ) { final String expr = (String) it.next(); final Object[] objs = ComponentsCtrl.parseEventExpression(comp, expr, comp, false); // objs[0] component, objs[1] event name final Component target = (Component) objs[0]; final String evtname = (String) objs[1]; SaveAfterEventListener listener = (SaveAfterEventListener) target.getAttribute("zk.SaveAfterEventListener." + evtname); if (listener == null) { listener = new SaveAfterEventListener(); target.setAttribute("zk.SaveAfterEventListener." + evtname, listener); target.addEventListener(evtname, listener); target.addEventListener(evtname + "SaveAfter", listener); } listener.addDataTarget(this, comp); } } } }
/** * @type m�todo de la clase ActionStandardBorder.java * @name generarReporte * @param idMapper representa el identificador del DTO en el mapa de reportes disponibles * @param titulo representa el titulo del reporte en la plantilla definida. * @param subtitulo representa el subtitulo del reporte en la plantilla definida. * @param list debido los reportes pueden ser generados a partir de una lista de objetos ya * cargados en memoria es decir no hay que ejecutar una consulta SQL a la base de datos, este * par��metro representa esa lista de objetos los cuales son procesados internamente por el * ReportBuilder que es el encargado de la generaci��n de reportes. * @param componente especifica el nombre del componente o m��dulo al cual pertenece la entidad * (DTO) del reporte a generar * @throws Exception Cualquier Excepcion * @desc Eencapsula la funcionalidad de generaci��n din��mica de reportes para tablas b��sicas. * Debe ser invocado en cada uno de los action que necesiten tener esta opci��n */ public void generarReporte(String idMapper, String fuente, String modulo, Component component) throws Exception { log.info("Ejecutando m�todo [generarReporte]..."); Map<String, Object> parametros = new HashMap<String, Object>(); parametros.put("id", idMapper); parametros.put("fuente", fuente); parametros.put("modulo", modulo); parametros.put("SEC_EJECUTABLE_PADRE", component.getAttribute("SEC_EJECUTABLE")); Component emergente = getEmergente("SRZ_REPORTE", parametros); if (emergente instanceof Window) { Window win = (Window) emergente; win.setClosable(true); emergente.setAttribute("TITULO_NOTIFICACIONES_GRITTER", ((Window) emergente).getTitle()); win.doModal(); } }
public void loginOk(boolean bootstrap) throws Exception { LoginUsuario lu = new LoginUsuario(); LoginUsuarioDTO uDto = lu.log(this.user, this.pass); this.setAtributoSession(Config.LOGEADO, uDto.isLogeado()); this.setAtributoSession(Config.USUARIO, uDto); this.setUs(uDto); this.poneCarita(uDto.isLogeado()); Component compTool = Path.getComponent("/templateInicio"); Control vm = (Control) compTool.getAttribute("vm"); vm.setUs(uDto); if (uDto.isLogeado() == true) { // registrar el login this.registrarLogin(); try { // recupero el control de esta sesion y lo pongo a escuchar // eventos para este login ControlInicio miCi = (ControlInicio) this.getAtributoSession(Config.MI_ALERTAS); EventQueues.lookup(this.getLoginNombre(), EventQueues.APPLICATION, true) .subscribe(new AlertaEvento(miCi)); // ================ this.m.ejecutarMetoto(Config.INIT_CLASE, Config.INIT_AFTER_LOGIN); } catch (Exception e) { e.printStackTrace(); uDto.setLogeado(false); System.out.println( "Error: Metodo afterLogin\n " + " InitClase:" + Config.INIT_CLASE + "\n metodo:" + Config.INIT_AFTER_LOGIN); this.msg = "Configuración incorrecta"; Clients.evalJavaScript("loginFaild()"); return; } Include inc = (Include) compTool.getFellow("menu"); inc.invalidate(); // esto hace un refresh del menu if (this.isSiPiePagina() == true) { Include incS = (Include) compTool.getFellow("menuSistema"); incS.invalidate(); // esto hace un refresh del menu } Object menuBar = inc.getFellow("menubar"); habilitarDeshabilitarMenuBar(menuBar); BindUtils.postGlobalCommand(null, null, "habilitarMenu", null); this.setTextoFormularioCorriente(" "); this.saltoDePagina(bootstrap ? Archivo.okLoginBootstrap : Archivo.okLogin); } else { this.msg = "Usuario o clave incorrecta"; Clients.evalJavaScript("loginFaild()"); } }
private void myLoadAttribute(Component comp, Object bean) { try { // since 3.1, 20080416, support bindingArgs for non-supported tag // bug #2803575, merge bindingArgs together since a component can have // multiple bindings on different attributes. Map<Object, Object> bindArgs = cast((Map) comp.getAttribute(DataBinder.ARGS)); if (bindArgs == null) { bindArgs = new HashMap<Object, Object>(); comp.setAttribute(DataBinder.ARGS, bindArgs); } if (_args != null) { bindArgs.putAll(_args); comp.setAttribute(_attr + "_" + DataBinder.ARGS, _args); } if (_converter != null) { bean = _converter.coerceToUi(bean, comp); if (bean == TypeConverter.IGNORE) return; // ignore, so don't do Fields.set() } // Bug #1876198 Error msg appears when load page (databind+CustomConstraint) // catching WrongValueException no longer works, check special case and // use setRowValue() method directly if ((comp instanceof InputElement) && "value".equals(_attr)) { Object value = bean; Object oldv = null; try { // Bug 1879389 final Method m = comp.getClass().getMethod("getValue"); oldv = ((InputElement) comp).getRawValue(); value = Classes.coerce(m.getReturnType(), bean); } catch (NoSuchMethodException ex) { // ignore it } // See both Bug 3000305 and 2874098 Fields.set(comp, "rawValue", value, _converter == null); } else { Fields.set(comp, _attr, bean, _converter == null); } } catch (ClassCastException ex) { throw UiException.Aide.wrap(ex); } catch (NoSuchMethodException ex) { // Bug #1813278, Annotations do not work with xhtml tags if (comp instanceof DynamicPropertied) { final DynamicPropertied dpcomp = (DynamicPropertied) comp; if (dpcomp.hasDynamicProperty(_attr)) { // no way to know destination type of the property, use bean as is dpcomp.setDynamicProperty(_attr, bean); } else { throw UiException.Aide.wrap(ex); } } else { // Feature# 2855116. Save into component custom-attribute(also a variable in ZK5). comp.setAttribute(_attr, bean); } // Bug #1876198 Error msg appears when load page (databind+CustomConstraint) // catching WrongValueException no longer works, so mark it out /*} catch (WrongValueException ex) { //Bug #1615371, try to use setRawValue() if ("value".equals(_attr)) { try { Fields.set(comp, "rawValue", bean, _converter == null); } catch (Exception ex1) { //exception throw ex; } } else { throw ex; } */ } }
public Treeitem cargarHijosTreePorDemanda( Treechildren padre, String[] sec, String ids, boolean treeItemRenderMovimiento) throws Exception { log.info("Ejecutando el metodo [Treeitem cargarHijosTreePorDemanda...]"); Component itemSelected = null; List<Component> listItem = padre.getChildren(); Map<String, Object> parameter = new HashMap<String, Object>(); parameter.put("GRUPO", padre.getAttribute("grupo").toString()); if (sec != null) { List<Component> arbol = ((Treechildren) ((Treeitem) listItem.get(0)).getChildren().get(1)).getChildren(); for (int i = (sec.length - 1); i > 0; i--) { for (Component itemTree : arbol) { if (itemTree.getId().trim().equals(ids + sec[i])) { if (i == 1) { ((Treeitem) itemTree).setSelected(true); itemSelected = itemTree; break; } else { parameter.put("PADRE", sec[i]); List<MyItemTree> listaHijos = (List<MyItemTree>) ParametrizacionFac.getFacade() .obtenerListado(itemTree.getAttribute("Consulta").toString(), parameter); Treechildren tchil = (Treechildren) itemTree.getChildren().get(1); tchil.getChildren().clear(); for (MyItemTree myItemTree : listaHijos) { Treeitem tiHijo = new Treeitem(); Treerow trow = new Treerow(); Treecell tcEti = new Treecell(myItemTree.getEtiqueta()); if (!treeItemRenderMovimiento) { // valida si se debe habilitar o no el componente // dragdroptree trow.setDroppable("true"); trow.setDraggable("true"); } if (myItemTree.getParametros() != null) { if (myItemTree.getParametros().equals("I")) { trow.setStyle("background-color:#E3F6CE"); } else if (myItemTree.getParametros().equals("E")) { trow.setStyle("background-color:#F6CECE"); } } if (myItemTree.getOtherValue() != null && myItemTree.getOtherValue().toString().equals("N")) { tcEti.setStyle("color:#BDBDBD;font-weight: bold"); } tcEti.setTooltiptext(myItemTree.getEtiqueta()); trow.appendChild(tcEti); trow.appendChild( new Treecell( myItemTree.getValor() != null ? myItemTree.getValor().trim() : null)); trow.appendChild( new Treecell( myItemTree.getPadre() != null ? myItemTree.getPadre().trim() : null)); trow.appendChild(new Treecell(myItemTree.getNivel().toString())); trow.appendChild( new Treecell(myItemTree.getId() != null ? myItemTree.getId().trim() : null)); trow.appendChild( new Treecell( myItemTree.getOtherValue() != null ? myItemTree.getOtherValue().toString().trim() : null)); trow.appendChild( new Treecell( myItemTree.getParametros() != null ? myItemTree.getParametros().trim() : null)); trow.setAttribute("valor", myItemTree.getValor()); trow.setAttribute("padre", myItemTree.getPadre()); trow.setAttribute("nivel", myItemTree.getNivel()); trow.setAttribute("llave", myItemTree.getId()); trow.setAttribute("movimiento", myItemTree.getOtherValue()); trow.setAttribute("parametros", myItemTree.getParametros()); tiHijo.appendChild(trow); tiHijo.setId(ids + myItemTree.getId()); tiHijo.setAttribute("Consulta", itemTree.getAttribute("Consulta")); tiHijo.setAttribute("grupo", itemTree.getAttribute("grupo")); if (padre.hasFellow(ids + myItemTree.getId())) padre.getFellow(ids + myItemTree.getId()); tchil.appendChild(tiHijo); if (myItemTree.getNumeroDescendientes() > 0) { cargarHijosTreePorDemanda( tiHijo, myItemTree.getId(), ids, treeItemRenderMovimiento); } } ((Treeitem) itemTree).setOpen(true); arbol = ((Treechildren) itemTree.getChildren().get(1)).getChildren(); break; } } } } } else { itemSelected = (Treeitem) listItem.get(0); ((Treeitem) listItem.get(0)).setSelected(true); } return ((Treeitem) itemSelected); }
private void enter(Component btn) { CfgValue cfgValue = (CfgValue) btn.getAttribute("cfgValue"); createDialog( new CfgValueViewer(cfgValue, null).getView(), // cfgValue.getTitle()); }
private void copyValue(Component btn) { CfgValue origValue = (CfgValue) btn.getAttribute("cfgValue"); CfgValue newEle = CfgParser.copy(origValue); addValue_(newEle); }