来自按钮的Xpages下拉菜单

时间:2014-08-29 08:03:21

标签: button drop-down-menu xpages

Xpages有没有办法从按钮创建下拉菜单?与应用程序布局控件中的相同?

谢谢,

1 个答案:

答案 0 :(得分:3)

使用扩展程序库中的xe:popupMenu

并在按钮上的客户端javascript中使用此功能

XSP.openMenu(thisEvent,#{javascript:getComponent('popupMenu1').getMenuCtor()})

其中popupMenu1是xe:popupMenu

的名称

这是单击按钮时弹出菜单的工作示例。

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"
    xmlns:xe="http://www.ibm.com/xsp/coreex">

    <xe:popupMenu id="popupMenu1">
        <xe:this.treeNodes>
            <xe:basicLeafNode label="Entry 1" submitValue="Entry1"></xe:basicLeafNode>
            <xe:basicLeafNode label="Entry2" submitValue="Entry2"></xe:basicLeafNode>
        </xe:this.treeNodes>
        <xp:eventHandler event="onItemClick" submit="true"
            refreshMode="partial" refreshId="computedField1">
            <xe:this.action><![CDATA[#{javascript:var computedField1:com.ibm.xsp.component.xp.XspOutputText = getComponent("computedField1");
var popupMenu1:com.ibm.xsp.extlib.component.outline.UIOutlinePopupMenu = getComponent("popupMenu1");
viewScope.Clicked=context.getSubmittedValue()
}]]></xe:this.action>
        </xp:eventHandler></xe:popupMenu>
    <xp:button value="Click me" id="button1">
        <xp:eventHandler event="onclick" submit="false">
            <xp:this.script><![CDATA[XSP.openMenu(thisEvent,#{javascript:getComponent('popupMenu1').getMenuCtor()})]]></xp:this.script>
        </xp:eventHandler></xp:button>
    &#160;
    <xp:text escape="true" id="computedField1" value="#{viewScope.Clicked}"></xp:text></xp:view>