Do I really need a managed bean?

戏子无情 提交于 2019-12-11 05:45:33

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/16692194/do-i-really-need-a-managed-bean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!