Fetishcode…Thinking in objects

findByKey and setCurrentRow

Publicado en ADF by fetishcode en Febrero 26th, 2008

Método que dado el nombre de un ViewObject y una lista de keys nos realiza una búsqueda mediante el método findByKey y nos setea la primera de las rows como currrentRow.


    public void setCurrentRowViewObject(String nomview, List l){
     try{
            Iterator it = l.listIterator(0);
            ViewObject vo=findViewObject(nomview);
            Object[] keyValues=new Object[l.size()];
            for(int i=0; it.hasNext();i++){
                       Object item = it.next();
                       keyValues[i]=item;
            }

            Row[] r = vo.findByKey(new Key(keyValues),1);
            if (r != null && r.length > 0) {
                vo.setCurrentRow(r[0]);}
        } catch (Exception ex)  {}
    }

Un método muy útil para tener en nuestra clase de Utils o en nuestro AppmoduleImpl.

Etiqueta con:, , ,