Do I really need a managed bean?

2019-07-29 23:08发布

Everyting I have read about calling Java from Xpages mentions managed beans. But I really don't need to save the state of my object. Do I still need to make my class managed?

What I need to do is to check to see if a password is expired for a user in Directory Services (LDAP). My plan was to check the state using my LDAP class then store the result in a regular session variable. So would I still need to use a managed bean?

If not, do I still need to mention the class in faces-config.xml or anyplace else?

标签: xpages
1条回答
爷、活的狠高调
2楼-- · 2019-07-29 23:31

As Henrik said you dont need to use a bean. Here a short example how to call a java class directly. Lets say your class is in the package org.testin Path: yourApplication.nsf/webContent/WEB-INF/src/

package org.test;

public class Test{

    public static String halloWorld() throws Exception {
        return "HalloWorld";
    }
}

you can call its Methods by using:

<xp:text value="#{javascript:return org.test.Test.halloWorld();}"></xp:text>

You can find more Infos on that in the IBM wiki.

查看更多
登录 后发表回答