croutledge Posted May 6, 2009 Share Posted May 6, 2009 I'm trying to use a list of my domain objects to create reports. I've been able to get the fields listed from the domain objects and can drag them on to a report. But when one of the properties is another domain object ireport is unable to see the getters in that object for me to call. i have to manually change it to $F{order}.getId() for example.Is this the only way of doing it or is it possible for ireport to provide some sort of context assist? Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted May 6, 2009 Share Posted May 6, 2009 you can map sub-objects. The result will be something like:$F{order.id}Giulio Link to comment Share on other sites More sharing options...
croutledge Posted May 7, 2009 Author Share Posted May 7, 2009 What do you mean by map? I just tried changing a field from $F{packCodeMD}.getId(), which works, to $F{packCodeMD.id} and it doesn't work. I get a line in the Report Problem Window saying File Not Found: packCodeMD.id. In the report output window i get: - net.sf.jasperreports.engine.design.JRValidationException:ÂReportÂdesignÂnotÂvalidÂ:Â ÂÂÂÂÂ 1.ÂFieldÂnotÂfoundÂ:ÂpackCodeMD.id ÂÂÂÂ atÂnet.sf.jasperreports.engine.design.JRAbstractCompiler.verifyDesign(JRAbstractCompiler.java:262) ÂÂÂÂ atÂnet.sf.jasperreports.engine.design.JRAbstractCompiler.compileReport(JRAbstractCompiler.java:144) ÂÂÂÂ atÂcom.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:525) ÂÂÂÂ atÂorg.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561) ÂÂÂÂ atÂorg.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986 Link to comment Share on other sites More sharing options...
Giulio Toffoli Posted May 7, 2009 Share Posted May 7, 2009 To map in this case means to define a field to reference a particular objecyt (that's mybean.getPackCodeMD().getId() )There are two ways to map this such of sub object, I gave you the one that is not the default. The bean path is read from the description of the field, while the name of the field is arbitrary.See the attached image. The object <personBean>.getAddress().getState() is defined as field named state. The description says how to get it from the bean that represents the current record (address.state).You should do the same for your packCodeMD.id./uploads/projects/ireport/bean_mapping.pngGiulio Link to comment Share on other sites More sharing options...
croutledge Posted May 8, 2009 Author Share Posted May 8, 2009 Fantastic. I didn't realise you can double click on an object to see its attributes and then add these as a selectable field. Thanks for the help. Carl Link to comment Share on other sites More sharing options...
croutledge Posted May 11, 2009 Author Share Posted May 11, 2009 Hitting a problem with this on one of my test reports. In my Pallet class i have an attribute of type currentPalletLocation, which itself contains a attribute of type PalletStore. Now i want to display the location attribute of the PalletStore. If i add a field via the JavaBean Datasource choosing currentPalletLocation the report will preview (not added the field to the report). If i add the field to the report and then change the expression to $F{currentPalletLocation}.getPalletStore().getLocation() it works just fine. If i add a field via the JavaBean Datasource straight to the location attribute the report doesn't even preview even when it isn't actually added to report. See error below ErrorÂfillingÂprint...ÂErrorÂretrievingÂfieldÂvalueÂfromÂbeanÂ:Âlocation net.sf.jasperreports.engine.JRException:ÂErrorÂretrievingÂfieldÂvalueÂfromÂbeanÂ:Âlocation ÂÂÂÂatÂnet.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:127) ÂÂÂÂatÂnet.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getFieldValue(JRAbstractBeanDataSource.java:100) ÂÂÂÂatÂnet.sf.jasperreports.engine.data.JRBeanCollectionDataSource.getFieldValue(JRBeanCollectionDataSource.java:104) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.setOldValues(JRFillDataset.java:822) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFillDataset.next(JRFillDataset.java:786) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.next(JRBaseFiller.java:1413) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:111) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:899) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:821) ÂÂÂÂatÂnet.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:89) ÂÂÂÂatÂnet.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:628) ÂÂÂÂatÂnet.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:544) ÂÂÂÂatÂcom.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:921) ÂÂÂÂatÂorg.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561) ÂÂÂÂatÂorg.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986) CausedÂby:Âjava.lang.NoSuchMethodException:ÂUnknownÂpropertyÂ'location' ÂÂÂÂatÂorg.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1122) ÂÂÂÂatÂorg.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:686) ÂÂÂÂatÂorg.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:715) ÂÂÂÂatÂorg.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:290) ÂÂÂÂatÂnet.sf.jasperreports.engine.data.JRAbstractBeanDataSource.getBeanProperty(JRAbstractBeanDataSource.java:115) ÂÂÂÂ...Â14Âmore Print not filled. Try to use an EmptyDataSource... Any idea's? Cheers Carl Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now