In portlet class of your sample portlet add code on similar lines as given below:
package com.sify.npp.portlet;
import java.rmi.RemoteException;
import java.util.List;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.util.bridges.mvc.MVCPortlet;
import com.sify.npp.businesslogic.model.Metadata;
import com.sify.npp.businesslogic.model.impl.MetadataImpl;
import com.sify.npp.businesslogic.service.MetadataLocalServiceUtil;
/**
* Portlet implementation class Metadata
*/
public class MetadataPortlet extends MVCPortlet {
public Metadata createMetadata(ActionRequest actionRequest,ActionResponse actionResponse) throws PortalException, SystemException, RemoteException {
long metadataId = 0L;
metadataId = CounterLocalServiceUtil.increment(this.getClass().getName());
Metadata metadata = new MetadataImpl();
metadata.setListtypeid(metadataId);
metadata.setName("tintin");
metadata.setType_("com.sify.npp.businesslogic.model.Metadata");
MetadataLocalServiceUtil.addMetadata(metadata);
return metadata;
}
public List<Metadata> displayMetadata(ActionRequest actionRequest,ActionResponse actionResponse) throws PortalException, SystemException, RemoteException {
int start=0;
int end=20;
List<com.sify.npp.businesslogic.model.Metadata> listMetadata = MetadataLocalServiceUtil.getMetadatas(start, end);
actionRequest.setAttribute("metadataList", listMetadata);
return listMetadata;
}
}write jsp code whcih takes calls from UI to portlet class given above as:
<%@page import="javax.portlet.PortletURL"%>
<%@page import="javax.portlet.ActionRequest"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
<%@ include file="/html/metadata/init.jsp" %>
<h1>Create Metadata Form</h1>
<%
PortletURL updateMetadataURL = renderResponse.createActionURL();
updateMetadataURL.setParameter(ActionRequest.ACTION_NAME, "createMetadata");
%>
<aui:form name="fm" method="POST" action="<%=updateMetadataURL.toString() %>">
<aui:input name="name" label="Metadata Name:"/>
<aui:button type="submit" value="Save"/>
</aui:form>Hope this helps