Search code examples
javaxpageslotus-domino

Is possible to add annotation @ManagedBean in XPages?


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;
    }


}

it doesn't compile:

@ManagedBean(name="photoBean")
@SessionScoped

Is there special code to do that? Or is it only for Java EE and not for Lotus? Notes says to create the annotations.


Solution

  • 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>
    

    Happy Programming!