1 2 Previous Next 22 Replies Latest reply on Mar 5, 2009 8:05 AM by Ramón Minarro

    SuggestionBox

    Ramón Minarro Newbie

      Hi, I Have a problem with a suggestionBox. I have a jsp page in a well-functioning suggestionbox but i have another jsp page where it does not work well a suggestion box. The problem is that I always select the first item in the list of suggestions.

      The code of de jsp page is:


      <rich:suggestionbox id="idSugerenciasCen" suggestionAction="#{usuarioCentroBean.autoCompletarAvanzado}"
      var="centro" tokens="," fetchValue="#{centro.codcen}" width="350" height="200"
      for="idCentro" shadowOpacity="9" nothingLabel="Centro no encontrado.">
      <t:column>
      <h:outputText value="#{centro.codcen}" style="font-style:bold"/>
      </t:column>
      <t:column>
      <h:outputText value="#{centro.dencen}"/>
      </t:column>
      </rich:suggestionbox>



      UsuarioCentroBean.java



      public List autoCompletarAvanzado(Object begin){
      String prefijo = (String) begin;
      List resultado;
      if (centros == null) {
      centroBusqueda= new Centro();
      getCentros();
      }
      resultado = new ArrayList();
      Centro centroIt;
      for(Iterator itCentros = this.centros.iterator(); itCentros.hasNext();){
      centroIt = itCentros.next();
      if(((centroIt != null) && ((centroIt.getCodcen().indexOf(prefijo.toUpperCase()) == 0) ||
      (centroIt.getDencen().contains(prefijo.toUpperCase())) ||
      (centroIt.getLoccen().contains(prefijo.toUpperCase()))))){
      resultado.add(centroIt);
      }
      }
      return resultado;
      }

        1 2 Previous Next