Using the Expression Builder, you can create expressions or conditions that perform computations on data values provided by the Data Dictionary or by end users. Correspondence Management uses the result of the expression evaluation to select assets such as text, images, lists, and conditions and insert them in the correspondence as required.
The Expression Builder internally uses JSP EL libraries, so the expression adhere to JSPEL syntax. For more information, see Example expressions.
The operators that are available for use in expressions are available in the top bar of the expression builder.
Here are a few commonly used JSP EL examples that you can use in your Correspondence Management solution:
You can find more information in the JSP EL specification. The client-side expression manager does not support certain variables and functions in the JSP EL specification, specifically:
Collection indexes and map keys (using the [] notation) are not supported in variable names for expressions evaluated on the client-side.
The following are the parameter types or return types of functions used in expressions:
Remote functions provide the capability to use custom logic in expressions. You can write custom logic to be used in expression as a method in Java and same function can be used inside expressions. Available remote functions are listed under the “Remote Functions” tab on the left side of Expression Editor.
You can create a custom bundle to export your own remote functions for use inside expressions. To create a custom bundle to export your own remote functions, perform the following tasks. It demonstrates how to write a custom function that capitalizes its input string.
Define an interface for the OSGi service containing methods which are being exported for use by Expression Manager.
Declare methods on the interface A and annotate them with the @ServiceMethod annotation (com.adobe.exm.expeval.ServiceMethod). Expression Manager ignores any unannotated methods. The ServiceMethod annotation has the following optional attributes which can also be specified:
package mergeandfuse.com;
import com.adobe.exm.expeval.ServiceMethod;
public interface RemoteFunction {
@ServiceMethod(enabled=true,displayName="Returns_all_caps",description="Function to convert to all CAPS", familyId="remote")
public String toAllCaps(String name);
}
The parameters of the methods can also be optionally annotated using the @ServiceMethodParameter annotation (com.adobe.exm.expeval.ServiceMethodParameter). This annotation is only used for specifying human-readable names and descriptions of method parameters for use in the authoring user interface. Ensure that the parameters and return-values of the interface methods belong to one of the following types:
Define the implementation of the interface, configure it as an OSGI service and define the following service properties:
@org.apache.felix.scr.annotations.Properties({
@org.apache.felix.scr.annotations.Property(name = "connectors.jsoninvoker", boolValue = true),
@org.apache.felix.scr.annotations.Property(name = "connectors.jsoninvoker.alias", value = "<service_id>"),
@org.apache.felix.scr.annotations.Property(name = "exm.service", boolValue = true)})
The exm.service=true entry instructs Expression manager, that the service contains remote functions suitable for use in expressions. The <service_id> value must be a valid Java identifier (alphanumeric,$, _ with no other special characters). This value, prefixed with the REMOTE_ keyword, forms the prefix which is used inside expressions. For example, an interface with an annotated method bar() and the service ID foo in the service properties, can be referenced inside expressions using REMOTE_foo:bar().
package mergeandfuse.com;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
@Component(metatype = true, immediate = true, label = "RemoteFunctionImpl")
@Service(value = RemoteFunction.class)
@org.apache.felix.scr.annotations.Properties({
@org.apache.felix.scr.annotations.Property(name = "connectors.jsoninvoker", boolValue = true),
@org.apache.felix.scr.annotations.Property(name = "connectors.jsoninvoker.alias", value = "test1"),
@org.apache.felix.scr.annotations.Property(name = "exm.service", boolValue = true)})
public class RemoteFuntionImpl implements RemoteFunction {
@Override
public String toAllCaps(String name) {
System.out.println("######Got######"+name);
return name.toUpperCase();
}
}
Below are sample archives to use:
GoodFunctions.jar.zip
GoodFunctions.zip