Galera já estou desistindo de implementar relatórios no vraptor, não consegui nada ainda, então estou retornando ao inicio mais uma vez e não consigo executar o Exemplo de download do arquivo binário que tem na documentação do vraptor, aguém poderia me ajudar, tenho os seguintes códigos:
package ramal.logic;
import java.io.IOException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
/**
* permite acesso para OutputStream and ContentType
*/
public class ClientOutput {
private HttpServletResponse response;
public ClientOutput(HttpServletResponse response) {
super();
this.response = response;
}
public ServletOutputStream getOutputStream() throws IOException {
return response.getOutputStream();
}
public void setContentType(String type) {
response.setContentType(type);
}
}
package ramal.logic;
import javax.servlet.http.HttpServletResponse;
import org.vraptor.Interceptor;
import org.vraptor.LogicException;
import org.vraptor.LogicFlow;
import org.vraptor.annotations.Out;
import org.vraptor.view.ViewException;
public class DownloadInterceptor implements Interceptor {
private HttpServletResponse response;
public DownloadInterceptor(HttpServletResponse response) {
this.response = response;
}
private ClientOutput clientOutput;
public void intercept(LogicFlow flow) throws LogicException, ViewException {
this.clientOutput = new ClientOutput(this.response);
flow.execute();
}
@Out(key="org.vraptor.util.ClientOutput")
public ClientOutput getClientOutput() {
return this.clientOutput;
}
}
package ramal.logic;
import java.io.IOException;
import org.vraptor.annotations.Component;
import org.vraptor.annotations.InterceptedBy;
import org.vraptor.annotations.Viewless;
@Component("report")
@InterceptedBy( DownloadInterceptor.class )
public class RelatorioDeContratosLogic {
private ClientOutput clientOutput;
public RelatorioDeContratosLogic(ClientOutput clientOutput) {
this.clientOutput = clientOutput;
}
@Viewless
public void sample() throws IOException {
// gera um pdf usando o output stream
new ReportGenerator().outputTo(
this.clientOutput.getOutputStream()
);
}
}
Só que se eu importar o ReportGenerator() ele diz que não tem referencia com “outputTo”.
Galera preciso entregar um relatorio hoje, peço a ajuda de vcs (y)