Reputation: 11
I'm new to Liferay framework, started with this example portlet app in which users can add some strings to search container, maybe comments or whatever: https://dev.liferay.com/develop/learning-paths/mvc/-/knowledge_base/6-2/writing-your-first-liferay-application
What I'm currently trying to do is to add a possibility to delete selected entries from search container. I added one more column with checkbox: this is how it looks like. But I do not know how to transfer that column to my java controller class. This is how my jsp looks right now:
<jsp:useBean id="entries" class="java.util.ArrayList" scope="request"/>
<liferay-ui:search-container>
<liferay-ui:search-container-results
results="<%= entries %>"
/>
<liferay-ui:search-container-row
className="com.liferay.docs.guestbook.model.Entry"
modelVar="entry"
>
<liferay-ui:search-container-column-text>
<input type="checkbox" id="myCheckBoxIds" name="myCheckBoxes" width="10"/>
</liferay-ui:search-container-column-text>
<liferay-ui:search-container-column-text property="message" />
<liferay-ui:search-container-column-text property="name" name="name" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
<portlet:actionURL name="deleteEntry" var="deleteEntryURL">
<portlet:param name="checkBoxes" value="WHAT SHOULD I PUT HERE TO TRANSFER myCheckBoxes"></portlet:param>
</portlet:actionURL>
<aui:button-row cssClass="guestbook-buttons">
<aui:button onClick="<%= addEntryURL.toString() %>" value="Add Entry"></aui:button>
<aui:button onClick="<%= deleteEntryURL %>" value="Delete Entry"></aui:button>
</aui:button-row>
Any ideas? Thanks in advance!
Upvotes: 0
Views: 705
Reputation: 4210
Do not add checkbox explicitly but You can provide rowChecker attribute to lfieray's search-container tag.
Below javascript code will give you list of key value of checked rows, which you can then pass it to controller by setting it into hidden field.
var checkBoxValue = Liferay.Util.listCheckedExcept(document.<portlet:namespace />fm, "<portlet:namespace />allRowIds");
Upvotes: 0