0

JavaScript and jQuery are very useful tools in web application development and they are widely used in all most all web application development tools. But in JSF, the same JavaScript and jQuery libraries are not complied. What is the way to overcome this limitation?

Can I download from the internet JSF-specific jQuery and JavaScript libraries? JavaScript and jQuery libraries which are extensively used with other technologies can not be used without modifications in JSF and hence, it is difficult to use them in JSF Is there any solution to this?


Update: Actually, I'm using NetBeans IDE 6.9.1 to develop web applications in J.S.F in which Javascript can not be used with the same syntax as it is used with other technologies. For example, string concatenation can not be made using the + operator. It can be made using the operator & instead. Similarly, most of the logical operators need to be modified and so on.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Bhavesh
  • 303
  • 2
  • 3
  • 9
  • 1
    I've edited your question body to cleanup some incorrect term usage, but I do by *far* not understand the concrete question which you're trying to ask. The title is merely a wild guess. Please edit and clarify yourself. Are you for example encountering problems when you're manually importing jQuery while using a 3rd party JSF component library which already includes jQuery, such as PrimeFaces? In that case, you should **ask that as such** instead of asking an overly broad and vague question. – BalusC Oct 25 '11 at 18:48
  • 1
    What limitations are you talking about? – Matt Handy Oct 25 '11 at 18:49
  • Actually, I'm using NetBeans IDE 6.9.1 to develop web applications in J.S.F in which Javascript can not be used with the same syntax as it is used with other technologies. For example, string concatenation can not be made using the + operator. It can be made using the operator & instead. Similarly, most of the logical operators need to be modified and so on... – Bhavesh Oct 25 '11 at 19:02
  • That's much better. I've put that back into the question for you and posted an answer. – BalusC Oct 25 '11 at 19:12

2 Answers2

2

I'm using NetBeans IDE 6.9.1 to develop web applications in J.S.F in which Javascript can not be used with the same syntax as it is used with other technologies.

First of all, it's JSF, not J.S.F.


For example, string concatenation can not be made using the + operator.

This is nonsense. Perhaps you're confusing JavaScript with EL.


It can be made using the operator & instead. Similarly, most of the logical operators need to be modified and so on...

That is indeed required if you write JavaScript code plain vanilla straight inside a XML based template, such as Facelets which uses XHTML. The characters <, >, &, ", etc are special characters in XML and should be escaped whenever you want to represent them as-is in XML. The normal practice is to just put that plain JS code inside its own .js file which you include by <script> or <h:outputScript>. Otherwise you've to put it in ugly <![CDATA[ blocks. Please note that this problem is not specifically related to JSF, but to combining JavaScript with XML in general.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
0

Javascript is not framework specific. It is for html and html generated content.

Jsf does put certain limitations on js..but usually they can be overcome. If you are having a specific problem, ask on SO and hopefully we can help.

To add to that, JSF components and framework are javascript/AJAX-rich and I've found that I don't need to write as much javascript as I would think when I'm using the proper components and methods to implement what I want and using them correctly.

Nick Rolando
  • 25,879
  • 13
  • 79
  • 119