Show TOC

Implementing a Custom Module GalleryLocate this document in the navigation structure

Use

The Module Gallery is an area where users access available modules and workspace page layouts. You can replace the standard Module Gallery with your own custom implementation. You implement your Module Gallery as a portal component.

Developing a Custom Module Gallery

The following code samples illustrate how to use the Workspaces API to retrieve information about available modules and layouts.

Modules Server Side: Get Available Modules
	//Get available modules to be presented in the Module Gallery
	public List getAvailableModules(IPortalComponentRequest request) {
		IWorkspacesService[] providersArray = RuntimeFactory.getWorkspacesRuntime().getServices(
				AbstractContentProvider.class);
		// Get available content providers	
		AbstractContentProvider[] providers = new AbstractContentProvider[providersArray.length];
		System.arraycopy(providersArray, 0, providers, 0, providersArray.length);
		List allDescriptors = new LinkedList();

		//Build content descriptors for all available content providers
		ContentFilter galleryFilter = new ContentFilter(new Availability[]{Availability.GALLERY}
				,new Type[]{Type.SHARED});
		for(int i=0;i<providers.length;i++)
		{
			AbstractContentProvider curProvider = providers[i];
			ContentDescriptor[] curDescriptors = curProvider.getContentDescriptors(galleryFilter,request.getUser(),request.getLocale());
			allDescriptors.addAll(Arrays.asList(curDescriptors));
		}
		return allDescriptors;
	}
Note

You can organize modules in the Module Gallery by the predefined categories. For more information, see Categorizing Modules in the Module Gallery.

Adding Module to Page

Call the following client-side functions to notify the APB when the user adds a module to a page.

You can get the values of the moduleContentID, moduleName,moduleIconURL parameters from the ContentDescriptor object retrieved on the server side.

Client Side: Module is Added to Page
	//Call to notify APB that the user started dragging a module onto a page
	pb_startDrag(moduleContentID, moduleName,moduleIconURL, moduleProviderID);	

	//Call to notify APB that the user added a module by clicking the Add button
	pb_addModule(moduleContentID, moduleName,moduleIconURL, moduleProviderID);
Layouts Server Side: Get Available Layouts
	//Get available layouts to be presented in the Module Gallery
	public LayoutDescriptor[] getAvailableLayouts(IPortalComponentRequest request) {
		ILayouts layouts = (ILayouts)RuntimeFactory.getWorkspacesRuntime().getService(ILayouts.class);
		LayoutDescriptor[] descriptors = layouts.getLayouts(request.getLocale(), request.getUser());
		return descriptors;
	}

On the client side, you need to implement interaction of your Module Gallery with Ajax Page Builder (APB). This interaction is bidirectional, for example:

  • When the user opens the Layouts tab, the page builder alerts the Module Gallery to highlight the currently selected layout.

    Client Side: Highlight Current Page Layout
    	//Subscribe to the APB client-side event that passes the current layout
    	EPCM.subscribeEventReliable("urn:com.sap.portal.ajaxpagebuilder", "passCurrentLayout", saveCurrentLayout);
    
    	// Implement a callback function that saves the current layout 
    	// and highlights it in the Module Gallery													
    	function saveCurrentLayout(data)  	{
    	var currentLayoutID = data.dataObject;
    	//...
    	}
    
    	//When the Layouts tab opens, call the function that causes APB 
    	//generate the passCurrentLayout event
    	pb_getCurrentLayout();
  • When the user selects another layout, the Module Gallery alerts APB to apply the new layout.

    You can get the values of the layoutXML and layoutID parameters from the LayoutDescriptor object retrieved on the server side.

    Client Side: Layout is Selected
    	// Call to alert APB to apply the selected layout
    	pb_setLayout(layoutXML,layoutID);
API Reference

For the client-side API reference, see Client-Side Module Gallery API and Client-Side Layout API.

Integrating the Custom Module Gallery
  1. Deploy your custom Module Gallery portal component.

  2. Navigate to Start of the navigation path Workspace Administration Next navigation step  Configuration Next navigation step Custom Screens End of the navigation path.

  3. In the Module Gallery Component field, enter the name of your component in the <application name>.<component name> format.