Showing posts with label Delete Data from database. Show all posts
Showing posts with label Delete Data from database. Show all posts

Sunday, 7 July 2013

How to update and delete data in database using search container in liferay?

Hi Liferay members , in my previous post i have explained to retrieve data from database this time i am going to show you how to update those data from database .
Just follow this simple steps

list.jsp 

1)Open list.jsp where you have written code for search container to retrieve data and this following line in that container.

<liferay-ui:search-container-column-jsp path="/button.jsp" />

button.jsp

1)Now create button.jsp and add following snippet of code


<%ResultRow rslt=(ResultRow)request.getAttribute(WebKeys.SEARCH_CONTAINER_RESULT_ROW) ;

Foo f=(Foo)rslt.getObject();

String prk=String.valueOf(f.getFooId());

%>
//Button menu tag
<liferay-ui:icon-menu>

//Create “editProduct” method in Action file
<portlet:actionURL var="editURL" name="editProducts">
<portlet:param name="edit" value="<%=prk %>"/>
</portlet:actionURL>

// ”EDIT” button for Update event. 
<liferay-ui:icon image="edit" message="Edit" url="<%=editURL.toString() %>"/>
</liferay-ui:icon-menu>

//Creates "deleteproducts" method in action file
<portlet:actionURL var="deleteURL" name="deleteproducts">
<portlet:param name="edit" value="<%=prk %>"/>
</portlet:actionURL>
<liferay-ui:icon-delete url="<%=deleteURL.toString() %>" />