Customizable selectors

Resume

A new feature is now available in VDoc 14, it is the customizable selectors.
VDoc SDK gives us the opportunity to create our own selectors which offer more flexibility and ease to use.

Opening the selector from a field

Compatible mode

You already know the fields SelectorField (many articles on this subject), which already allows us since several versions to open a view as a selector.
This mode has been retained and it allows you as before calling your view directly from a SelectorField. This mode should not have any impact on your previous developments. However, it does not take advantage of the new selector and it's an outdated mode that allows migration cheaply.

Customizable mode

This mode use a screen of type "selector" that can integrate one or more views with new predictive capabilities, research, etc. This is the topic that we will discuss here.

A screen of type selector

XML definition of the screen

This type of screen is defined in the "navigation" file like other VDoc screens type . This type of screen doesn't have Java provider, however, we will see that it's the integrated views that carry their provider which may be enhanced by interfaces associated to the selector.

XML definition prototype
<definition name="example">
<screens>

<selector name="NameOfTheScreenSelector" action="NameOfTheActionOrMethod" predictive="true/false">
    <links>
        <link name="LinkName1" label="Link label 1" default="true/false">
            <view name="ViewName" label="View Label" 
                    provider="com.vdoc.<...>.ProviderUsedByTheView" 
                    selectable="true/false" 
                    paginable="true/false" 
                    filterable="true/false"
                    search="true/false"
                    globalFilterColumns="columnName2;columnNameX;...;columnName2 ">

                <column name="columnName1" label="Column label 1" />
                <column name="columnName1" label="Column label 2" />
                 ...
                <column name="columnNameX" label="Column label x" />
            </view>
        </link>

        <link name="LinkName2 ...>
            <view ...>
                <column ... />
                 ...
            </view>
        </link>

        ...

    </links>
    
    <currentSelection>
        <column name="columnName1" label="Column label 1" />
        <column name="columnName2" label="Column label 2" />
         ...
        <column name="columnNameX" label="Column label x" />
    </currentSelection>
    
    <lastSelection>
        <column name="columnName1" label="Column label 1" />
        <column name="columnName2" label="Column label 2" />
         ...
        <column name="columnNameX" label="Column label x" />
    </lastSelection>
  
</selector>

</screens>
</definition>

Tag options

Selector tag
Attribute Description
name The screen name. Ex: screen=NameOfScreenSelector (to put in the Development Attributes of a Customizable field).
action The method name. Ex: method=NameOfTheActionOrMethod (to put in the Development Attributes of a Customizable field).
predictive If set to true, it allows the auto-complete search directly in the field. No needs to open the search screen. Note: the predictive research will use the link that matches the first of the following conditions: * The link with search=true else, * The link with default=true else, * The first link defined.
link tag
Attribute Description
name The link name.
label The label displayed to the left section of the screen. Default: LG_SELECTOR_DEFAULT_LINK_LABEL (Elements)
default (Default: false) When set to true, this link is displayed by default at the opening of the screen. Note: A link have to be set to true and only one. The predictive search use the default link for its research.
view tag
Attribute Description
name The link name.
label The label displayed to the left section of the screen.
provider Provider class associated to the view.
globalFilterColumns Defines the columns that can be filtered (filter field in the top of the screen). Ex: globalFilterColumns="columnName1, columnName3, ..." Note: The label associated to the column will be displayed in the filter field.
filterable Specifies if filters should be positioned.
search (Default : false) If set to true, this link will be used for plain searches by the predictive search (in the Search tab). Specially useful with tree structured selectors which permits to search children. Note: search begins when you type some text in the search field. Only one view can have this attribute set to true, and it can't be set to true if the default link is also set to true.
currentSelection tag

In the case of a multiple selector, it allows to define the columns that will be displayed for the items already selected.

lastSelection tag

The new selectors system stores the items you have recently selected. This tag allows you to define the columns that will be displayed in the view "Lately selected".

The view providers for selectors

Note that the views of selectors will have to implement the ICollectionViewProvider interface. See this topic to understand how to manipulate the new interface.

Reminder
ICollectionModelViewProvider interface is now deprecated in Version 14.
Overview

To summarize, the view provider will inherit of a BaseViewProvider and will implement a ICollectionViewProvider.
It will then be possible to enhance the view provider with additional interfaces (ISelectorViewProvider), giving us SDK inputs points that will be called.

ISelectorViewProvider Interface
public interface ISelectorViewProvider
{
     /**
      * Called method every time you open the advanced selector
      */
     public void onOpen();
    
     /**
      * Called method before the display of the view in the explorer.
      */
     public void onActivate();
}

The field selector : SelectorInputComponent

This selector is used to navigate to your screen selector via its name and method.

    <field ctrl="com.axemble.vdp.ui.framework.widgets.components.sys.forms.SelectorInputComponent" ...  
        screen="selectorName" method="selectorAction" />
Note
It is now recommended that when you create a selector in this new mode, to no longer use the SelectorField but to use the SelectorInputComponent.

Example

The following development shows user selector in the directory. This selector will have the features:

  • A search view
  • A default view corresponding to all users (the user has the right to view)
  • A view of the users in my organization (that link will be hidden for sysadmin)
Code and setup

Download customizable selector example

File included:

  • ExampleSelector.xml - XML Definition of the screen selector
  • AllUsersViewProvider.java - View provider showing all users
  • OrganizationUsersViewProvider.java - View provider showing users within the same organization of the currently logged-on user
  • testSelector.zip - VDoc application exported