What is the problem?  Is the function getting called?  Do you see your
confirm dialog?

sean


On Thu, 24 Feb 2005 20:28:13 +0100, Slawek <[EMAIL PROTECTED]> wrote:
> please explain me as i would be an idiot:D
> //===============================================
> <%@ taglib uri="http://java.sun.com/jsf/html"; prefix="h"%>
> <%@ taglib uri="http://java.sun.com/jsf/core"; prefix="f"%>
> <%@ taglib uri="http://myfaces.apache.org/extensions"; prefix="x"%>
> <html>
> <head>
> <script language="javaScript">
>         function clik(){
>                 a=confirm('sure?');
>                 if (a)
>                         return true;
>                 return false;
>         }
> </script>
> </head>
> <body>
> <f:view>
> <h:form >
>         <x:commandButton onclick="clik()" action="#{bean.action}" value="aa" 
> />
> </h:form>
> </f:view>
> </body>
> </html>
> //===========================================================
> when user answer cancel on confirm JS window should form be submitted or
> not?
> 
> 
> > I have since checked x:commandLink and it does exactly what I thought.
> >  Also, just so you know, you will have the same issue with RI (with no
> > workaround.)  The spec does not allow the onclick attribute for
> > command link (that is why its in the "extended" components of MyFaces
> > as opposed to the core section.)
> >
> > sean
> >
> >
> >
> > On Thu, 24 Feb 2005 16:40:41 +0100, Stefan Frank
> > <[EMAIL PROTECTED]> wrote:
> >> Hi Sean,
> >>
> >> many Thx for the tip, I will test it and see, if it works.
> >>
> >> Cheers
> >> stf
> >>
> >> > -----Original Message-----
> >> > From: Sean Schofield [mailto:[EMAIL PROTECTED]
> >> > Sent: Donnerstag, 24. Februar 2005 00:52
> >> > To: MyFaces Discussion; [EMAIL PROTECTED]
> >> > Subject: Re: JavaScript-Confirm inside a commandlink?
> >> >
> >> > 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