掲示板

How to implement liferay conformation window before submit form in LR 6

11年前 に Kiran Kumar Boyini によって更新されました。

How to implement liferay conformation window before submit form in LR 6

Expert 投稿: 287 参加年月日: 11/06/02 最新の投稿
Hi All,


I am trying to develop iferay conformation window before delete the records using <liferay-ui:icon>.

Can anyone provide the code such that if user click ok it has to submit ,if he click cancel it should not be submit.


  <portlet:actionurl name="deleteEmployee" var="deleteURL">
				  	<portlet:param name="deletePrimKey" value="<%= String.valueOf(empRecord.getEmployeeId()) %>" />
				    </portlet:actionurl>
 <liferay-ui:icon image="delete" message="Delete" url="<%= deleteURL.toString() %>" onClick="showConfirm();" />


See the attachment.

Regards,

Kiran.

添付ファイル:

thumbnail
11年前 に mohammad azaruddin によって更新されました。

RE: How to implement liferay conformation window before submit form in LR 6

Expert 投稿: 492 参加年月日: 12/09/17 最新の投稿
Hi Try this
<%
String deleteConfirm = "javascript:confirmDel()";
%>

<liferay-ui:icon-menu>
<liferay-ui:icon image="delete" message="Delete"
url='<%=deleteConfirm%>' />
</liferay-ui:icon-menu>

<script type="text/javascript">
function confirmDel() {
msg = "Are you sure you want to delete this?";
if(confirm(msg)) {
window.location.href = '<%=deleteURL.toString()%>';
} else {
return false;
}
}
</script>
10年前 に Marc Heimann によって更新されました。

RE: How to implement liferay conformation window before submit form in LR 6

New Member 投稿: 21 参加年月日: 13/02/20 最新の投稿
Thank you, it's working for me now.
9年前 に asif aftab によって更新されました。

RE: How to implement liferay conformation window before submit form in LR 6

Regular Member 投稿: 123 参加年月日: 13/09/02 最新の投稿
It is better to use <liferay-ui:icon-delete> tag because the code provided on this page is creating problem, If I have more than one record then on delete it deletes last record not the record that I want to delete.
<liferay-ui:icon-delete message="return" url="<%= deleteURL %>"/>
It is working properly for me.
Sorry azhar bhai but I faced this problem.
asif
thumbnail
8年前 に Syed Nasar によって更新されました。

RE: How to implement liferay conformation window before submit form in LR 6

Junior Member 投稿: 64 参加年月日: 15/09/03 最新の投稿
Hi, Try this. It is working for me.emoticon
<liferay-ui:icon-delete url="<%=deleteURL%>" confirmation = "Are you sure to delete this?"/>
thumbnail
8年前 に Enrique Valdes Lacasa によって更新されました。

RE: How to implement liferay conformation window before submit form in LR 6

Junior Member 投稿: 92 参加年月日: 14/07/29 最新の投稿
asif aftab:
It is better to use <liferay-ui:icon-delete> tag because the code provided on this page is creating problem, If I have more than one record then on delete it deletes last record not the record that I want to delete.
<liferay-ui:icon-delete message="return" url="<%= deleteURL %>"/>
It is working properly for me.
Sorry azhar bhai but I faced this problem.
asif


Mmm...I think you could just pass the record Id in your deleteURL as a parameter, like:

<portlet:actionurl name="deleteRecord" var="deleteUrl">
  <portlet:param name="recordId" value="<%= String.valueOf(recordId) %>" />
</portlet:actionurl>


And that way, your action will be able to get the id and delete the specific record.

So I wouldn't say that Mohammad Azharuddin's answer is wrong. I like the answer because it is simple, works...and it provides a confirmation dialog in the same way as the "liferayish" <liferay-ui:icon-delete> element does behind the scenes... but for a button. I use the liferay-ui:icon-delete to include a delete icon in a Liferay Action button dropdown options for a specific record (see liferay-ui:icon-menu) and use Mohammad's way if you just want to call the delete from a regular button.