how to conform deleting in jsf

I am pretty new to jsf.

I am using commandLink and doing deleting from database.But before deleting I want to let user conform his/her behaviour. I don't want to create another form and bean for this. So I use java scirpt here.

I post relevant code:

<SCRIPT LANGUAGE=JAVASCRIPT>

function verify(){

msg = "Are you absolutely sure that you want to submit this form?";

//all we have to do is return the return value of the confirm() method

return confirm(msg);

}

</SCRIPT>

......

<h:commandLink actionListener="{ViewUicLookupBean.uicLookupDeleted}" immediate="false" value="Delete" onmouseup=verify() >

<f:param name="uicLookupId" value="#{currentRow.uic}"/>

</h:commandLink>

.....

I test my program. When I don't add "onmouseup=verify()" in commandLink it works fine. But after adding it displays the conform dialog firstly and in this dialog if you select "OK" it don't delete record.

Anyone know sth about it?

[1048 byte] By [xlia] at [2007-10-2 3:25:40]
# 1
My goal is only to conform deleting. So any idea/suggestion will be appreicate.
xlia at 2007-7-15 22:35:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
I have similiar problem. Who does know the solution?
peria at 2007-7-15 22:35:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
havn't really looked at the javascript side of this but for something easy that would work if javascript wont http://www.jenia.orgtry their jsf popupBox
dboyd68a at 2007-7-15 22:35:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4

You can try use the example to add confirm prompt to wrap around the original onclick functon.

<html>

<head>

<script>

function addConfirmPrompt(c,msg){

var tempFunc = c.onclick;

var newFunc = function(){ if(confirm(msg)) return tempFunc(); }

c.onclick = newFunc;

}

function init(){

addConfirmPrompt(document.getElementById('c'),'Are you sure you want to delete this item?');

}

</script>

<head>

<body onload="init();">

<a id="c" href="#" onclick="alert('ok1'); alert('ok2');">click here</a>

</body>

</html>

Chokinga at 2007-7-15 22:35:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
hi;Here is a way that i use<h:commandButton value="Delete"binding="#{sp$SAAdmin.btnDelete}"id="btnDelete"action="#{sp$SAAdmin.btnDeleteAction}"onclick="return confirm('Are you sure you wish to continue?');" http://asahin.net>
A_SAHINa at 2007-7-15 22:35:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

normally, when you use javascript to validate a click, you'd have script that looks something like:

<a href="#" onclick="return confirm('are you sure?');">delete</a>

But, since that will stop the execution of any javascript that occurs after the ; and the JSF commandLink button adds the javascript necessary for submission after, you need to only return if the outcome is false. What I've gotten to work is this:

onclick="if(!confirm('are you sure?')){ return; }"

It's a little ugly, and a little verbose. But it shoud work.

jcerna at 2007-7-15 22:35:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...