Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to redirect to another JSP page via JavaScript in MVC portlet?
    primarykey
    data
    text
    <p>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.</p> <p>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.</p> <p>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.</p> <p>Here is the snippet of code that I have tried.</p> <p>Following is my column of edit button:</p> <pre><code>&lt;td&gt;&lt;input type="submit" id=&lt;%=temprest.getPrimaryKey()s%&gt; onclick="return getbuttonId('&lt;%=temprest.getPrimaryKey() %&gt;')" value="edit" /&gt;&lt;/td&gt; </code></pre> <p>...and on click of that button THE following Javascript will be invoked:</p> <pre><code> &lt;script type="text/javascript"&gt; function getbuttonId(sid){ // document.editform.action=url; // document.editform.submit(); var url="&lt;%= editURL.toString()%&gt;"; window.location.href = url+"?sid="+sid; return false ; } &lt;/script&gt; </code></pre> <p>My portlet action url is as follows:</p> <pre><code>&lt;portlet:actionURL name="editRestaurant" var="editURL"&gt; &lt;/portlet:actionURL&gt; </code></pre> <p>...and the method I am calling via portlet action url is here in my action class:</p> <pre><code>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"); } </code></pre> <p>I got error like this when I click on edit function</p> <pre><code> java.lang.NoSuchMethodException: emenu.advertise.portlet.RestaurantPortlet.editRestaurant?sid=5(javax.portlet.ActionRequest, javax.portlet.ActionResponse) </code></pre> <p>Can somebody please guide me to fix this?</p> <p>@</p> <p>here i want that the sid value assigned to my button id should be transfer to this string value before page is redirects </p> <pre><code>&lt;% String restId=request.getParameter("sid"); //can i call sid value of javascript function getbuttonId() here %&gt; &lt;portlet:actionURL name="editRestaurant" var="editURL"&gt; &lt;portlet:param name="key" value="&lt;%=restId %&gt;"/&gt; &lt;/portlet:actionURL&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload