Reputation: 57
I need to determine the value to be displayed in the menu according to the logged-in user. If there are Ariel, Austin, Jennifer and Ryan in the menu, when I log in as Ariel, the menu will not show Ariel, there will only be Austin, Jennifer and Ryan. How to achieve this requirement?
Upvotes: 2
Views: 112
Reputation: 30960
Get the current logged-in user name with
var username = session.createName(session.getEffectiveUserName()).getCommon()
and remove the name from the list of users.
Example:
<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:comboBox id="comboBox1">
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:
var names = new java.util.ArrayList();
names.add("Ariel A");
names.add("Austin B");
names.add("Jennifer C");
names.add("Ryan D");
var username = session.createName(session.getEffectiveUserName()).getCommon();
names.remove(username);
return names;
}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
</xp:view>
Upvotes: 2
Reputation: 20384
The easiest way is to bind the available selection to a JavaScript function or a managed bean. It returns an array (JS) or collection (Java). Inside the function you can do the needful based on the user
Upvotes: 0