The navigation connector allows the designer to specify, through the form editor, three actions on form elements:
The purpose of this example is to give you an overview of the various mechanisms the Connectors Framework brings to you.
Developing a connector is quite straightforward. You just need to create the following elements:
This file should be available from the relative path "WEB-INF\storage<custom><connectors>\education-navigation.xml".
<?xml version="1.0" encoding="UTF-8"?>
<connectors>
<connector name="navigation" label="navigation-connector.label" description="navigation-connector.description" version="1.0" company="Visiativ Software">
<services>
<service name="hideElements" label="service.navigation.hideElements.label" description="service.navigation.hideElements.description" useExternalDataConnection="false">
<class qualifiedName="com.axemble.education.connectors.navigation.HideElementsServiceConnector" />
<icons>
<icon name="small" path="navigation/hidefield.png" />
<icon name="medium" path="" />
<icon name="large" path="" />
</icons>
<configuration>
<class qualifiedName="com.axemble.education.connectors.navigation.HideElementsServiceConnectorEditor" />
<section name="settings" label="service.navigation.hideElements.section.settings.label">
<fields>
<!-- hide elements -->
<field name="fldElementsChoices" label="service.navigation.hideElements.selectElements.label" description="service.navigation.hideElements.selectElements.description" ctrl="textselectlist" mode="write" throw-events="true" mandatory="true"
string-value="fromValue">
<options>
<option key="fromValue" labelid="LG_FROM_VALUE" />
<option key="fromField" labelid="LG_FROM_FIELD" />
</options>
</field>
<field name="fldElementsValue" label="service.navigation.hideElements.elementsValue.label" description="service.navigation.hideElements.elementsValue.description" ctrl="text" mandatory="true" maxlength="64" defaultValue="" />
<field name="fldElementsField" label="service.navigation.hideElements.elementsField.label" description="service.navigation.hideElements.elementsField.description" ctrl="selector" mandatory="true" screen="Property" method="select" multiple="true" />
<field name="fldValue" label="service.navigation.hideElements.value.label" description="service.navigation.hideElements.value.description" ctrl="checkbox" />
</fields>
</section>
</configuration>
<inputs>
<input name="iResource" type="com.axemble.vdoc.sdk.interfaces.IResource" />
<input name="iWorkflowInstance" type="com.axemble.vdoc.sdk.interfaces.IWorkflowInstance" />
</inputs>
<outputs>
<output name="result" type="java.lang.Boolean" />
<output name="error" type="java.lang.String" />
<output name="errorMessage" type="java.lang.String" />
</outputs>
<entry-points>
<connectors-library familyName="education" />
</entry-points>
<supported-events>
<front-end-events>
<resource-definition>
<form>
<events>
<event name="onAfterLoad" default="true" />
</events>
</form>
</resource-definition>
</front-end-events>
</supported-events>
</service>
<service name="mandatoryField" label="service.navigation.mandatoryField.label" description="service.navigation.mandatoryField.description" useExternalDataConnection="false">
<class qualifiedName="com.axemble.education.connectors.navigation.MandatoryFieldServiceConnector" />
<icons>
<icon name="small" path="navigation/mandatoryfield.png" />
<icon name="medium" path="" />
<icon name="large" path="" />
</icons>
<configuration>
<class qualifiedName="com.axemble.education.connectors.navigation.MandatoryFieldServiceConnectorEditor" />
<section name="settings" label="service.navigation.mandatoryField.section.settings.label">
<fields>
<field name="fldElementsField" label="service.navigation.mandatoryField.elementsField.label" description="service.navigation.mandatoryField.elementsField.description" ctrl="selector" mandatory="true" screen="Property" method="select" multiple="true" />
<field name="fldValue" label="service.navigation.mandatoryField.value.label" description="service.navigation.mandatoryField.value.description" ctrl="checkbox" />
</fields>
</section>
</configuration>
<inputs>
<input name="iResource" type="com.axemble.vdoc.sdk.interfaces.IResource" />
<input name="iWorkflowInstance" type="com.axemble.vdoc.sdk.interfaces.IWorkflowInstance" />
</inputs>
<outputs>
<output name="result" type="java.lang.Boolean" />
<output name="error" type="java.lang.String" />
<output name="errorMessage" type="java.lang.String" />
</outputs>
<entry-points>
<connectors-library familyName="education" />
</entry-points>
<supported-events>
<front-end-events>
<resource-definition>
<form>
<events>
<event name="onAfterLoad" default="true" />
</events>
</form>
</resource-definition>
</front-end-events>
</supported-events>
</service>
<service name="editField" label="service.navigation.editField.label" description="service.navigation.editField.description" useExternalDataConnection="false">
<class qualifiedName="com.axemble.education.connectors.navigation.EditFieldServiceConnector" />
<icons>
<icon name="small" path="navigation/editfield.png" />
<icon name="medium" path="" />
<icon name="large" path="" />
</icons>
<configuration>
<class qualifiedName="com.axemble.education.connectors.navigation.EditFieldServiceConnectorEditor" />
<section name="settings" label="service.navigation.editField.section.settings.label">
<fields>
<field name="fldElementsField" label="service.navigation.editField.elementsField.label" description="service.navigation.editField.elementsField.description" ctrl="selector" edit="true" screen="Property" method="select" multiple="true" />
<field name="fldValue" label="service.navigation.editField.value.label" description="service.navigation.editField.value.description" ctrl="checkbox" />
</fields>
</section>
</configuration>
<inputs>
<input name="iResource" type="com.axemble.vdoc.sdk.interfaces.IResource" />
<input name="iWorkflowInstance" type="com.axemble.vdoc.sdk.interfaces.IWorkflowInstance" />
</inputs>
<outputs>
<output name="result" type="java.lang.Boolean" />
<output name="error" type="java.lang.String" />
<output name="errorMessage" type="java.lang.String" />
</outputs>
<entry-points>
<connectors-library familyName="education" />
</entry-points>
<supported-events>
<front-end-events>
<resource-definition>
<form>
<events>
<event name="onAfterLoad" default="true" />
</events>
</form>
</resource-definition>
</front-end-events>
</supported-events>
</service>
</services>
</connector>
</connectors>package com.axemble.education.connectors.navigation; import java.util.Collection; import com.axemble.education.connectors.navigation.common.CommonNavigationServiceConnector; import com.axemble.education.connectors.navigation.common.CommonNavigationServiceConnectorEditor; import com.axemble.vdoc.sdk.interfaces.IProperty; import com.axemble.vdoc.sdk.interfaces.IResourceController; import com.axemble.vdp.utils.StringUtils; public class HideElementsServiceConnector extends CommonNavigationServiceConnector
@Override
public int execute( IContext context, int eventType, String eventName, Element customElement )
{
try
{
IResourceController resourceController = getWorkflowModule().getResourceController( getResource() );
boolean value = ( (Boolean)getServiceDefinition().getValue( CommonNavigationServiceConnectorEditor.FIELD_VALUE ) ).booleanValue();
String option = (String)getServiceDefinition().getValue( HideElementsServiceConnectorEditor.FIELD_ELEMENTS_CHOICES );
switch ( option )
{
case HideElementsServiceConnectorEditor.OPTION_FROM_VALUE :
{
String stringMarkers = (String)getServiceDefinition().getValue( HideElementsServiceConnectorEditor.FIELD_ELEMENTS_VALUE );
if ( StringUtils.isNotEmpty( stringMarkers ) )
{
stringMarkers = stringMarkers.trim();
String[] markers = StringUtils.split( stringMarkers, "," );
for ( int i = 0 ; i < markers.length ; i++ )
{
String marker = markers[i];
resourceController.showBodyBlock( marker, !value );
}
}
}
break;
case HideElementsServiceConnectorEditor.OPTION_FROM_FIELD :
{
Collection<IProperty> properties = (Collection<IProperty>)getServiceDefinition().getValue( CommonNavigationServiceConnectorEditor.FIELD_ELEMENTS_FIELD );
if ( properties != null )
{
for ( IProperty property : properties )
resourceController.setHidden( property.getName(), value );
}
}
break;
}
}
catch( Exception e )
{
String errorMessage = getErrorMessage();
this.getServiceOutputs().addOutput( OUTPUT_RESULT, Boolean.FALSE );
this.getServiceOutputs().addOutput( OUTPUT_ERROR_MESSAGE, errorMessage );
this.getServiceOutputs().addOutput( OUTPUT_ERROR_NUMBER, -900 );
buildError( eventType, errorMessage, e );
return IConnectorExecutionStatus.STOP;
}
this.getServiceOutputs().addOutput( OUTPUT_RESULT, Boolean.TRUE );
return IConnectorExecutionStatus.STOP_ASYNCHRONOUS;
}@Override
public void beforeCompletion( IContext context, Element customElement )
{
super.beforeCompletion( context, customElement );
}
@Override
public void afterCompletion( IContext context, Element customElement, boolean committed )
{
super.afterCompletion( context, customElement, committed );
}