Salesforce

Creating and Using Java Variables (Magic xpa 4.x)

« Go Back

Information

 
Created BySalesforce Service User
Approval Process StatusPublished
Objective
Description

Creating and Using Java Variables

Once you load the JAR file, you need to create a Java variable. You create a Java variable like any other Magic xpa variable, in the Data View Editor.

You need to set the Object Type property in the JAVA section.

Initialize a Java Variable

Java variables need to be initialized manually by a constructor. A constructor instantiates and initializes an object. Constructors are methods in which the name of the method is the same as the class itself.

You can initialize a Java variable either by updating the Java variable with an existing Java object or by running a Java method that creates a Java object.

For example, update A with Java.java.lang.String();

Using a constructor is an operation that needs to be performed only once. If this is performed a second time, a new instance of the object is created. As a consequence, you need to take special care as to where to define the constructor.

Java Variables vs Java Objects

Java variables in Magic xpa represent Java objects. The Java variable keeps only a reference to the Java object. Therefore, any properties of the Java object are not stored in the Magic xpa Java variable.

This means for example that:

  • The Magic xpa recompute mechanism works when a change is made to the Java variable (the Java object reference) and not a change to one of the Java variable properties. For example, changing the text value of Java variable A will not cause recompute when the expression A.Text is used.

ยท A Java variable should not be stored as a shared value using the SharedValSet() function. When using the SharedValSet() function for a Java variable, only the variable reference is stored as a shared value. This means that if the Java object was created in a task that is now closed, the reference stored in the shared value will refer to a non-existing object.

Reference
Attachment 
Attachment