Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse and Facets

Tags:

eclipse

facets

In the courses java, everyone (or at least most people) seemed to have a working eclipse. They always seemed to have a working faces-config (a visual one), and autocomplete in xhtml files (for facelets). Though for autocomplete, we added *.xhtml files on JSP's.

It seems that this was a part I don't know well about eclipse, and it's fairly annoying since I don't know why. When I import a project (either Maven or existing), it always has no facets but java (and that in 1.5 not even 1.6), while it is supposed to be a webproject and have facelets & dynamic web project.

Can I change those facets? It seems to just work when I put java to 1.6, but trying to edit the dynamic web module version from 2.4 to 2.5 (it is standard on 2.4) without running into some troubles. Even after I just made a fresh maven project (with an archtype in commandline), I'm not able to change much about these facets.

What am I doing wrong?

like image 553
toomuchcs Avatar asked Jan 26 '11 21:01

toomuchcs


People also ask

What are facets in Eclipse?

Faceted Project Framework is a mature component of Eclipse Web Tools Platform (WTP) that facilitates treating Eclipse projects as composed of units of functionality (called facets) that can be easily added or removed by users.

Where can I find project facets in Eclipse?

Project FacetsRight click on the project properties. Select “Project Facets“, and click “convert to faceted form…” Check “Dynamic Web Module” and “Java“, and specify the value. By default, Eclipse will generate all “web” related files (like WEB-INF, web.

How do I enable project facets in Eclipse?

In the Project Explorer view of the Java™ EE perspective, right-click the project and then select Properties. Select the Project Facets page in the in the Properties window. This page lists the facets in the project and their versions.

What is facets in Java?

Facets define characteristics and requirements for Java™ EE projects and are used as part of the runtime configuration. When you add a facet to a project, that project is configured to perform a certain task, fulfill certain requirements, or have certain characteristics.


Video Answer


2 Answers

Eclipse functionality is driven by project metadata. If you don't have the right metadata, the projects aren't going to behave correctly.

If you are starting from scratch and creating projects in Eclipse, make sure to place all of the metadata files in your source control system (including everything under [project]/.settings directory).

If you are using Maven to generate your Eclipse project metadata, make sure that you find the Maven plugin that knows about WTP. I don't have a reference, but I know it exists. This will ensure that when Maven generates metadata, it will have the correct metadata for web projects.

Can I change those facets? It seems to just work when I put java to 1.6, but trying to edit the dynamic web module version from 2.4 to 2.5 (it is standard on 2.4) without running into some troubles.

The way facet works is that the facet author can choose not to implement version change logic. Unfortunately the Java EE module facets (such as the dynamic web module) do not have version change implemented. Other facets like Java do support this. So your experience will vary from facet to facet.

If all else fails, you can edit .settings/org.eclipse.wst.common.project.facet.core.xml file by hand. Make sure to do that from Eclipse or you will need to refresh the project afterwards. Just keep in mind that if you are forcing the change like that, you might need to do some manual fixes to your project content. For instance, if you change web spec level, you may need to update the deployment descriptors.

like image 81
Konstantin Komissarchik Avatar answered Oct 03 '22 05:10

Konstantin Komissarchik


You can change project facets. You should close eclipse , then goto .settings directory, org.eclipse.wst.common.project.facet.core.xml file holds all facets related info. You can add or remove a project facet .

like image 43
Gursel Koca Avatar answered Oct 03 '22 05:10

Gursel Koca