2014-08-29 347 views

回答

3

使用XE:POPUPMENU從擴展庫

而這個函數在客戶端的JavaScript上的按鈕

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

其中popupMenu1是的名稱xe:popupMenu

這是一個工作實例e單擊按鈕時彈出菜單。

<?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> 
+0

它不適合我。 – 2014-08-29 08:28:47

+0

做了我的示例工作,請標記答案爲好,並解決此問題 – 2014-08-31 11:45:21