5

I'm trying to use the new org.omnifaces.converter.ListConverter in a primefaces picklist. I added the new dependency in my project with maven and rebuilt the project in order to download the jar file:

<dependency>
    <groupId>org.omnifaces</groupId>
    <artifactId>omnifaces</artifactId>
    <version>1.5</version>
</dependency>

I'm importing the namespace in my facelets as follows:

xmlns:o="http://omnifaces.org/ui"

Still, when I try to use <o:converter> in my picklist as follows:

<o:converter converterId="omnifaces.ListConverter" list="#{projectBean.clientSource}" />

I get a message from netbeans 7.3 saying :

The attribute list is not defined in the component converter

It doesn't seem to cause any build failure though... Am I missing something? Do I not use omnifaces as it is meant to be?

Eric C.
  • 3,310
  • 2
  • 22
  • 29

3 Answers3

4

This is, unfortunately, "by design".

Netbeans apparently validates the attributes rather strictly based on their registration in the *.taglib.xml file.

The <o:converter> is supposed to support all attribtues of any arbitrary converter, such as pattern and locale of <f:convertDateTime>, the minFractionDigits and integerOnly of <f:convertNumber>, etcetera. It's however impossible to register all of those attributes in the *.taglib.xml file in order to satisfy all possible use cases of <o:converter>. It namely also supports custom converters instead of standard ones.

It's however valid to specify a "custom" tag attribute and this is where the <o:converter> relies on. The list attribute is actually an attribute of the omnifaces.ListConverter converter. I don't have Netbeans at hands and I'm not sure whether it interpretes it as an error or as an warning and or if it's configurable somewhere in its validation settings, but I can assure you that this is absolutely harmless and should at most generate a warning (and thus not as an error).

In case you didn't understood the use of <o:converter>, it's a special tag handler which evaluates the attributes of the specified converter during view render time instead of view build time. This way it's possible to supply "dynamic" attributes tied to bean properties instead of hardcoded string attributes.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • thanks for these informations. It is indeed harmless since my application runs perfectly well but netbeans sees this as an error (underlined in red). I haven't found a way to make netbeans ignore this for the moment. Thanks also for the good work on `omniface`, it saves a lot of time ! – Eric C. Jan 17 '14 at 14:34
  • Netbeans marks it as an error? Wow, this is a bit overzealous. In any case, you're welcome. – BalusC Jan 17 '14 at 14:35
  • What IDE do you use @BalusC ? – alibttb Apr 21 '19 at 10:51
1

I worked around this issue in netbeans by unzipping omnifaces-2.1.jar.

Edit omnifaces-2.1\META-INF\omnifaces-ui-taglib.xml

Find converter

Add an attribute under converter:

<attribute>
        <description>
            <![CDATA[
                Model source list http://showcase.omnifaces.org/converters/ListConverter
            ]]>
        </description>
        <name>list</name>
        <required>false</required>
        <type>java.lang.String</type>
</attribute>

Just before < /tag >.

Zip the extracted contents (META-INF and org folders) into onmifaces-2.1.jar.

Use that jar in netbeans.

Robert_E
  • 11
  • 2
  • That's indeed a workaround. But the `` supports technically an undefined amount of attributes. – BalusC Jun 11 '15 at 15:21
  • Has this been already added in latest 2.x version or 3.x? If no, please open a bug ticket so it can be fixed. – Roland Mar 29 '18 at 19:43
-1

The first time when you add the dependency, netbeans don't update its namespaces list.

Then,

  1. Execute "Clean and Build"
  2. In some cases, restart Netbeans

And its all

The same has happened to me with omnifaces 1.7 and Netbeans 7.3.1

David SK
  • 814
  • 7
  • 21
  • Since I've posted this question, I must have restarted netbeans about 300 times and cleaned&built my project about 3000 times. And it is still showing this annoying error message !! – Eric C. Jan 16 '14 at 13:50