Home Forums Presentation Jasper Reports Retrieving all enumeration values in jasper report

Viewing 4 reply threads
  • Author
    • #9231


      I am trying to retrieve complete enumeration value of Occupation enum in my jasper report and accordingly trying to highlight the actual value (for eg. Armed Forces) from the application so as to differentiate the actual value from the application in the complete set.

      I had tried to assign  java.lang.object  to my field in report so that it could retrieve the complete collection  and then calling the required enum,but the values are not getting populated.I had even tried through query but it didn’t worked.

      Is there any other way to retrieve the complete enumeration values in jasper report and highlight the actual value?

    • #9239
      Owen PondOwen Pond

      Hi Shreelekha,

      The most efficient approach is to create a sub-report and have the sub-report read from the Occupation enumeration for which you want to display all values. You can pass in the “selected” occupation to the sub-report as a parameter and then write report side logic which highlights the matching occupation in the list returned by the read.

      Let me know if this makes sense.


    • #9247

      Hi Owen,

      Thanks for the response. I tried to create a subreport and then accordingly call it in my main report but it didn’t worked,I am getting only the actual value and not complete set of values. I am retrieving occupation caption ; if  only occupation is called then I get a blank report.

      Also I have to retrieve 7 different  enum data for different fields so creating a subreport for every field might hinder the performance when launching a report which can also lengthen the report.



    • #9257
      Owen PondOwen Pond

      Hi Shreelekha,

      If I understand correctly you are trying to produce something like this.

      Example Report

      In which case the sub report solution will work, but there is a trick to the configuration, which is to not pass in an association to the sub report. Passing in an association will filter the sub report result set which in this case would cause only 1 enumeration value to appear. Try the following in your sub report configuration.

      <reportElement x=”600″ y=”0″ width=”230″ height=”40″ uuid=”7de28682-1ff2-4a96-85bb-597e9e0bcdd9″/>
      <subreportParameter name=”NEXJ_LAZY”>
      <subreportParameter name=”NEXJ_REPOSITORY”>
      <subreportParameter name=”NEXJ_REPORT_CACHE”>
      <subreportParameter name=”NEXJ_PARENT”>
      <subreportParameter name=”REPORT_RESOURCE_BUNDLE”>
      <subreportParameter name=”statusValue”>
      <subreportParameterExpression><![CDATA[$F{status value}]]></subreportParameterExpression>

      Notice that there is no association parameter passed to the sub report.

      In the sub report, the query should look something like this

      (caption value)

      And you can create the conditional formatting like this

      <style name=”ConditionalBackground”>
      <style mode=”Opaque” backcolor=”#EFF74A” fill=”Solid”/>

      In regards to your performance concerns; All enumerations are cached on the server so there will be no extra queries sent to the server. If you don’t want to maintain one sub report for each enumeration, then you can create something more generic by querying EnumDisplayBase instead and passing in the enum type and value that you want to highlight.



    • #9265

      Thanks Owen. It worked.

Viewing 4 reply threads
  • You must be logged in to reply to this topic.