Jquery Not Running In Jsf Application
Solution 1:
It seems like a bad location of file, I dont where exactly you placed the jquery file in your web app , but anyway It should be located in folder under the resources folder, So...
Add resources
folder under the WebContent
and inside resources create js
folder
then access the files like this
<h:outputScriptname="js/jquery-1.7.2.js"target="head" />
Solution 2:
I believe that JSF may be enforcing XHTML standards which tell it to ignore your script tag because it is outisde head or body tags. Have you checked whether your script tag is being rendered at all?
I have learned the hard way that the best way to do stuff when dealing with JSF is to do it the JSF way. In this case, it would be using h:outputScript tag.
Also, a good practice with JavaScript is to put it in a separate .js file even if you are going to use it on only one page. Makes it much easier to debug in a browser.
Solution 3:
Are you sure about the line: "#{facesContext.externalContext.requestContextPath}/faces/jquery-1.7.2.js" ? If I were you, I would look at the browser Url, then code with a relative path w/r to that Url to point to jquery-1.7.2.js. Another possible debug way would be to make a copy of the jquery-1.7.2.js in the current folder (i.e. of the current .xhtml), then the script tag line would be src="./jquery-1.7.2.js". If you can see the alert, then the problem is from that line path.
Post a Comment for "Jquery Not Running In Jsf Application"