Panelgrid / datagrid ou outra coisa?

0 respostas
G

Olá,

Tenho uma classe que faz uma pesquisa e retorna um array de objetos.
Quero exibir o resultado da pesquisa em uma página.

Para isso eu poderia programar em jsp e fazer "na marra", mas acredito que exista uma tag jsf que me de isso de forma mais fácil. Dei uma olhada nas tags panelgrid e datagrid, mas não consegui entender direito… Alguém sabe como fazer???

A variável que eu gostaria de usar é a elements, quero saber se existe uma forma de percorre-la automaticamente.

A classe segue abaixo:

import javax.xml.rpc.ServiceException;

import com.google.soap.search.GoogleSearch;
import com.google.soap.search.GoogleSearchResult;
import com.google.soap.search.GoogleSearchResultElement;

import java.rmi.RemoteException;
import java.util.*;

public class pesquisa {
	private final GoogleSearchPort port;
	private final String googleKey;
	
	private String chavePesquisa = "";
	
	private String mensagem = "";
	
	private GoogleSearchResultElement elements[] = null;
	
	private final String SUCESSO_BUSCA = "success";
	
	private final String ERRO_BUSCA = "failure";
	
	public pesquisa(String googleKey) throws ServiceException{
		this.googleKey = googleKey;
		GoogleSearchService service = new GoogleSearchServiceLocator();
		port = service.getGoogleSearchPort();
	}
	
	public GoogleSearchResultElement[] buscar(String chave) throws Exception{
		GoogleSearch googleSearch = new GoogleSearch();
		googleSearch.setKey("OHMvlDlQFHIz4cT2IZ1xspolgDkOt/jL");
		googleSearch.setQueryString(chave);
		//googleSearch.setRestrict("Gustavo Luis Marques Melo");
		googleSearch.setStartResult(0);
		
		GoogleSearchResult result = null;
		elements = null;
		
		 result = googleSearch.doSearch();
		 elements = result.getResultElements();
						
		return elements;
	}

	public String fazPesquisa(){
		
		if((chavePesquisa == null) || (chavePesquisa.trim().length() == 0))
		{
			mensagem = "Chave de pesquisa não informada";
			return ERRO_BUSCA;
		}
		
		try{
			GoogleSearchResultElement[] elements = buscar(chavePesquisa);
			if(elements.length > 0)
			  return SUCESSO_BUSCA;
			else
			{
				mensagem = "Não foram encontrados resultados para a chave de pesquisa informada";
				return ERRO_BUSCA;
			}
			
		}catch(Exception e)
		{
			e.printStackTrace();
		}
				
		mensagem = "Estamos enfrentando problemas técnicos no momento, favor tentar mais tarde";
		return ERRO_BUSCA;
	}
	
	public String getChavePesquisa() {
		return chavePesquisa;
	}

	public void setChavePesquisa(String chavePesquisa) {
		this.chavePesquisa = chavePesquisa;
	}
	
	public String getMensagem() {
		return mensagem;
	}

	public void setMensagem(String mensagem) {
		this.mensagem = mensagem;
	}

	public GoogleSearchResultElement[] getElements() {
		return elements;
	}

	public void setElements(GoogleSearchResultElement elements[]) {
		this.elements = elements;
	}
Criado 8 de julho de 2006
Respostas 0
Participantes 1