Reputation: 3563
I have a mapped bean in faces-config.xml
<managed-bean>
<managed-bean-name>beanName</managed-bean-name>
<managed-bean-class>java.util.HashMap</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
<managed-property>
<property-name>elements</property-name>
<map-entries>
<key-class>java.lang.String</key-class>
<value-class>path.InputFormElementContainer</value-class>
</map-entries>
</managed-property>
</managed-bean>
The implementation in java is:
public class InputFormElementContainer implements List<InputFormElement>, Serializable{
private static final long serialVersionUID = -4685106549564090233L;
private List<InputFormElement> elements;
//Empty Constructor
public InputFormElementContainer() {
elements = new ArrayList<InputFormElement>();
}
public List<InputFormElement> getElements() {
return elements;
}
public void setElements(List<InputFormElement> elements) {
this.elements = elements;
}
}
But I am getting this error when I refresh my application:
com.sun.faces.mgbean.ManagedBeanCreationException: No se puede crear el bean administrado beanName. Se han encontrado los problemas siguientes:
- No existe la propiedad elements para el bean administrado beanName.
The translation to english could be: can not create the administrated beanName due to the following problem: elemts property does not exist for beanName.
This problem came to me in the migration to JSF2. I was reading tutorials, but I could't figure out how to make this manage-bean propperly in JSF2. Could anybody help me??
Thanks in advance!
Upvotes: 0
Views: 4423
Reputation: 782
You have two options depending of how you want to model your class InputFormElementContainer
If you need 'elements' to be a List:
<managed-bean>
<managed-bean-name>beanName</managed-bean-name>
<managed-bean-class>java.util.HashMap</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
<managed-property>
<property-name>elements</property-name>
<property-class>java.util.ArrayList</property-class>
<list-entries>
<value-class>path.InputFormElementContainer</value-class>
<value>...</value
...
</list-entries>
</managed-property>
</managed-bean>
Or if you need 'elements' property to be a Map:
<managed-bean>
<managed-bean-name>beanName</managed-bean-name>
<managed-bean-class>java.util.HashMap</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
<managed-property>
<property-name>elements</property-name>
<property-class>java.util.HashMap</property-class>
<map-entries>
<key-class>java.lang.String</key-class>
<value-class>path.InputFormElementContainer</value-class>
<map-entry>
<key></key>
<value></value>
</map-entry>
</map-entries>
</managed-property>
</managed-bean>
Upvotes: 0
Reputation: 240860
It is wrong
<managed-bean-name>beanName</managed-bean-name>
<managed-bean-class>java.util.HashMap</managed-bean-class>
<managed-bean-scope>view</managed-bean-scope>
<managed-property>
<property-name>elements</property-name>
here jsf will search for getters/setters of the field elements
in java.util.HashMap which doesn't exist, and so the error
Upvotes: 1