Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
570 views
in Technique[技术] by (71.8m points)

jquery ui - How to include external Javascript file in a JSF page

I want to include the URL of jQuery UI http://code.jquery.com/ui/1.9.0/jquery-ui.js in my JSF page. I saw many questions which said <h:outputScript> should be used, but in none of the answers I saw an example as to how to include an URL. The answers were only relevant if the js file is present in some folder of the project.

Can someone please help where I have to include it in my page?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Just use plain HTML <script> element the usual way.

<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>

The <h:outputScript> can only refer local scripts. You'll only miss its dynamic versioning, modularity and relocation advantages, but that should technically not harm for a static and external script.

It's however possible to use a custom ResourceHandler to change the URL of a <h:outputScript> to be an external URL for pure CDN purposes. OmniFaces CDNResourceHandler is such an example.


Unrelated to the concrete problem, PrimeFaces components are built around jQuery/UI. Are you absolutely positive that you need a separate instance of jQuery UI library?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...