Access UserBean from Java
I use the userBean that comes with the extension Library in SSJS very often. It is a convenient way to access various properties of the current user.
Today I wanted to use the UserBean in Java. But I could not figure out, how to do. After some help from Stephan Wissel and a few minutes of try and error, I ended up with the following:
package de.eknori.jsf.core;
import com.ibm.xsp.extlib.beans.*;
public class User {
public static Object getUser() {
return UserBean.get().getField( "effectiveUserName" );
}
}
A UserBean.get(9 will return all fields as shown in the picture below
The getField(String) method lets you access a single value from the bean.