Stefan,

Below is a response to a similar question on this list a few days ago.

HTH,
sean


h:commandLink uses javascript to do some behind the scenes trickery.
Here is an example of JSF and then the HTML you get.

<h:commandLink id="link" action="goto">
 <h:outputText value="#{msg.linkName}"/>
</h:commandLink>

yields something like ...

<a id="_id0:link" href="#"
onclick="document.forms['_id0']['_id0:link'].value= '_id0:link';
    document.forms['_id0'].submit();return false;">Next Page</a>

So the javascript is submitting the form for you.  (BTW you may not
have realized it but h:commandLink requires javascript - no big deal
but you should know.)

I believe your problem is because the onsubmit() method is not fired
if you submit the form via javascript.  Unfortunately, the onclick
event is where you would normally but your desired logic and that
attribute is not available (in the standard <h:commandLink>).

I just quickly checked <x:commandLink> for you (the myfaces "extended"
version) and it has an onclick attribute.  I am willing to bet that
whatever code you supply there will be called before the regular
onclick stuff you can expect from commandLink.



On Wed, 23 Feb 2005 14:40:50 +0100, Stefan Frank
<[EMAIL PROTECTED]> wrote:
> Is there a way to add a simple confirm dialog to an x:commandlink?! I wanted
> to add a simple onclick="confirm('Sure you want to delete the whole
> database?!')" to suns h:commandLink, but the onclick is not open in their
> implementation.
> 
> Before I switch alle my buttons and links to myfaces, I'd like to make sure,
> that this actually works...
> 
> Cheers
> stf
> 
>

Reply via email to