Generating a Static Wrapper

To generate a static wrapper class, proceed as follows:

  1. Configure the Ant task file as described in Configuring the Ant Task File.

  2. Execute the Ant task file as described in Executing the Ant Task File.

For an example of how to use a static and dynamic wrapper, see Example of Using Static and Dynamic Wrappers.

Configuring the Ant Task File

When a new OpenL Tablets project is created, it already contains an Ant task file GenerateJavaWrapper.build.xml located in the build folder. When the file is executed, it automatically creates wrapper Java classes for specified Excel files. The Ant task file must be adjusted to match contents of the specific project.

For each Excel file, an individual <openlgen> section must be added between the <target> and </target> tags.

Each <openlgen> section has a number of parameters that must be adjusted. The following table describes <openlgen> section parameters:

Parameters in the <openlgen> section

Parameter

Description

openlName

OpenL configuration to be used. For OpenL Tablets, the following value must always be used:

org.openl.xls

userHome

Location of user defined resources relative to the current OpenL Tablets project.

srcFile

Reference to the Excel or Word file for which a wrapper class must be generated.

targetClass

Full name of the wrapper class to be generated.

OpenL Web Studio recognizes modules in projects by wrapper classes and uses their names in the user interface. If there are multiple wrappers with identical names, only one of them is recognized as a module in OpenL Web Studio.

displayName

End user oriented title of the file that appears in OpenL Web Studio.

targetSrcDir

Folder where the generated wrapper class must be placed.

The following is an example of the GenerateJavaWrapper.build.xml file:

<project name="GenJavaWrapper" default="generate" basedir="../">

<taskdef name="openlgen" classname="org.openl.conf.ant.JavaWrapperAntTask"/>

<target name="generate">

<echo message="Generating wrapper classes..."/>

<openlgen openlName="org.openl.xls" userHome="."

srcFile="rules/Rules.xls"

targetClass="com.exigen.claims.RulesWrapper"

displayName="Rule table wrapper"

targetSrcDir="gen"

</openlgen>

<openlgen openlName="org.openl.xls" userHome="."

srcFile="rules/Data.xls"

targetClass=" com.exigen.claims.DataWrapper"

displayName="Data table wrapper"

targetSrcDir="gen"

</openlgen>

</target>

</project>

Executing the Ant Task File

To execute the Ant task file and generate wrappers, proceed as follows:

  1. In Eclipse, refresh the project.

  2. Execute the Ant task XML file as an Ant build.

  3. Refresh the project again so that wrapper classes are displayed in Eclipse.

Once wrappers are generated, the corresponding Excel or Word files can be used in the solution.