0

How can I embed an external JavaScript library like Google maps within a JSF view?

In traditional HTML I'd do it like <script src="http://maps.google.com/maps/api/js?v=3.6&sensor=false"></script>.

I want to know if its compulsory to use < h:outputScript> tag when I want to include an external JS library in a JSF view, because all examples I was able to find on this subject assumed that the actual JS file was included in a web application project and thus used <h:outputScript>.

1 Answer 1

2

You can insert standard HTML elements in your JSF views, like <div> or <script>, as in your case. Moreover, JSF will ultimately render <h:outputScript> as a plain <script> element. We normally use the former to let the JS file pass through the FacesServlet.

All of this yields that your <script> element shall be inserted 'as is'.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for your response. I actually had my code that way, just wanted to be sure if there was not an "official" jsf2 way to do it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.