private QuerySearchAvanced saveSearchConditions(HttpSession session, HttpServletRequest request) { String listOrder = RequestUtils.parseRequestParameterAsStringWithEmpty(request, "99999"); if (StringUtils.isEmpty(listOrder)) { listOrder = XML_FLD_UPPER_TEXT + 1; } int contRegistros = Integer.parseInt(request.getParameter("contadorreg")); QuerySearchAvanced querySearchAvanced = new QuerySearchAvanced(); FieldSearchAvanced[] fieldSearchAvanced = new FieldSearchAvanced[contRegistros]; int[] idoperator = new int[contRegistros]; String[] valueWhere = new String[contRegistros]; String[] nexo = new String[contRegistros]; boolean[] hasInvalidValue = new boolean[contRegistros]; Map nameCampos = (Map) session.getAttribute("camposconsulta"); for (int i = 0; i < contRegistros; i++) { FieldSearchAvanced field = (FieldSearchAvanced) nameCampos.get(request.getParameter("oSelectCampo_" + i)); if (field != null) { field.setRowId(i); fieldSearchAvanced[i] = field; try { idoperator[i] = Integer.parseInt(request.getParameter("oSelectOperador_" + i)); } catch (NumberFormatException e) { // idoperator[i] = 0; } valueWhere[i] = request.getParameter("where_" + i); hasInvalidValue[i] = false; } nexo[i] = request.getParameter("nexo_" + i); } querySearchAvanced.setFieldSearchAvanced(fieldSearchAvanced); querySearchAvanced.setIdOperator(idoperator); querySearchAvanced.setValueWhere(valueWhere); querySearchAvanced.setNexo(nexo); querySearchAvanced.setHasInvalidValue(hasInvalidValue); querySearchAvanced.setOrder(listOrder); session.setAttribute("contRegistros", new Integer(contRegistros)); session.setAttribute("valoresConsulta", querySearchAvanced); return querySearchAvanced; }
/** Método que se encarga de cargar los datos en pantalla */ private void deleteRow( HttpServletRequest request, HttpServletResponse response, HttpSession session) throws ServletException, IOException { int contRegistros = Integer.parseInt(request.getParameter("contadorreg")); QuerySearchAvanced querySearchAvanced = new QuerySearchAvanced(); FieldSearchAvanced[] fieldSearchAvanced = new FieldSearchAvanced[contRegistros]; int[] idoperator = new int[contRegistros]; String[] valueWhere = new String[contRegistros]; String[] nexo = new String[contRegistros]; Map nameCampos = (Map) session.getAttribute("camposconsulta"); int ind_auxiliar = 0; for (int i = 0; i <= contRegistros; i++) { if (request.getParameter("oSelectCampo_" + i) != null) { fieldSearchAvanced[ind_auxiliar] = (FieldSearchAvanced) nameCampos.get(request.getParameter("oSelectCampo_" + i)); try { idoperator[ind_auxiliar] = Integer.parseInt(request.getParameter("oSelectOperador_" + i)); } catch (NumberFormatException e) { // idoperator[i] = 0; } valueWhere[ind_auxiliar] = request.getParameter("where_" + i); nexo[ind_auxiliar] = request.getParameter("nexo_" + i); ind_auxiliar++; } } querySearchAvanced.setFieldSearchAvanced(fieldSearchAvanced); querySearchAvanced.setIdOperator(idoperator); querySearchAvanced.setValueWhere(valueWhere); querySearchAvanced.setNexo(nexo); session.setAttribute("contRegistros", new Integer(contRegistros)); session.setAttribute("valoresConsulta", querySearchAvanced); request.getRequestDispatcher("/frmqueryadvan.jsp").forward(request, response); }