jsf - Getting csv response at client side -
i trying retrieve csv file jsf managed bean.
right doing way,
csvcontroller: bean responds output content type text/csv.
samplecsv.xhtml: webpage contains code:
#{csvcontroller.generatereport()}
when browse page on browser, download dialog opens enables downloading csv file.
report.xhtml:
webpage downloads csv:
d3.csv('http://mysite/samplecsv.xhtml');
is there way rid of samplecsv.xhtml , straight retrieve csv file bean in report.xhtml? d3.csv('http://mysite/csvcontroller/report')
perfect
the pattern you're asking not native way jsf works. see jsf 2: invoking managed bean directly
if still want download content straight managed bean, here illustration in how it. anyway, url download link in report.xhtml
should generated jsf component <f:commandlink action="#csvcontroller.download()}" />
see how stream file download in jsf backing bean?
my recommended approach create new @webservlet("/csvcontroller")
or jax-rs @path("/csvcontroller")
front-end , phone call business logic here. access managed bean servlet this: possible inject @managedbean @managedproperty @webservlet?
anyway, recommed take at: backing beans (@managedbean) or cdi beans (@named)? are @managedbeans obsolete in javaee6 because of @named in cdi/weld?
jsf csv
No comments:
Post a Comment