jsf2 +<托管财产><属性名称>属性名称>托管财产>
我在 faces-config.xml 中有一个映射 bean
<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>
java 中的实现是:
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;
}
}
但是当我刷新应用程序时,我收到此错误:
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.
英语翻译可能是: 由于无法创建管理 beanName解决以下问题:beanName 的 elemts 属性不存在。
我在迁移到 JSF2 时遇到了这个问题。我正在阅读教程,但我不知道如何在 JSF2 中正确制作这个管理 bean。有人可以帮助我吗?
提前致谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是错误的
,jsf 将在 java.util.HashMap 不存在,所以错误
It is wrong
here jsf will search for getters/setters of the field
elements
in java.util.HashMap which doesn't exist, and so the error根据您想要如何对类 InputFormElementContainer 进行建模,您有两个选择
如果您需要将“elements”作为列表:
或者如果您需要将“elements”属性作为映射:
You have two options depending of how you want to model your class InputFormElementContainer
If you need 'elements' to be a List:
Or if you need 'elements' property to be a Map: