I'm pretty sure that Simon is correct about JSF EL working anywhere in
JSF 1.2.   I know that facelets already supports using JSF EL anywhere
in a page, even in comments.

On 11/9/05, Simon Kitching <[EMAIL PROTECTED]> wrote:
> Warren Bell wrote:
> > I want to create a JavaScript alert window with a message from a resource
> > bundle when I have a message to display. Getting the message is no problem,
> > but getting it into the JavaScript is.
> >
> > <script language="JavaScript" type="text/JavaScript">
> > function displayMessage()
> > {
> >   var message = "MESSAGE HERE";
> >   if(message == "")
> >   {
> >   }
> >   else
> >   {
> >     alert(message);
> >   }
> > }
> > </script>
> >
> > <body onload="displayMessage()">
> >
> >
> > I want to replace "MESSAGE HERE" with #{mainMenu.alertMessage}.
> > #{mainMenu.alertMessage} would be an empty string or have a message. I am
> > getting var message = "#{mainMenu.alertMessage}" instead of the value of
> > #{mainMenu.alertMessage}.
> >
> > Is there a way using MyFaces to achieve this?
>
> I think in the next release of JSP this will be possible (EL expressions
> evaluated in the body of the JSP page). However that's no consolation
> for you now :-) [and I might be wrong anyhow...]
>
> Right now, the only place an EL expression #{..} is evaluated is in the
> attribute of a JSF tag, so your approach above won't work.
>
> You might be able to do something like this:
>    <t:div style="display:none" id="mymessage" forceid="true">
>      <h:outputText value="#{...}"/>
>    </t:div>
> to force some text to be output in a named div, but not visible to the
> user. Then in your javascript you could do:
>    var message = document.getElementById("mymessage").innerHtml();
>    alert(message);
>
> The alternative would be to write a component that can emit arbitrary
> text as a script variable, eg
>    <t:var name="message" value="#{...}"/>
> which generates something like:
>    <script>var message="..."</script>
>
> There's the t:stylesheet tag which is sort of in this spirit.
>
> Note that writing a custom JSP component is sadly much more complicated
> than it should be :-(
>
> Regards,
>
> Simon
>

Reply via email to