A number of extensions, including RichFaces contain tree menu tags. That is the preferable approach, because these specialty tags are integrated into JSF, thus are usually simpler to code and more reliable to operate.
Of course, in the case of RichFaces, the underlying support is often accomplished using jQuery internally, but that's transparent to the developer.
An IDE is no substitute for an Intelligent Developer.
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
Download Free Java APIs to Work with Office Files and PDF