So what you really want is #{MyBean.checkA ? 'doJS('staticvalue',' + beanA.value + ');' : 'alert('hello'));' "
Some of the issues I see - You need to somehow escape the single quotes in the javascript - You need to be able to concat the doJS expression. I've solved the second issue by writing a static concat function in facelets. That's only an option if you're using facelets, though. I don't know if there's a way to escape a single quote in EL. I'd probably solve that one with a static function that returns a single quote in facelets as well. Either that, or stick it in as a managed bean. On 3/30/07, Michael Heinen <[EMAIL PROTECTED]> wrote:
This does not work. The "?" must be part of the EL expression, or ? What I want is that if MyBean.checkA is true, then doJS('staticvalue','#{beanA.value}'); should be printed into the attribute value. This expression has to be in single quotes. The problem is that the JavaScript parameters in this function call have to be also in single quotes. Something like your suggestion: onclick=#{MyBean.checkA}?'doJS('staticvalue','#{beanA.value}');':'alert('hello'));'" is rendered as true?'doJS('staticvalue','bla');':'alert('hello'));' Michael -----Original Message----- From: Mike Kienenberger [mailto:[EMAIL PROTECTED] Sent: Donnerstag, 29. März 2007 17:42 To: MyFaces Discussion Subject: Re: escaping in EL? Are you trying to do this? onclick=#{MyBean.checkA}?'doJS('staticvalue','#{beanA.value}');':'alert('hello'));'" Only put #{} around parts you want interpreted by EL. On 3/29/07, Michael Heinen <[EMAIL PROTECTED]> wrote: > > > > > I want to express the following Javascript function call via EL: > > > > <sometag > > onclick=#{MyBean.checkA?'doJS('staticvalue','#{beanA.value}');':'alert('hello'));'}" > > </sometag> > > > > How can I do this ? > > Is there any way to escape this stuff ? > > > > Thanks, > > Michael