开发者

integrated report in ireport with jsf [closed]

开发者 https://www.devze.com 2023-01-23 16:39 出处:网络
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly开发者_开发问答 broad, or rhetorical andcannot be reasonably answered in its current form.
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

精彩评论

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

关注公众号