You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Julien Martin <ba...@gmail.com> on 2007/08/20 13:41:06 UTC

JS confirm for h:commandButton??

Hello,
I would like for a user to confirm that he/she wants to undertake a submit
action. I have a h:commandButton and I would like to use the JS confirm
function and the onclick attribute in order to do that. The problem is when
I want to submit the form (once the user has clicked yes on the confirm
button) and I do not want to hard-code the path to the form. Another problem
is that I have several h:commandButtons on the form.
Can anyone please help?
Thanks in advance,
Julien Martin.

Re: JS confirm for h:commandButton??

Posted by David Delbecq <de...@oma.be>.
Not totally true. There is some JS operations JSF makes upon submit that
will be bypassed by your return.

<h:commandButton value="submit" action="#{myBean.action}" onclick="if
(!confirm('Are you sure?')) return false;" />


This is because you need the operation to continue if user confirm. This
is not 100% necessary with command buttons, but it is with command links.


En l'instant précis du 20/08/07 13:55, Julien Martin s'exprimait en ces
termes:
> I was given the solution by someone. Here it is:
> [code]
> <h:commandButton value="submit" action="#{myBean.action}"
> onclick="return confirm('Are you sure?');" />
> [/code]
> Julien.
>
>
> 2007/8/20, Julien Martin <balteo@gmail.com <ma...@gmail.com>>:
>
>     Hello,
>     I would like for a user to confirm that he/she wants to undertake
>     a submit action. I have a h:commandButton and I would like to use
>     the JS confirm function and the onclick attribute in order to do
>     that. The problem is when I want to submit the form (once the user
>     has clicked yes on the confirm button) and I do not want to
>     hard-code the path to the form. Another problem is that I have
>     several h:commandButtons on the form.
>     Can anyone please help?
>     Thanks in advance,
>     Julien Martin.
>
>


-- 
http://www.noooxml.org/


Re: JS confirm for h:commandButton??

Posted by Julien Martin <ba...@gmail.com>.
I was given the solution by someone. Here it is:
[code]
<h:commandButton value="submit" action="#{myBean.action}" onclick="return
confirm('Are you sure?');" />
[/code]
Julien.


2007/8/20, Julien Martin <ba...@gmail.com>:
>
> Hello,
> I would like for a user to confirm that he/she wants to undertake a submit
> action. I have a h:commandButton and I would like to use the JS confirm
> function and the onclick attribute in order to do that. The problem is when
> I want to submit the form (once the user has clicked yes on the confirm
> button) and I do not want to hard-code the path to the form. Another problem
> is that I have several h:commandButtons on the form.
> Can anyone please help?
> Thanks in advance,
> Julien Martin.
>