0 Replies Latest reply on Dec 18, 2012 12:05 AM by luisaggo

    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

    luisaggo

      When I submit the action from a commandButton, this error appear:

       

      java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
      at java.util.ArrayList.RangeCheck(ArrayList.java:547)
      at java.util.ArrayList.get(ArrayList.java:322)
      at javax.faces.component.AttachedObjectListHolder.restoreState(AttachedObjectListHolder.java:165)
      at javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:1560)
      at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1336)
      at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1351)
      at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1351)
      at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1351)
      at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1351)
      at javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:1351)
      at javax.faces.component.UIViewRoot.processRestoreState(UIViewRoot.java:876)

       

      My RichFaces Version is 4.2.3Final and JSF is Mojarra 2.1.14.

       

       

      The View source is:

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

       

       

      <html xmlns="http://www.w3.org/1999/xhtml"

                xmlns:ui="http://java.sun.com/jsf/facelets"

                xmlns:h="http://java.sun.com/jsf/html"

                xmlns:f="http://java.sun.com/jsf/core"

                xmlns:p="http://primefaces.org/ui"

                xmlns:a4j="http://richfaces.org/a4j"

                xmlns:rich="http://richfaces.org/rich">

      <!-- Todas las paginas deben tener esta linea para que las tildes funcionen -->

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      <f:loadBundle basename="co.com.gesiti.acreditacion.properties.program"

                var="msg" />

      <h:body>

      <ui:composition template="/template/common.xhtml">

                <ui:define name="body">

                          <script src="resources/scripts/jquery.metadata.js"

                                    type="text/javascript"></script>

                          <script type="text/javascript">

                          jQuery(document).ready( function() {

                                              //$("#mainForm:username").focus();

                                               jQuery("input:text:first").focus();

                                    });

                          </script>

       

                          <h:panelGroup rendered="#{currentUser.tipoUsuario == null}">

                          <a4j:outputPanel id="contentForm">

                          <h:form>

                                    <table width="100%" align="center" border="0" cellspacing="0"

                                              cellpadding="0">

                                              <tr>

                                                        <td class="titulosolo" align="right"><br />

                                                        <h:outputText styleClass="titulosolo" value="Inicio Sesión">

                                                        </h:outputText></td>

                                              </tr>

                                    </table>

                                    <br />

       

                                    <table width="50%" align="center" border="0" cellspacing="0"

                                              cellpadding="0" class="tablamultiregistro">

                                              <tr class="tablamultiregistrotr2">

                                                        <td align="right"><h:outputText value="Nombre de Usuario: " />

                                                        </td>

                                                        <td align="left"><h:inputText

                                                                  id="username" immediate="true" value="#{InicioSesion_1.username}"  />

                                                        <h:panelGroup id="ErrorUsernamePanel"

                                                                  style="color:red; font-weight:bold">

                                                                  <h:message for="username" />

                                                        </h:panelGroup></td>

                                              </tr>

                                              <tr class="tablamultiregistrotr1">

                                                        <td align="right"><h:outputText value="Contraseña: " /> </td>

                                                        <td align="left">

                                                        <h:inputSecret id="password" immediate="true" redisplay="true" value="#{InicioSesion_1.password}"

                                                                   /> <h:panelGroup id="ErrorPasswordPanel"

                                                                  style="color:red; font-weight:bold">

                                                                  <h:message for="password" />

                                                        </h:panelGroup></td>

                                              </tr>

       

       

       

       

                                                        <tr class="tablamultiregistrotr2">

                                                                  <td align="center" colspan="2">

                                                                            <a4j:outputPanel id="idProcesoSelect"

                                                                                      rendered="#{InicioSesion_1.activarProceso}" ajaxRendered="true">

       

                                                                                      <h:selectOneMenu value="#{InicioSesion_1.idProceso}"

                                                                                                id="txtProceso">

                                                                                                <f:selectItems value="#{InicioSesion_1.procesosSelect}" />

                                                                                                <f:ajax event="change"

                                                                                                          actionListener="#{InicioSesion_1.validateProcesos}"

                                                                                                          ajaxSingle="true" />

                                                                                      </h:selectOneMenu>

                                                                            </a4j:outputPanel>

                                                                  </td>

                                                        </tr>

       

       

       

       

                                                        <tr class="tablamultiregistrotr2">

                                                        <td align="center" colspan="2">

                                                        <h:panelGroup id="errorSummary"

                                                                  style="color:red; font-weight:bold">

                                                                  <h:outputText value="#{InicioSesion_1.errorSummary}" />

                                                                  <br />

                                                        </h:panelGroup>

                                                        <p:commandButton value="Aceptar1" action="#{InicioSesion_1.consultarProcesos}" type="submit"

                                                        ajax="false"

                                                        styleClass="submit"

                                                        immediate="true"

                                                        update="ErrorUsernamePanel,ErrorPasswordPanel,errorSummary,idProcesoSelect" />

       

                                                        <a4j:commandButton value="Aceptar"

                                                                  action="#{InicioSesion_1.consultarProcesos}"

                                                                  styleClass="submit"

                                                                  immediate="true"

                                                                  render="contentForm">

                                                                  </a4j:commandButton>

                                                                  </td>

                                              </tr>

       

                                              <tr class="tablamultiregistrotr2">

                                                        <td align="center" colspan="2">

                                                        <br/>

                                                        <br/>

                                                        <a4j:commandLink value="Recuperar Contraseña" id="link"          action="#{InicioSesion_1.recuperarClave}" />

                                                        </td>

                                              </tr>

                                    </table>

                          </h:form>

                          </a4j:outputPanel>

                          </h:panelGroup>

       

                </ui:define>

      </ui:composition>

      </h:body>

      </html>

       

       

      AND the Backing Bean Action is:

       

       

       

       

       

      @SuppressWarnings("unchecked")

                public String consultarProcesos() throws SQLException, IOException {

       

       

                          Usuarios oUsuario = null;

       

                          try {

                                    oUsuario = usuarioServices.validateUsuario(username, password);

                          } catch (Exception e) {

                                    // TODO Auto-generated catch block

                                    //e.printStackTrace();

                          }

       

       

                          if (oUsuario == null) {

                                    alert1.setVisible(true);

                                    alert1.setType("error");

                                    alert1

                                                        .setStyle("color: red; font-family: 'Arial','Helvetica',sans-serif; font-size: 11px; height: 22px; left: 0px; top: 144px; position: absolute; width: 550px");

                                    String errorString = " " + " " + "Nombre de usuario o contraseña incorrecta. Intente de nuevo";

                                    errorSummary = errorString;

                                    alert1.setSummary(errorString);

                                    bandera = true;

                                    return null;

                          }else{

                                    List<UsuarioProceso> procesos = usuarioServices.getProcesosUsuario(oUsuario);

       

                                    if (loadPrivs(oUsuario.getTipoUsuario().trim()).containsKey("superAdministrador") || getUsuarioProceso() != null){

                                              setActivarProceso(false);

                                              return iniciarSesion_action();

                                    }else if (procesos == null || procesos.size() == 0){

                                              alert1.setVisible(true);

                                              alert1.setType("error");

                                              alert1

                                                                  .setStyle("color: red; font-family: 'Arial','Helvetica',sans-serif; font-size: 11px; height: 22px; left: 0px; top: 144px; position: absolute; width: 550px");

                                              String errorString = " " + " " + "No tiene procesos asociados por lo cual no puede ingresar a la aplicación. Por favor contactar al administrador";

                                              errorSummary = errorString;

                                              alert1.setSummary(errorString);

                                              bandera = true;

                                              setActivarProceso(false);

                                              return null;

                                    }else if (isActivarProceso() && getUsuarioProceso() == null){

                                              alert1.setVisible(true);

                                              alert1.setType("error");

                                              alert1

                                                                  .setStyle("color: red; font-family: 'Arial','Helvetica',sans-serif; font-size: 11px; height: 22px; left: 0px; top: 144px; position: absolute; width: 550px");

                                              String errorString = " " + " " + "Debe elegir un proceso";

                                              errorSummary = errorString;

                                              alert1.setSummary(errorString);

                                              bandera = true;

                                              setActivarProceso(false);

                                              return null;

                                    }else {

                                              setActivarProceso(true);

                                              setErrorSummary("");

                                              return "indexProgram";

                                    }

                          }

       

       

                }

       

       

      PLEASE ANY IDEA?