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.
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; }
You can organize modules in the Module Gallery by the predefined categories. For more information, see Categorizing Modules in the Module Gallery.
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);
//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);
For the client-side API reference, see Client-Side Module Gallery API and Client-Side Layout API.
Deploy your custom Module Gallery portal component.
Navigate to
.In the Module Gallery Component field, enter the name of your component in the <application name>.<component name> format.