Extension class

The extension classes on the views enable to customize in the same time the generated views and the developed views by branching off the class com.axemble.vdoc.sdk.providers.BaseViewProvider and implementing the interface com.axemble.vdp.ui.core.providers.ICollectionModelViewProvider.

These view extension classes may be defined either in the generated views administration, either directly in the XML description of a view-type screen.

Example of defining a generated view extension class

<definition catalog="EDUCATION" catalogType="0" extensionClasses="com.vdocsoftware.education.extensions.SimpleViewExtension" type="treatment">
  <filters>
[…]

To develop a view extension class, you just have to branch off the class named BaseViewExtension. The full name of the class is: com.axemble.vdoc.sdk.view.extensions.BaseViewExtension.

Method of the BaseViewExtension class

public abstract class BaseViewExtension implements Serializable {
  // initialization
  public void init();
  
  // accessing the graphical element and the view template
  protected final CtlAbstractView getView();
  protected final ICollectionViewModel getModel();

  // accessing the modules
  final public IWorkflowModule getWorkflowModule();
  final protected ISiteModule getSiteModule();

  // events linked to the generated views
  public boolean onPrepareView( Definition viewDefinition );
  public String onPrepareSQL( String sqlQuery );
  
  // events linked to the view construction
  public void onPrepareColumns( List viewModelColumns );
  public abstract void onPrepareItem( ViewItem item );

  public boolean onReady();
}

Example of view extension implementation

This example shows how to add columns of different types to the original view and how to supply the view elements by working on the view templates. This development type may be implemented both for the generated views and the developed views (based on view providers).

It shows also how to use display areas through templates. Indeed, for each added column, it is possible to specify a display area that will be interpreted by the navigation framework depending on the execution environment used (Easysite, Portal or alone).

The values corresponding to the display areas are provided in the navigation framework via the class ViewModelColumn:

  • ZONE_PROPERTIES
  • ZONE_EXTENDED_PROPERTIES
  • ZONE_ADDITIONAL_PROPERTIES
  • ZONE_TITLE
  • ZONE_DATE
  • ZONE_ACTOR
  • ZONE_ICON
  • ZONE_DESCRIPTION
  • ZONE_THUMBNAIL
  • ZONE_CONTENT
  • ZONE_ATTACHMENTS
  • ZONE_PATH

Summary table of display modes by specified area

Area/Mode Link List Table Thumbnail
Title On the link left On the link left On the link left On the link left
Icon Link label Link label Link label Link label
Description Tooltip Displayed Tooltip Tooltip
Miniature Tooltip Tooltip Tooltip Displayed
Date Tooltip Displayed Displayed Tooltip
Operator Tooltip Displayed Displayed Tooltip
Attached documents Tooltip Tooltip Displayed Tooltip
Path Tooltip Displayed Tooltip No displayed
Main properties Tooltip Displayed Displayed Tooltip
Secondary properties Tooltip Displayed Tooltip Tooltip
Additional properties No displayed Tooltip Tooltip No displayed

Code example

public class SimpleViewExtension extends BaseViewExtension {
    public void onPrepareColumns(List viewModelColumns) {
        // columns construction
        ViewModelColumn propertyColumn = new ViewModelColumn("actions", "LG_ACTIONS");
        propertyColumn.setZone(ViewModelColumn.ZONE_TITLE);
        viewModelColumns.add(propertyColumn);

        propertyColumn = new ViewModelColumn("text1", "LG_TEXT1");
        propertyColumn.setZone(ViewModelColumn.ZONE_TITLE);
        viewModelColumns.add(propertyColumn);

        propertyColumn = new ViewModelColumn("text2", "LG_TEXT2");
        propertyColumn.setZone(ViewModelColumn.ZONE_TITLE);
        viewModelColumns.add(propertyColumn);

        propertyColumn = new ViewModelColumn("text3", "LG_TEXT2");
        propertyColumn.setZone(ViewModelColumn.ZONE_TITLE);
        viewModelColumns.add(propertyColumn);

        super.onPrepareColumns(viewModelColumns);
    }

    public void onPrepareItem(ViewItem item) {
        final ViewModelItem viewModelItem = item.getViewModelItem();

        CtlButton addButton = new CtlButton("add", new CtlText("Ajouter au panier"));
        addButton.addActionListener(new ActionListener() {
            public void onClick(ActionEvent event) {
                try {
                    getSiteModule().getMessageController().
                            sendMessage("basket", BasketHandler.IEventTypes.ADD,
                                    ((IStorageKey) viewModelItem.getKey()).toString());
                } catch (SiteModuleException e) {
                    Navigator.getNavigator().processErrors(e, true);
                }
            }
        });

        // positioning widgets for each column
        viewModelItem.setValue("actions", addButton);
        viewModelItem.setValue("text1", "Bonjour");
        viewModelItem.setValue("text2", "Salut");
        viewModelItem.setValue("text3", new CtlButton("add", new CtlText("Autre")));
    }
}
Info

The possibility to add graphical elements directly as value of a property of a ViewModelItem object is visible here. If several graphical elements must be added on a same cell, you should use an intermediate object of java.util.LinkedList type.

For the case of customized views, it is possible to modify the original view definition as well as the SQL constraints (advanced mode).

Modifying the original definition of a view

In this example a new constraint is created. It constrains the field « fldUser » to the value of the connected user protocol URI.

public boolean onPrepareView( Definition viewDefinition ) {
	try {
		// recovering the current constraints
		Fieldgroup fieldGroup = (Fieldgroup)viewDefinition.getFilters().getFieldgroup();
		
		ObjectFactory objFactory = new ObjectFactory();
		
		// creating a new constraint
		Field fieldNo = (Field)objFactory.createField();
		fieldNo.setName( "fldUser" );
		fieldNo.setValue( getWorkflowModule().getLoggedOnUser().getProtocolURI() );
		
		// adding a constraint
		fieldGroup.getFieldgroupOrField().add( fieldNo );
	} catch( Exception e ) {
		Navigator.getNavigator().processErrors( e, true );
		return false;
	}
	return super.onPrepareView( viewDefinition );
}