Using Providers with Custom Applications

Imagine a widget that can display lists of orders. You can use the Info Framework so that it shows any list of orders provided through InfoListProvider.

First you must obtain a list of all available providers for the desired type, and then you would obtain a specific provider through that list.

  1. The list of all available providers for MyOrder, can be obtained done by using the InfoListProviderTracker:

    @Reference
    InfoListProviderTracker _infoListProviderTracker;
    

    Once a tracker is available, obtaining the list is as simple as invoking getInfoListProviders():

    _infoListProviderTracker.getInfoListProviders(MyOrder.class);
    

    When the user selects an item from this list, you can store the class’s name.

  2. When a specific provider is desired it can be obtained through its class name as follows:

    _infoListProviderTracker.getInfoListProvider(infoListProviderClassName);
    

Leveraging renderers from a custom application

Using renderers from a custom application is almost identical to using providers. Here is the equivalent code to what you’ve seen previously:

_infoItemRendererTracker.getInfoItemRenderers(MyOrder.class.getName());

String infoItemRendererClassName = MyOrderRenderer.class.getName();
_infoItemRendererTracker.getInfoItemRenderer(infoItemRendererClassName);
« Custom rendering of information with `InfoItemRenderer`Introduction to Liferay Forms »
Was this article helpful?
0 out of 0 found this helpful