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

Viewing 4 reply threads
  • Author
    Posts
    • #9231

      Hello,

      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?

      0
    • #9239
      Owen PondOwen Pond
      Participant

      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.

      Regards

      0
    • #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.

      Thanks!

       

      0
    • #9257
      Owen PondOwen Pond
      Participant

      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.

      <subreport>
      <reportElement x=”600″ y=”0″ width=”230″ height=”40″ uuid=”7de28682-1ff2-4a96-85bb-597e9e0bcdd9″/>
      <subreportParameter name=”NEXJ_LAZY”>
      <subreportParameterExpression><![CDATA[Boolean.TRUE]]></subreportParameterExpression>
      </subreportParameter>
      <subreportParameter name=”NEXJ_REPOSITORY”>
      <subreportParameterExpression><![CDATA[$P{NEXJ_REPOSITORY}]]></subreportParameterExpression>
      </subreportParameter>
      <subreportParameter name=”NEXJ_REPORT_CACHE”>
      <subreportParameterExpression><![CDATA[$P{NEXJ_REPORT_CACHE}]]></subreportParameterExpression>
      </subreportParameter>
      <subreportParameter name=”NEXJ_PARENT”>
      <subreportParameterExpression><![CDATA[$F{:instance}]]></subreportParameterExpression>
      </subreportParameter>
      <subreportParameter name=”REPORT_RESOURCE_BUNDLE”>
      <subreportParameterExpression><![CDATA[$P{REPORT_RESOURCE_BUNDLE}]]></subreportParameterExpression>
      </subreportParameter>
      <subreportParameter name=”statusValue”>
      <subreportParameterExpression><![CDATA[$F{status value}]]></subreportParameterExpression>
      </subreportParameter>
      <subreportExpression><![CDATA[((nexj.core.reporting.jasper.DataSource)
      $P{REPORT_DATA_SOURCE}).loadSubReport(“cmEventMeetingRequestSub”)]]></subreportExpression>
      </subreport>

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

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

      (roadshow:MeetingRequestStatusEnum
      (caption value)
      ()
      ()
      )

      And you can create the conditional formatting like this

      <style name=”ConditionalBackground”>
      <conditionalStyle>
      <conditionExpression><![CDATA[$F{value}.equals($P{statusValue})]]></conditionExpression>
      <style mode=”Opaque” backcolor=”#EFF74A” fill=”Solid”/>
      </conditionalStyle>
      </style>

      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.

      Regards

      Owen

      0
    • #9265

      Thanks Owen. It worked.

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