10

I have added a common JAR to my project. The jar looks something like...

CommonWeb.jar
 |-- META-INF
 |    |-- resources
 |    |    `-- common
 |    |         |-- css
 |    |         |    `-- my.css
 |    |         |-- js
 |    |         |    `-- my.js
 |    |         |-- images
 |    |         |    `-- my.png
 |    |         |-- components
 |    |         |    `-- mycomposite.xhtml
 |    |         `-- templates
 |    |              `-- mytemplate.xhtml
 |    |-- faces-config.xml
 |    `-- MANIFEST.MF
 :

Everything is working except that Netbeans will not recognise my composite component. The page trying to use the component looks something like this...

<ui:composition template="/resources/common/templates/mytemplate.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:cmn="http://java.sun.com/jsf/composite/common/components">

    <ui:define name="content">
        ...
        <cmn:mycomposite ... />
        ...
    </ui:define>
</ui:composition>

The project will compile and run, no worries. But the IDE gives me red squiggly lines on <cmn:mycomposite ... /> and does not auto-complete, etc. It will all work fine if I copy the component into the project's own resources folder, so it seems netbeans just isn't looking to the jar.

There are quite a few questions around with similar problems, eg:

...but there are no satisfactory solutions or workarounds.

Also there have been a few netbeans bug reports on the matter but these all seem to be 'fixed'

Is there some configuration that I'm missing? Has anyone actually managed to get this working with the latest version of NetBeans (NetBeans 7.4 Patch 2 at time of writing)? Has anyone found a work-around that actually works?

UPDATE:

This problem continues to occur in NetBeans 8

Community
  • 1
  • 1
Daniel Loiterton
  • 5,073
  • 5
  • 33
  • 46
  • I don't do Netbeans, so I can't tryout myself and write a reliable answer right now. I can only suggest to try yourself one thing: create a `/META-INF/foo.taglib.xml` wherein you explicitly declare a new namespace for composite components contained in the JAR as per this Q&A: http://stackoverflow.com/questions/22247914/change-composite-components-namespace Then, try using that new XML namespace in Netbeans instead. At least, this is how usual "component libraries" are supposed to work and I can hardly imagine that Netbeans wouldn't take them into account as well. – BalusC Feb 20 '15 at 09:38
  • @BalusC Declaring the `namespace` and `composite-library-name` in `*.taglib.xml` does not solve the problem. – stg Feb 20 '15 at 10:15
  • Just to be sure, that taglib is in JAR (not in WAR), and you did change the XML namespace in the using page to the one declared in taglib? – BalusC Feb 20 '15 at 10:49
  • Yep, everything is fine here. Also, the project compiles and run without any problems, it's just the annoying problem, that NetBeans does not recognise the composite components and thus marks the page erroneous. When some tags are explicitly defined in taglib.xml, NetBeans has *no problem with them as well, the problem is just related to composite components, which are not explicitly defined in the `*.taglib.xml` but rather defined by the usage of `` – stg Feb 20 '15 at 11:11
  • Problem continues in Netbeans 8.1 https://netbeans.org/bugzilla/show_bug.cgi?id=257684 – Fast Engy Jun 15 '16 at 06:17
  • @DrDan What kind of NetBeans project did you use/adapt to create your CmmonWeb.jar and did you have to fiddle with the Ant build (assuming you used an Ant-based project) to get the Jar to build ? Just using a Java Class Library project does not work without adaptation even if the folder structure is as shown, the Ant build does not includes `.../resources/...` – Webel IT Australia - upvoter Nov 21 '16 at 07:17

1 Answers1

0

This issue is an IDE only issue and continues in version 8.1. It stems from the bug identified in Netbeans bugzilla - specifically in the "JSF Editor for XHTML" module (org.netbeans.modules.web.jsf.editor)

I resolved the issue by downloading the version 8.1 source files for Netbeans and applying the suggested patch myself. I'm guessing it's a similar issue in earlier versions but I didn't check this.

To download and compile Netbeans you can follow the "How To" in here

Changes in summary:

CompositeComponentModel.java line 296 changed to:

if (parent != null && parent.getName().equalsIgnoreCase("META-INF")) { //NOI18N

JsfBinaryIndexer.java line 74 changed to:

namePattern = ".*\\.tld|.*\\.taglib\\.xml|.*\\.xhtml",

Indexer version incremented on line 81 changed to:

static final int INDEXER_VERSION = 11; //NOI18N

Given that the bug is being tracked hopefully it makes it into the next release.

Fast Engy
  • 1,913
  • 1
  • 12
  • 10