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
Please sign in to leave a comment.
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);
--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
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
WebFacet class is located in com.intellij.javaee plugin so your plugin.xml file must contain
com.intellij.javaee]]>
tag.
--
Nikolay Chashnikov
Software Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"