View

The “view” element may be used in two different ways:

  • child tag when used in the context of a form or an explorer templatescreens;
  • parent tag when used in the context of portlets or easysite contents.

The user interface associated with the “view” tag is produced by the following class template: com.axemble.vdp.ui.framework.composites.xml.XMLView.

In the case of views, two provider classes may be used:

  • standard view: com.axemble.vdoc.sdk.providers.BaseViewProvider ;
  • browsing view: com.axemble.vdoc.sdk.providers.BaseBrowsableViewProvider ;

The view tag may be completed by the attributes displayed in the following table:

Attributes Description
selectable indicates if the view displays “tick boxes” elements enabling to select lines.
filterable indicates if the filters must be placed
paginable indicates if the page per page is supported
rowsperpage indicates the lines number displayed per page

Sub-tags:

Tag Description
button Enables to add a navigation button in the interface
image Enables to place image buttons associated to commands or navigation.
link Enables to specify a browsing link.
column Enables to specify the columns of the view.

XML example

<view name="DEMO" label="LG_DEMO" selectable="true" provider="com.axemble.education.providers.demo.DemoViewProvider" paginable="true" filterable="true">
    <button name="delete" label="LG_DELETE" style="style2">
        <action class="DEMO" name="delete"/>
    </button>
    <button name="import" label="LG_IMPORT" style="style3">
        <action class="DEMO" name="import"/>
    </button>
    <link name="browse">
        <action class="DEMO" name="browse"/>
    </link>
    <image name="delete">
        <action class="DEMO" name="delete"/>
    </image>
    <image name="properties">
        <action class="DEMO" name="edit"/>
    </image>
    <image name="security">
        <action class="DEMO" name="security"/>
    </image>
    <column name="column1" label="LG_COLUMN1" zone="title"/>
    <column name="column2" label="LG_COLUMN2"/>
    <column name="column3" label="LG_COLUMN3"/>
    <column name="column4" label="LG_COLUMN4"/>
</view>

Simple form preview

application list application list

Create a view provider

This involves defining an XML and associating a provider with it which will always inherit from BaseViewProvider, but will implement the ICollectionViewProvider interface.

Method implementation

  /**
   * Retourne tous les objets natifs à présenter dans la vue (vos objets), le type de ces objets correspond au generics de la classe (T).
   */
  public abstract Collection getObjects();

  /**
   * Converti un objet (de type T) en tant que ViewModelItem
   */
  public ViewModelItem fetchLine( T object );

  /**
   * Appelé avant de récupérer les objets
   */
  public void beforeFetch();

  /**
   * Appelé après avoir fait tous les fetchLine()
   */
  public void afterFetch();

Implementation example

public class NewViewProvider extends BaseViewProvider implements ICollectionViewProvider<MyCustomObject> {

	private static com.axemble.vdoc.sdk.utils.Logger LOG = com.axemble.vdoc.sdk.utils.Logger.getLogger(NewViewProvider.class);

	public NewViewProvider (INavigateContext context, CtlAbstractView view) {
		super(context, view);
	}

	/**
	 * @see com.axemble.vdp.ui.core.providers.ICollectionViewProvider#getObjects()
	 */
	@Override
	public Collection<MyCustomObject> getObjects() {
		return getAllMyCustomObjects();
	}

	/**
	 * @see com.axemble.vdp.ui.core.providers.ISelectableViewProvider#fetchLine(java.lang.Object)
	 */
	@Override
	public ViewModelItem fetchLine(MyCustomObject customObject) {
		ViewModelItem viewModelItem = new ViewModelItem(customObject);
		viewModelItem.setValue("label", customObject.getLabel());
		return viewModelItem;
	}
	
	/**
	 * @see com.axemble.vdp.ui.core.providers.base.AbstractViewProvider#beforeFetch()
	 */
	@Override
	public void beforeFetch() {
		LOG.error("Called before fetching");
	}

	/**
	 * @see com.axemble.vdp.ui.core.providers.base.AbstractViewProvider#afterFetch()
	 */
	@Override
	public void afterFetch() {
		LOG.error("Called after fetching");
	}
}

Source: https://wiki.myvdoc.net/xwiki/bin/view/Dev+Floor/HowToBuildNewVDoc14Views