Ah - I see. <body> is not a jsf tag. But then why don't you get literal
"<h:outputText value="#{mainMenu.alertMessage}"/>"?I think how .jsp file is being parsed is not clear at all. Anyway it is good to know that it works. Yee -----Original Message----- From: Warren Bell [mailto:[EMAIL PROTECTED] Sent: Thursday, 10 November 2005 1:06 PM To: MyFaces Discussion Subject: RE: JavaScript alert() window I was able to get it to work with: <body onload="displayMessage('<h:outputText value="#{mainMenu.alertMessage}"/>')"> This evaluated correctly and gave me an alert window with the message. <body onload="displayMessage('#{mainMenu.alertMessage}')"> This gave me an alert window with the literal message #{mainMenu.alertMessage} > -----Original Message----- > From: Simon Kitching [mailto:[EMAIL PROTECTED] > Sent: Wednesday, November 09, 2005 7:53 PM > To: MyFaces Discussion > Subject: Re: JavaScript alert() window > > > 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 > > __________ NOD32 1.1282 (20051109) Information __________ > > This message was checked by NOD32 antivirus system. > http://www.eset.com > >

