0
在我的xhtml文件中,我必須將p:dialog的employeeId和employeeName值傳遞給jasper report.I已創建jrxml(文件),字段爲$ F {employeeId}和$ F {employementName}。當我選擇命令按鈕時,它必須將employeeId和employeeName傳遞給碧玉報告並生成爲.pdf.But但我不知道如何在JRBeanCollectionDataSource中傳遞employeeId和employeeName。如何將bean值傳遞給碧玉報告
<p:dialog header="Employee Details" widgetVar="actDialog" appendToBody="false"
resizable="false" showEffect="explode" hideEffect="explode">
<h:panelGrid id="dialog" columns="2" cellpadding="4">
<h:outputText value="Employee Id:" />
<h:outputText
value="#{employeeBean.current.employeeId}"
style="font-weight:bold" />
<h:outputText value="Employee Name:" />
<h:outputText
value="#{employeeBean.current.employeeName}"
style="font-weight:bold" />
</h:panelGrid>
<p:commandButton value="Report" ajax="false" icon="ui-icon-check" style="width:70px;" action="#{employeeBean.generateReport}"/>
</p:dialog>
豆:
private List<EmployementScheduleDTO> userList;
private EmployementScheduleDTO current;
public List<EmployementScheduleDTO> getUserList() {
return userList;
}
public void setUserList(List<EmployementScheduleDTO> userList) {
this.userList = userList;
}
public EmployementScheduleDTO getCurrent() {
return current;
}
public void setCurrent(EmployementScheduleDTO current) {
if (current != null) {
this.current = current;
}
}
public void generateReport()
{
reportGeneration(current, userList);
}
public void reportGeneration(EmployementScheduleDTO employeedto,List<EmployementScheduleDTO> a_beanList)
{
try
{
URL url = getClass().getClassLoader().getResource("/WEB-INF/reports/employee.jrxml");
JasperReport jasperReport = JasperCompileManager.compileReport(url.getPath());
JRBeanCollectionDataSource jrDataSource =
new JRBeanCollectionDataSource(a_beanList);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, jrDataSource);
}
catch (JRException jre)
{
jre.printStackTrace();
}
catch(UnsupportedEncodingException e)
{
e.printStackTrace();
}
}
假設當前' '持有'userList'成員的引用,我不明白爲什麼這不起作用。你能否提供實際和預期產出的例子? – GenericJon