开发者

integrated report in ireport with jsf [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly开发者_开发问答 broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago.

hallo all..

i have a problem to create pdf format report with jasper report/ireport plugin in jsf ?

i've made a report in jasper report, but i can't integrate it with jsf for create pdf format..

thank for your help..


Could could do it this way. Add a h:commandLink on a page pointing to an action method of your bean:

<h:commandLink value="download report" action="#{myBean.downloadReport}" />

In your bean you should generate your report and write it to the OutputStream of the response:

public class MyBean {

  public String downloadReport() {

    // get HttpServletResponse
    FacesContext context = FacesContext.getCurrentInstance();
    HttpServletResponse response = 
      (HttpServletResponse) context.getExternalContext().getResponse();

    // set correct content type
    response.setContentType("application/pdf");

    // get OutputStream
    OutputStream stream = response.getOutputStream();

    // TODO: generate PDF and write the report to this output stream 

    // mark response as completed
    context.responseComplete();
    return null;

  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜