/* FUNCIONES DE UTILIDAD ADF FACES RC */ /* ***************************************************************** */ /* *** Este archivo debe importarse junto con el archivo Util.js *** */ /* ***************************************************************** */ /* Ejecuta el action de un commandButton/link cuando se presiona ENTER. * btnId: Id del commandButton/link pasado como parámetro * mediante af:clientAttribute*/ function ejecutarActionDeBoton(event) { var keycode = event.getKeyCode(); if (keycode == AdfKeyStroke.ENTER_KEY) { var btnId = event.getSource().getProperty("btnId"); var componente = AdfPage.PAGE.findComponentByAbsoluteId(btnId); AdfActionEvent.queue(componente, componente.getPartialSubmit()); } } /* Ejecuta el action de un commandButton. * btnId: Id del commandButton */ function ejecutarClickDeBoton(btnId) { var componente = AdfPage.PAGE.findComponentByAbsoluteId(btnId); AdfActionEvent.queue(componente, componente.getPartialSubmit()); } /* Ejecuta un goLink/goButton. * btnId: Id del goLink/goButton */ function ejecutarClickDeGoButton(btnId) { var component = AdfPage.PAGE.findComponentByAbsoluteId(btnId); var redirectEvent = new AdfRedirectEvent(component, component.getDestination(), true); redirectEvent.queue(true); } /* Muestra el mensaje de error recibido como parámetro */ function mostrarMensajeError(mensaje) { AdfPage.PAGE.clearAllMessages(); AdfPage.PAGE.addMessage(null, new AdfFacesMessage(AdfFacesMessage.TYPE_ERROR, "Error" , mensaje )); AdfPage.PAGE.showMessages(); } /* Muestra un mensaje de error sobre el componente. * idComponente: Id del componente sobre el cual se quiere mostrar el mensaje. * label: Título del mensaje. * mensaje: Mensaje de error. */ function mostrarMensajeErrorEnComponente(idcomponente, label, mensaje) { AdfPage.PAGE.clearAllMessages(); AdfPage.PAGE.addMessage(idcomponente, new AdfFacesMessage(AdfFacesMessage.TYPE_ERROR, label, mensaje), ""); AdfPage.PAGE.showMessages(); } /* Muestra el mensaje de información recibido como parámetro */ function mostrarMensajeInfo(mensaje) { AdfPage.PAGE.clearAllMessages(); AdfPage.PAGE.addMessage(null, new AdfFacesMessage(AdfFacesMessage.TYPE_INFO, "Información" , mensaje )); AdfPage.PAGE.showMessages(); } /* Muestra un mensaje de información sobre el componente. * idComponente: Id del componente sobre el cual se quiere mostrar el mensaje. * label: Título del mensaje. * mensaje: Mensaje de información. */ function mostrarMensajeInfoEnComponente(idcomponente, label, mensaje) { AdfPage.PAGE.clearAllMessages(); AdfPage.PAGE.addMessage(idcomponente, new AdfFacesMessage(AdfFacesMessage.TYPE_INFO, label, mensaje), ""); AdfPage.PAGE.showMessages(); } /* Deshabilita cualquier evento que el usuario quiera iniciar */ function deshabilitarEntradaDeUsuario(event) { event.preventUserInput(); } /* Coloca el foco en el siguiente componente habilitado de la lista de * componentes recibida como parámetro*/ function setFocusIn(event, lista) { var source = event.getSource(); var pref = source.getClientId().substring(0,source.getClientId().lastIndexOf(':')+1); var id = source.getClientId().substring(source.getClientId().lastIndexOf(':')+1); //actualizar lista con los componentes habilitados var listaActualizada = new Array(); for (i = 0; i < lista.length ; i++) { var item = AdfPage.PAGE.findComponentByAbsoluteId( pref + lista[i]); if (item == null) { item = AdfPage.PAGE.findComponentByAbsoluteId(lista[i]); } if (item == null) { item = document.getElementById(lista[i]); if (item != null && item != undefined){ if (item.disabled != true) listaActualizada.push(lista[i]) } } else { if (item != null && item != undefined){ if (item.getProperty('disabled') != true) listaActualizada.push(lista[i]) } } } var index = 0; for (i = 0; i < listaActualizada.length ; i++) { compAct = pref + id; if ((listaActualizada[i] == id) || (listaActualizada[i] == compAct)) { index = i; break; } } var prev = listaActualizada[index-1] == undefined ? pref + listaActualizada[listaActualizada.length-1] : pref + listaActualizada[index-1]; if (AdfPage.PAGE.findComponentByAbsoluteId(prev) == null) { prev = listaActualizada[index-1] == undefined ? listaActualizada[listaActualizada.length-1] : listaActualizada[index-1]; } var prox = listaActualizada[index+1] == undefined ? pref + listaActualizada[0] : pref + listaActualizada[index+1]; if (AdfPage.PAGE.findComponentByAbsoluteId(prox) == null) { prox = listaActualizada[index+1] == undefined ? listaActualizada[0] : listaActualizada[index+1]; } var keyModifier = event.getKeyModifiers(); var keycode = event.getKeyCode(); if (keycode == AdfKeyStroke.TAB_KEY) { if (keyModifier == AdfKeyStroke.SHIFT_MASK) { var previous = AdfPage.PAGE.findComponentByAbsoluteId(prev); if (previous == null) previous = document.getElementById(previous); previous.focus(); event.cancel(); return; } else { var proximo = AdfPage.PAGE.findComponentByAbsoluteId(prox); if (proximo == null) proximo = document.getElementById(prox); proximo.focus(); event.cancel(); } } } /* Abre el popup del Calendario de un inputDate */ function abrirCalendarioDeInputDate(event) { src = event.getSource(); popup = src.findComponent(""+AdfRichUIPeer.CreateSubId(src.getClientId(), AdfDhtmlInputDatePeer._POPUP_ID)); hints = {alignId:src.getClientId(), align:AdfRichPopup.ALIGN_END_AFTER}; popup.show(hints); } /* Posiciona el foco en el siguiente componente * Recibe sig y ant como parámetros (mediante clientAtributte) * sig: el id del componente siguiente * ant: el id del componente anterior */ function setFocoSigAnt(event) { var sig = event.getSource().getProperty('sig'); var ant = event.getSource().getProperty('ant'); var keyModifier = event.getKeyModifiers(); var keycode = event.getKeyCode(); if (keycode == AdfKeyStroke.TAB_KEY) { var comp = null; if (keyModifier == AdfKeyStroke.SHIFT_MASK) { comp = AdfPage.PAGE.findComponentByAbsoluteId(ant); if (comp == null) { comp = document.getElementById(ant); } } else { comp = AdfPage.PAGE.findComponentByAbsoluteId(sig); if (comp == null) { comp = document.getElementById(sig); } } comp.focus(); event.cancel(); } } /* ************************************* */ /* *** METODOS QUE REQUIEREN UTIL.JS *** */ /* ************************************* */ /* Invoca a la función soloFechas y patronFecha del Util.js*/ function patronFechaJSADF(event) { var src = event.getSource().getClientId() + '::content'; var fecha = document.getElementById(src); if (fecha.value.length > 9) event.cancel(); else { soloFechas(event); patronFecha(event, src); } } /* Invoca a la función soloCUITs y patronCuitCod del Util.js*/ function patronCuitCodJSADF(event) { var src = event.getSource().getClientId() + '::content'; soloCUITs(event); patronCuitCod(event, src); }