可以在XPages中添加注释@ManagedBean吗? [英] Is possible to add annotation @ManagedBean in XPages?
问题描述
我尝试在Java类中添加注释,以将XPages中的bean包含进来. 但是当我尝试这样做时:
I try to add annotations in a Java class to take the bean in XPages. But when I try this:
@ManagedBean(name="photoBean")
@SessionScoped
public class PhotoBean implements Serializable {
private static final long serialVersionUID = -6839844250507324282L;
private String idPhoto;
private String nomPhoto;
public String getIdPhoto() {
return idPhoto;
}
public void setIdPhoto(String idPhoto) {
this.idPhoto = idPhoto;
}
}
它不能编译:
@ManagedBean(name="photoBean")
@SessionScoped
是否有特殊的代码可以做到这一点?还是仅适用于Java EE而不适用于Lotus? Notes说要创建注释.
Is there special code to do that? Or is it only for Java EE and not for Lotus? Notes says to create the annotations.
推荐答案
正如他们所说,不可以,无法在Xpages中使用注释.该死!是的,我也想要他们.无论如何,要注册Bean的方法是通过faces-config.xml文件. (程序包浏览器视图,application/WebContent/WEB-INF/faces-config.xml)XML如下所示:
As they said, no, it is not possible to use the annotations in Xpages. DARN! Yeah, i want them too. Anyway the way to go about registering your Beans is through the faces-config.xml file. (package explorer view, application/WebContent/WEB-INF/faces-config.xml) The XML would look like:
<?xml version="1.0" encoding="UTF-8"?>
<faces-config>
<managed-bean>
<managed-bean-name>ErrWriter</managed-bean-name>
<managed-bean-class>de.hol.utils.errorHandling.ErrorWriter</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<!--AUTOGEN-START-BUILDER: Automatically generated by IBM Domino Designer. Do not modify.-->
<!--AUTOGEN-END-BUILDER: End of automatically generated section-->
</faces-config>
编程愉快!
这篇关于可以在XPages中添加注释@ManagedBean吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!