I am still facing a puzzling problem. I have two commandLink in two pages,
one is embedded in a dataTable. The first one works, but not the one
embedded in a dataTable. When I 'cancel' the confirm dialog I got routed to
"http:/localhost/myapp/#".
Below are the rendered HTML, I looked through them carefully; I can't see
why it wouldn't work.
Any idea?
Thanks for you links. I will write a Wiki page when I got this sorted out.
Regards,
Yee
--------Works OK ------------------------------------------------
<a href="#" onclick="
if (!confirm('You will lose all changes made. Are you sure?')) return;
clear_userForm();
document.forms['userForm'].elements['autoScroll'].value=getScrolling();
document.forms['userForm'].elements['userForm:_link_hidden_'].value='userFor
m:_id13';
if(document.forms['userForm'].onsubmit){
if(document.forms['userForm'].onsubmit())
document.forms['userForm'].submit();
}else{
document.forms['userForm'].submit();
}
return false;
"
id="userForm:_id13">Cancel</a>
------Eembedded in t:dataTable - doesn't work --------------------------
<a href="#" onclick="
if (!confirm('Are you sure you want to delete user?')) return;
clear_userForm();
document.forms['userForm'].elements['autoScroll'].value=getScrolling();
document.forms['userForm'].elements['userForm:_link_hidden_'].value='userFor
m:userTable_0:lnkDeleteUser';
if(document.forms['userForm'].onsubmit){
if(document.forms['userForm'].onsubmit())
document.forms['userForm'].submit();
}else{
document.forms['userForm'].submit();
}
return false;
"
id="userForm:userTable_0:lnkDeleteUser">delete</a>
-----Original Message-----
From: Dennis Byrne [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 1 November 2005 3:29 PM
To: MyFaces Discussion; [EMAIL PROTECTED]
Subject: RE: x:commandLink and onClick
use this ... http://www.mail-
archive.com/[email protected]/msg08449.html .
and please put it on the wiki.
---- Original message ----
>Date: Tue, 01 Nov 2005 13:24:38 +0800
>From: Yee CN <[EMAIL PROTECTED]>
>Subject: RE: x:commandLink and onClick
>To: "'MyFaces Discussion'" <[email protected]>
>
>Arragh - just hit the same problem. Is there a resolution
this?
>
>Why would onClick="return confirm('Are you sure...?');"
works on a
>commandButton but not on a commandLink?
>
>Is it a bug that will be fixed?
>
>Regards,
>Yee
>
>-----Original Message-----
>From: Mike Kienenberger [mailto:[EMAIL PROTECTED]
>Sent: Tuesday, 25 October 2005 11:49 PM
>To: MyFaces Discussion
>Subject: Re: x:commandLink and onClick
>
>When you get this all figured out, could you create a
MyFaces wiki entry on
>it?
>
>I'm sure I'm not the only one who will eventually need to do
something
>similar, and it'd be great if we could get it documented
somewhere!
>
>As you mentioned, there's a lot of attempts to provide this
with mixed
>results, and it'd be good to have something that's known to
work.
>
>On 10/25/05, James Reynolds <[EMAIL PROTECTED]> wrote:
>>
>> Oh! That's a good idea. However, that presents another
problem for my
>> page. By way of some background, I'm using a dataTable to
build a list
>> of upcoming conferences. The final column contains two
links inside,
>> "Edit" and "Delete." The Edit navigates to a detail page,
while the
>> delete would obviously remove the record and reload the
page. I also
>> have an "Add Conference" button outside of the table.
Using the
>> onSubmit attribute would prompt for confirmation no matter
what control
>> is activated. Perhaps I should just use commandButtons
instead of
>> commandLinks and avoid the issue altogether.
>>
>>
>> -----Original Message-----
>> From: Marius Kreis [mailto:[EMAIL PROTECTED]
>> Sent: Tuesday, October 25, 2005 8:26 AM
>> To: MyFaces Discussion
>> Subject: Re: x:commandLink and onClick
>>
>> sorry, my mistake.
>> i think
>> <h:form onSubmit="return confirm('text');" ..> should
work....
>>
>> James Reynolds wrote:
>> > That was my first try. The confirmation box pops up
properly, but the
>>
>> > form does not submit after clicking the 'OK' button.
Has anyone else
>> > had this trouble? Judging from the archives, it appears
that people
>> > have had mixed results with different methods.
>> >
>> > -----Original Message-----
>> > From: Marius Kreis [mailto:[EMAIL PROTECTED]
>> > Sent: Tuesday, October 25, 2005 7:32 AM
>> > To: MyFaces Discussion
>> > Subject: Re: x:commandLink and onClick
>> >
>> > This sounds like an error in your javascript.
>> > Perhaps you should try
>> > onClick="return confirm('Are you sure...?');"
>> >
>> > James Reynolds wrote:
>> >
>> >>I'm trying to add some confirmation to the onClick event
for my
>> >>commandLink. The mail archives have good suggestions
including:
>> >>
>> >>1. Call a function defined on the page like this:
onclick="return
>> >>validate()"
>> >>2. Construct the javascript as such: onclick="if (!
confirm('Are you
>> >>sure you want to delete this record?')) return"
>> >>
>> >>In each case, I'm receiving "Object Expected" errors in
Internet
>> >>Explorer. What is the best way of handling this task?
>> >>
>> >>Thanks
>> >
>> >
>> >
>> >
>>
>>
>>
>
Dennis Byrne