我真的需要一个托管 bean 吗? [英] Do I really need a managed bean?
问题描述
我读过的关于从 Xpages 调用 Java 的所有内容都提到了托管 bean.但我真的不需要保存我的对象的状态.我还需要管理我的课程吗?
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?
我需要做的是检查目录服务 (LDAP) 中用户的密码是否已过期.我的计划是使用我的 LDAP 类检查状态,然后将结果存储在常规会话变量中.那么我还需要使用托管 bean 吗?
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?
如果没有,我是否还需要在 faces-config.xml 或其他任何地方提及该类?
If not, do I still need to mention the class in faces-config.xml or anyplace else?
推荐答案
正如 Henrik 所说,您不需要使用 bean.这是一个如何直接调用java类的简短示例.假设您的类位于路径中的 org.test
包中:yourApplication.nsf/webContent/WEB-INF/src/
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.test
in 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>
您可以在 IBM wiki 中找到更多相关信息.
这篇关于我真的需要一个托管 bean 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!