Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to get list of selected row or list of selected checkbox from jsp page to action class method of portlet in liferay 6?
    primarykey
    data
    text
    <p>I am developing custom portlet and in one of my view page I need some help.</p> <p>Following is my form in which I have check box in every row and each row will be created at run time (dynamically):</p> <pre><code>&lt;form method="post" name="editform"&gt; &lt;table class="table table-bordered table-striped" id="dt_gal_res"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th class="table_checkbox"&gt;&lt;input type="checkbox" name="select_rows" class="select_rows" data-tableid="dt_gal_rest" /&gt;&lt;/th&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Contact Person&lt;/th&gt; &lt;th&gt;Website&lt;/th&gt; &lt;th&gt;EDIT&lt;/th&gt; &lt;th&gt;DELETE&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;% List&lt;restaurant&gt; rest_listOBJ = restaurantLocalServiceUtil.getAllAvailableRestaurant(); for (int i = 0; i &lt; (rest_listOBJ.size()); i++) { restaurant temprest = rest_listOBJ.get(i); %&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="checkbox" name="row_sel" class="row_sel" /&gt;&lt;/td&gt; &lt;td&gt;&lt;%=temprest.getName() %&gt;&lt;/td&gt; &lt;td&gt;&lt;%=temprest.getContactno() %&gt;&lt;/td&gt; &lt;td&gt;&lt;%=temprest.getWebsite() %&gt;&lt;/td&gt; &lt;td&gt; &lt;input type="submit" id="1" value="edit" onclick="return getbuttonId('&lt;%=temprest.getPrimaryKey() %&gt;')" /&gt; &lt;/td&gt; &lt;td&gt; &lt;input type="submit" id="2" value="DELETE" onclick="return getdeletebuttonId('&lt;%=temprest.getPrimaryKey() %&gt;')" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;% } %&gt; &lt;/table&gt; &lt;div style="visibility: hidden;"&gt; &lt;input type="hidden" name="hide1" id="hiddenkey" value=""&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>Right now I have delete button and by some other logic I am deleting the row one by one.<br> But now what I want is that after selecting the check-box of rows one or more check box when I submit one button then on-click of that one button I want to delete all those rows for which check-box is selected.</p> <p>Somehow if anyone can guide me that how can I get list of selected check box list in my action method of portlet class then even that will be enough for me.</p> <p>I am quite new to jsp so any one who has any idea please suggest me.</p> <p>As u guyz suggested i have done same way.but not getting any success..please correct me where am wrong here is my action class </p> <pre><code>public void deleteMultipleRestaurant(ActionRequest ar, ActionResponse ap) throws Exception { log.info("ENTERED"); List&lt;restaurant&gt; restaurants = restaurantLocalServiceUtil.getAllAvailableRestaurant(); for (restaurant restaurantitem : restaurants) { if (Boolean.valueOf(ar.getParameter("row_sel" + restaurantitem.getPrimaryKey()))) { // This is a selected checkbox so add you remove code here log.info(restaurantitem); restaurantitem.setIsdeleted(true); restaurantLocalServiceUtil.updaterestaurant(restaurantitem); } } } </code></pre> <p>in my view file am doing as follows</p> <p>this is my one of ul in this my delete link is there</p> <pre><code>&lt;portlet:actionURL name="deleteMultipleRestaurant" var="multideleteURL"&gt; &lt;/portlet:actionURL&gt; &lt;button data-toggle="dropdown" class="btn dropdown-toggle"&gt; Action &lt;span class="caret"&gt;&lt;/span&gt; &lt;/button&gt; &lt;ul class="dropdown-menu"&gt; &lt;li&gt;&lt;aui:button name="DELETE" value="DELETE" onClick="&lt;%=multideleteURL.toString() %&gt;"/&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="javascript:void(0)"&gt;Lorem ipsum&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="javascript:void(0)"&gt;Lorem ipsum&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>following is in view page</p> <pre><code>&lt;tbody&gt; &lt;% List&lt;restaurant&gt; rest_listOBJ = restaurantLocalServiceUtil .getAllAvailableRestaurant(); for (int i = 0; i &lt; (rest_listOBJ.size()); i++) { restaurant temprest = rest_listOBJ.get(i); %&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="checkbox" id="row_sel&lt;%= temprest.getPrimaryKey() %&gt;" name="&lt;portlet:namespace/&gt;row_sel&lt;%= temprest.getPrimaryKey() %&gt;" class="row_sel" /&gt; &lt;/td&gt; &lt;td&gt;&lt;%=temprest.getName()%&gt;&lt;/td&gt; &lt;td&gt;&lt;%=temprest.getContactno()%&gt;&lt;/td&gt; &lt;td&gt;&lt;%=temprest.getWebsite()%&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="button" id="1" onclick="return getbuttonId('&lt;%=temprest.getPrimaryKey()%&gt;')" style="border:none;width:20px" class="icon-pencil"/&gt; &lt;input type="button" id="2" onclick="return getdeletebuttonId('&lt;%=temprest.getPrimaryKey()%&gt;')" style="border:none;width:20px" class="icon-trash" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;% } %&gt; &lt;/tbody&gt; </code></pre> <p>but nothing am getting..its just reloading the page..just dat</p>
    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