1

I am using a converter throughout my system which uses the following annotation:

@FacesConverter(forClass = Group.class)

this works fine except for SelectManyMenu where the conversion doesn't seem to take place. My SelectManyMenu is defined as follows

<p:selectManyMenu value="#{maintainMB.filteredLogicalGroups}" var="g" showCheckbox="true">  
<f:selectItems value="#{maintainMB.logicalGroupFilterList}" var="group" itemLabel="#{group.name}" itemValue="#{group}" />  

<p:column>  
    <p:graphicImage value="image.png.xhtml" width="32"/>
</p:column>  

<p:column>  
    #{g.name} 
</p:column>  
</p:selectManyMenu>

The SelectMenyMenu renders ok but when i select items they are returned as a string not an object.

If i change my Converter annotation to

@FacesConverter(value = "groupConverter")

and change my SelectManyMenu tag to include

converter="groupConverter"

then it works as expected.

Is this a bug in JSF/Primefaces?

I am using: Primefaces 3.5 Tomcat 7

Thanks

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
bradders
  • 11
  • 1
  • 3

1 Answers1

2

The converter will fail when the type behind #{maintainMB.filteredLogicalGroups} is a generic collection, such as List<Group>, instead of a plain array, such as Group[].

The reason is simple: generic type information is only present during compiletime and completely absent during runtime. EL/reflection doesn't run during compiletime but only during runtime and all it sees is thus just a List. Without a converter, it'll assume it to hold items of the default type of String, the same as HTTP request parameters.

If you want to make use of forClass, then you'd need to change List<Group> property to a Group[] property.

private Group[] filteredLogicalGroups;

Otherwise, you really have to explicitly specify the converter.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555