WSO2 Governance Registry - Developer Guide [ Documentation Index ]

WSO2 Governance Registry - Developer User Guide

Creating a Custom User Interface in WSO2 Governance Registry

Custom UIs are user preferred way to add their own UI implementations into the registry. It is associated with Media types. CustomUIServiceClient class is needed to add custom UIs.

Writing a Sample Custom UI

1. Create your own java class to process the JSP form.

2. Create an instance for CustomUIServiceClient in your java class.

3. CustomUIServiceClient mainly has three methods. User can apply these methods to add,edit or update their forms.

4. Here the user has to specify the Media type of the resource to add or edit the resource details. for eg. public static void addStaffDetail(HttpServletRequest request, ServletConfig config, HttpSession session) throws UIException {

CustomUIServiceClient customUIServiceClient = new CustomUIServiceClient( config, session);

String parentPath = request.getParameter("parentPath");

String resourceName = request.getParameter("resourceName");

String staffID = request.getParameter("staffID");

String staffTitle=request.getParameter("staffTitle");

OMFactory fac = OMAbstractFactory.getOMFactory();

OMElement SID = fac.createOMElement("staffID"", null);

OMElement ST = fac.createOMElement("staffTitle", null);

SID.addAttribute("RID",staffID, null);

ST.addAttribute("RT", staffTitle, null);

SID.addChild(ST);

String content = SID.toString();

customUIServiceClient.addTextContent(parentPath, resourceName, mediaType, description, content);


}

5. User has to write a component.xml file which should be kept in META-INF directory.

Writing Component.xml file

Component.xml contains the CustomUI configuration. User has to define the

for example, <component xmlns="http://products.wso2.org/carbon">

<customUI>

<uiType>view</uiType>

<mediaType>text/staff</mediaType>

<uiPath>../jsp/staff_main_ajaxprocessor.jsp</uiPath>
</customUI>
<customUI>

<uiType>add</uiType>

<mediaType>text/staff</mediaType>

<uiPath>../jsp/staff_add_ajaxprocessor.jsp</uiPath>
</customUI>
</component>

Running the Custom UI with Registry

1. Drop your jars into "GREG_HOME/webapps/ROOT/WEB-INF/plugins".

2. Edit the bundle info detail that is in the "bundles.info" file which is located at "GREG_HOME/webapps/ROOT/WEB-INF/eclipse/configuration/org.eclipse.equinox.simpleconfigurator".

for eg.

org.wso2.carbon.registry.customUI,2.0.2,file:plugins/org.wso2.carbon.registry.customUI_2.0.2.jar,10,true

3. Start the server.

4. Log in the admin console and go to the Resources menu.

5. Click "Add Resource" link to add a new resource and choose "Create custom content" from Method combo box.

6. A text box named "Media type" will be displayed, from which select " other" option from drop down button for media type.

7. Enter your media type.

8. Click "Create Content",when your custom ui will display.

Figure 1: Sample Custom User Interface

Note:- A detailed sample for creating Custom UI is available with distribution under samples directory.