This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes Embedding Javascript in a JSF File Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Embedding Javascript in a JSF File" Watch "Embedding Javascript in a JSF File" New topic
Author

Embedding Javascript in a JSF File

Abiodun Adisa
Ranch Hand

Joined: Jan 17, 2002
Posts: 495
I am embedding a Javascript code segment within a JSF File,



But anytime i take a look at the html generated i only see


Without its content. How do i resolve this issue?
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
If you're still using the old JSF 1.1, you should wrap template text in <f:verbatim>.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15959
    
  19

Actually, this is a better way to do it:



Since you're embedding text that can potentially contain XML magic characters in an XML document. Which XML won't like. And even if you don't offend, any tool you used to pretty up the XML would chew up the JavaScript code formatting unless you wrapped it with a CDATA.

However, there are a couple of other problems here.

First of all, that's not how you'd attach javascript to a control, so it still won't work.

Secondly, onpaste() is not a standard JavaScript event. It works in IE and it works in Safari, but it does not work in Firefox and probably doesn't work in Opera.

So if you expected to set up a website that was trying to sell me something, you'd fail. I don't use IE for anything where money or sensitive data are involved.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
wood burning stoves
 
subject: Embedding Javascript in a JSF File
 
Similar Threads
jQuery auto complete with jsf
javascript with JSF???
Send requsts to a php file using AJAX
HTML AJAX response with embedded js?
javascript in JSP