Web Facet

Hi,

I would like to add a web facet to a custom module. At the moment I create a web.xml and copy it to the module source directory during the module creation. I was wondering whether it is possible to create a facet programmatically but I cant find any reference to how it can be done. Does anyone know where I can find an example or can someone post an example of how to create a web facet using a FacetManager.

Thanks in advance.
Avi

3 comments
Comment actions Permalink

What do you mean by "custom module"? Web Facets may be added only to Java modules.

In order to create and add Web facet to a module use the following code (inside WriteAction):

FacetType type = FacetTypeRegistry.getInstance().findFacetType(WebFacet.ID);

Facet facet = type.createFacet(module, name, type.createDefaultConfiguration(), null);
ModifiableFacetModel model = FacetManager.getInstance(module).createModifiableModel();
model.addFacet(facet);
model.commit();

In Diana the last 4 lines may be replaced with
FacetManager.getInstance(module).addFacet(type, name, null);

Hi,

I would like to add a web facet to a custom module. At the moment I create a web.xml and copy it to the module source directory during the module creation. I was wondering whether it is possible to create a facet programmatically but I cant find any reference to how it can be done. Does anyone know where I can find an example or can someone post an example of how to create a web facet using a FacetManager.

Thanks in advance.
Avi



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Thank you for your reply but when I added the above code I get a class not loaded exception. The WebFacet.ID cause the following exception: java.lang.ClassNotFoundException: com.intellij.javaee.web.facet.WebFacet

Edited by: AviTenzer on Aug 6, 2008 1:32 PM

0
Comment actions Permalink

WebFacet class is located in com.intellij.javaee plugin so your plugin.xml file must contain

com.intellij.javaee]]>

tag.

Thank you for your reply but when I added the code below I get a class not loaded exception. The WebFacet.ID cause the following exception: java.lang.ClassNotFoundException: com.intellij.javaee.web.facet.WebFacet



--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0

Please sign in to leave a comment.