I am trying to open my form with filling out every text box on click of edit button on the HTML table where all my data is stored in list and each row has edit button. When I click on edit it will redirect to edit_restaurant.jsp page from restaurant.jsp page.
My restuarant.jsp page have one HTML table list in which it has edit button on each row and I want that on click of that edit button I will redirect to edit_restaurant.jsp page where all data can fill up with the id key which is bind to my edit button.
What I want is to get the id of button in another jsp button..am using liferay custom mvc portlet so can anyone guide me that how to make it possible.
Here is the snippet of code that I have tried.
Following is my column of edit button:
<td><input type="submit" id=<%=temprest.getPrimaryKey()s%> onclick="return getbuttonId('<%=temprest.getPrimaryKey() %>')" value="edit" /></td>
...and on click of that button THE following Javascript will be invoked:
<script type="text/javascript">
function getbuttonId(sid){
// document.editform.action=url;
// document.editform.submit();
var url="<%= editURL.toString()%>";
window.location.href = url+"?sid="+sid;
return false ;
}
</script>
My portlet action url is as follows:
<portlet:actionURL name="editRestaurant" var="editURL">
</portlet:actionURL>
...and the method I am calling via portlet action url is here in my action class:
public void editRestaurant(ActionRequest reqeust,ActionResponse response) throws Exception
{
String str= reqeust.getParameter("sid");
long l=Long.valueOf(str);
//Retriev table data using Primary key
restaurant rest=restaurantLocalServiceUtil.getrestaurant(l);
//Set Attribute which has all values of specified pk.
reqeust.setAttribute("edit",rest );
// Redirect to Jsp page which has Update form.
response.setRenderParameter("jspPage","/jsps/edit_restaurant.jsp");
}
I got error like this when I click on edit function
java.lang.NoSuchMethodException: emenu.advertise.portlet.RestaurantPortlet.editRestaurant?sid=5(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
Can somebody please guide me to fix this?
@
here i want that the sid value assigned to my button id should be transfer to this string value before page is redirects
<%
String restId=request.getParameter("sid");
//can i call sid value of javascript function getbuttonId() here
%>
<portlet:actionURL name="editRestaurant" var="editURL">
<portlet:param name="key" value="<%=restId %>"/>
</portlet:actionURL>