В моем файле xhtml мне нужно передать значение employeeId и employeeName из p: dialog в отчет jasper. Я уже создал jrxml (файл), поля - $ F {employeeId} и $ F {usageementName}. Когда я выбираю кнопку команды, она должна передавать employeeId и employeeName в отчет jasper и генерировать как .pdf. Но я не знаю, как передать employeeId и employeeName в JRBeanCollectionDataSource.как передать значения bean в отчет jasper
<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>
Bean:
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