Jump to content
We've recently updated our Privacy Statement, available here ×
  • Ad Hoc View Using Custom Groovy Functions


    Tom C
    • Features: Ad Hoc Version: v6.4 Product: JasperReports® Server

    Users can define their Groovy function and use it in TIBCO JasperReports® Server v6.4.0 Ad Hoc views.

    The following are the steps needed to make this work.

    1. Define Groovy function in BaseGroovyColumn.groovy file under deployed TIBCO JasperReports Server v6.4.0  WEB-INFgroovygroovy_column directory. For example:

      def HelloWorld(String s) {
              return "Hello World ("+ s.trim() +").";
          }
      
    2. Expose newly defined Groovy function (from step 1) to Ad Hoc Designer web UI by adding the following function definition to applicationContext-el-operators.xml configuration file under deployed TIBCO JasperReports Server v6.4.0 WEB-INF directory. For example: 

      <bean parent="functionDef">
          <property name="name" value="HelloWorld"/>
          <property name="javaType" value="java.lang.String"/>
          <property name="argumentTypes">
              <list>
                  <value>#{ objectTypeMapper.checkType('String') }</value>
              </list>
          </property>
      </bean>
      
    3. Restart server;

    4. Create Ad Hoc View from TIBCO JasperReports Server v6.4.0 Ad Hoc Designer;

    5. Using the newly created Groovy function from the Ad Hoc custom calculated measure drop down list, create a calculated measure. For example:

      1_2.png.fdc22d93bb049b4f2f5f86b01f67b669.png

      2_2.png.cc76b91f1fece148bd8a0a054ee7c5fe.png

      Note: in this example, HelloWorld() function put a prefix literal to the concatenated user name created via another calculated measure.

    6. Put the new custom measure to Ad Hoc View and the result is shown:

      3_1.png.42a6a9c16102f7b8be28d11198fafa8d.png

    Since ad hoc calculated measures (vs Domain calculated fields) are generally processed in memory, we will not able to see those functions in ad hoc cache query. For example:

    4_0.png.8550c260e2b07c197245d677b39f3b39.png


    TTC-20171027

    1_2.png.756812e4be04e8cc39fc39c0978fc8be.png

    2_2.png.289b215d8231c33d8f6a5e9280eaed5e.png

    3_1.png.4ae4f1dcf61ed0b8e48e805be604a68d.png

    4_0.png.64fc4a64e5f459246929a0a69699edd3.png


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...