apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.6k stars 835 forks source link

Detect JSF usage in plain JAR projects and activate JSF support accordingly #3786

Open newk5 opened 2 years ago

newk5 commented 2 years ago

Apache NetBeans version

Apache NetBeans 13

What happened

Netbeans 13 no longer recognizes the JSF tag "ui:composition" in xhtml files or even any other JSF related tags. Autocomplete suggestions on any JSF components, JSTL tags, or even simple bean property or method suggestions are also broken, for some reason it keeps suggesting attributes from angularJS? We use netbeans primarily for JSF development and unfortunately this makes Netbeans 13 unusable. This did not happen in Netbeans 12.6 so for now we have to go back to that version. Hopefully this can be fixed, otherwise netbeans is no longer viable option to use for any JSF development.

How to reproduce

Open a XHTML file and press CTRL+SPACE on any JSF related tag, or even on a bean expression. Autocomplete either doesn't show, (says "No results") or just doesn't show any attributes of that JSF component/properties of that bean. You can also open any XHTML file which uses the "" tag, and netbeans wont be able to recognize it (see screenshots below)

Did this work correctly in an earlier version?

Apache NetBeans 12.6

Operating System

ElementaryOS 6.1 (based on Ubuntu 20.04.3) (also tested on windows, same issue)

JDK

JDK17 Temurin-17.0.2+8

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

About the ui:composition tag, If this line is present

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

It looks like this: image image

If I remove that line, it looks like this: image

image

But even then, the autocomplete suggestions are still broken.

If you need more information from me, please let me know.

Are you willing to submit a pull request?

No

Code of Conduct

Yes

matthiasblaesing commented 2 years ago

Please provide detailed steps to reproduce and if necessary a minimal demo project.

newk5 commented 2 years ago

The issue happens with any JSF project, when you're editing a xhtml file. You can clone this project: https://github.com/newk5/quarkus-jsf

  1. Clone that project and compile
  2. Then go to the index.xhtml file
  3. Put the cursor after "indexView." after the "."
  4. Press CTRL+SPACE
  5. This is the result: image

Repeat the exact same steps with NetBeans 12.6 and this is the result: image

NetBeans 13

image

NetBeans 12.6

image

Similar behaviour if you put the cursor inside any of those other tags (h:form, p:growl, p:autoUpdate, etc...) and press CTRL+SPACE in 12.6 you get autocomplete suggestions for attributes of those tags, but in NetBeans 13 you dont get any of those suggestions.

Let me know if that's clear or if you need more details, I'll do my best to explain

matthiasblaesing commented 2 years ago

Please do the following:

I assume, that you had that plugin set activated in 12.6 and not on 13.

newk5 commented 2 years ago

After doing those steps, it's now working. You were right, it seems it was not active (I'm not sure why)

In any of the previous Netbeans versions, I never manually had to activate the "Java Web and EE" plugin, NetBeans just automatically activated it for me ( I guess when it detected a JSF project). It seems this type of thing is no longer done automatically with version 13. Do you know if this is a bug or intended?

matthiasblaesing commented 2 years ago

I bet you build WAR projects by then and not plain JAR.

newk5 commented 2 years ago

Ahh I think you are right. I build both WAR projects and plain JAR JSF apps, but I think the first project I opened in NetBeans13 was a quarkus jsf app. Building JSF projects into a JAR instead of a WAR with quarkus is relatively new so my understanding is that NetBeans doesn't detect quarkus JSF apps as "valid" JSF apps, and doesn't automatically enable the JavaEE plugin.

The condition for checking whether a quarkus app is a JSF app would be checking if the project contains the myfaces dependency. Do you think it would be viable for NetBeans to do this automatically? Or maybe this is something which should be done in a "quarkus" type plugin instead?