Problemas ao navegar entre registros

Bom dia galera!

Estou com um problema, criei uma pagina(jsp) para exibir imagens na tela e tem 2 botões avançar e voltar.
No banco tem 3 imagens, ao clicar em avançar só vai para segunda imagem, clico em avançar e não vai para a terceira. No botão voltar o mesmo problema.

Segue meu codigo.

[code] public String btVoltar1_action() {
try {
tabelafotosDataProvider2.cursorPrevious();
tabelafotosDataProvider2.refresh();
tabelaantesfotosDataProvider2.cursorPrevious();
tabelaantesfotosDataProvider2.refresh();
if (dcData.getSelectedDate() == null && ddDescricao.getValue() != null) {
String nome_arquivo = (String) tabelafotosDataProvider2.getValue(“fotos.nome_arquivo”);
info(“nome 1” + nome_arquivo);
Date data = (Date) tabelafotosDataProvider2.getValue(“fotos.data”);

            //    info("nome "+ nome_arquivo);
            ServletContext theApplicationsServeletContext = (ServletContext) this.getExternalContext().getContext();
            String path = theApplicationsServeletContext.getRealPath("/images/pacientes");
            //  info("caminho imagem " + path);

            //carrega a imagem do banco no campo imagem
            img_antes.setVisible(true);
            img_antes.setUrl(IMAGE_URL + "/" + nome_arquivo);

        //img_antes.setUrl("/images/pacientes/teste.jpeg");
        //       info("imagem carregada");
        } else {
            String nome_arquivo = (String) tabelaantesfotosDataProvider2.getValue("fotos.nome_arquivo");
            info("nome 1" + nome_arquivo);
            Date data = (Date) tabelaantesfotosDataProvider2.getValue("fotos.data");

            //    info("nome "+ nome_arquivo);
            ServletContext theApplicationsServeletContext = (ServletContext) this.getExternalContext().getContext();
            String path = theApplicationsServeletContext.getRealPath("/images/pacientes");
            //  info("caminho imagem " + path);

            //carrega a imagem do banco no campo imagem
            img_antes.setVisible(true);
            img_antes.setUrl(IMAGE_URL + "/" + nome_arquivo);

        //img_antes.setUrl("/images/pacientes/teste.jpeg");
        //       info("imagem carregada");
        }
    } catch (Exception ex) {
        error("Erro " + ex);

    }
    return null;
}[/code]

HELP!

Alguém me ajuda estou desesperado :frowning: