1

After having an instance of a Converter within a Managed Bean according to same issue as described in stackoverflow questions listed below, I am getting an exception that the object was not found.

Expression Error: Named Object: ch.foo.EnitityConverter@f163464 not found

Stackoverflow questions:

My xhtml code:

<h:selectManyCheckbox value="#{bean.selectedEmployees}">
  <f:converter converterId="#{bean.entityConverter}" />
  <f:selectItems value="#{bean.allEmployees}" var="e" itemLabel="#{e.name}" />    
</h:selectManyCheckbox>
4

2 に答える 2

1

The converterId attribute expects the converter ID (the converter name). Any EL expression value is evaluated as a String. You're basically passing the toString() result of your converter instance to it, which is ch.foo.EnitityConverter@f163464. This converter ID is in turn not recognized as any of the registered converters. However .. You didn't want to pass the converter ID, but instead just reference a whole converter instance.

The converterId attribute is the wrong attribute whenever you want to reference a whole concrete instance instead. Use the binding attribute instead, or the input component's converter attribute.

Thus, so

<h:selectManyCheckbox value="#{bean.selectedEmployees}">
  <f:converter binding="#{bean.entityConverter}" />
  <f:selectItems value="#{bean.allEmployees}" var="e" itemLabel="#{e.name}" />    
</h:selectManyCheckbox>

or

<h:selectManyCheckbox value="#{bean.selectedEmployees}" converter="#{bean.entityConverter}">
  <f:selectItems value="#{bean.allEmployees}" var="e" itemLabel="#{e.name}" />    
</h:selectManyCheckbox>
于 2012-11-16T12:31:34.183 に答える
-2

It is missing converter name. Your name may be like entityConverter. Default will be calss name. Use as below;

   <f:converter converterId="#{entityConverter}" />
于 2012-11-16T10:52:54.623 に答える