我想在PlaceBar(extlib oneui應用程序佈局)中動態添加動作。XPages extlib oneui layout - 如何動態添加placebar動作
我們有幾個存儲在某些配置文件中的URL。基於這些URL我想創建具有基本子節點的容器節點。每個子節點使用列表中的一個URL。 如何創建容器節點並動態添加子節點?任何示例SSJS/Java/CSJS代碼?
謝謝。
我想在PlaceBar(extlib oneui應用程序佈局)中動態添加動作。XPages extlib oneui layout - 如何動態添加placebar動作
我們有幾個存儲在某些配置文件中的URL。基於這些URL我想創建具有基本子節點的容器節點。每個子節點使用列表中的一個URL。 如何創建容器節點並動態添加子節點?任何示例SSJS/Java/CSJS代碼?
謝謝。
感謝您的快速回復。這對我來說非常有用。
另一種方法是基於XSnippet代碼和一些反向engg找到的。從xpage的java代碼如下:
var oneui = getComponent("applicationLayout1");
var uiConfig = oneui.getConfiguration();
var containerNode:com.ibm.xsp.extlib.tree.complex.ComplexContainerTreeNode = new com.ibm.xsp.extlib.tree.complex.ComplexContainerTreeNode();
containerNode.setLabel("Cluster Applications");
var docAppProfile = docColl.getFirstDocument();
while(docAppProfile != null)
{
var children:com.ibm.xsp.extlib.tree.complex.ComplexLeafTreeNode = new com.ibm.xsp.extlib.tree.complex.ComplexLeafTreeNode();
children.setComponent(oneui);
children.setLabel(docAppProfile.getItemValueString("appTitle"));
children.setHref(docAppProfile.getItemValueString("appURL"));
children.setImage(docAppProfile.getItemValueString("appLogoThumb"));
containerNode.addChild(children);
children = null;
var tempDoc = docColl.getNextDocument(docAppProfile);
docAppProfile = null;
docAppProfile = tempDoc;
}
uiConfig.addPlaceBarAction(containerNode);
這只是示例代碼。將其轉換爲java代碼並進行序列化,以提高性能並在應用程序中只加載一次。
再次感謝您的幫助。
看一看這是在中使用XPages擴展庫書中描述245頁
這裏是一個非常簡單的例子(直接從書上所採取的重複節點(xe:repeatTreeNode
) ):
<xe:repeatTreeNode var="val">
<xe:this.value>
<![CDATA[#{javascript:return [
["Home","home"],
["Domino","domino"],
["OneUI","oneui"]
];}]]>
</xe:this.value>
<xe:this.children>
<xe:basicLeafNode>
<xe:this.submitValue><![CDATA[#{javascript:return val[1]}]]></xe:this.submitValue>
<xe:this.label><![CDATA[#{javascript:return val[0]}]]></xe:this.label>
</xe:basicLeafNode>
</xe:this.children>
</xe:repeatTreeNode>
您可以做的另一件事是使用PhaseListener在渲染響應之前將項注入容器節點。然後,您可以在一個地方爲您的所有網頁進行控制。
基本上它與上面列出的代碼相同,但在Java中。然後在faces-config.xml文件
<lifecycle>
<phase-listener>com.company.app.phaselisteners.PlaceBarInjector</phase-listener>
</lifecycle>
package com.company.app.phaselisteners;
public class PlaceBarInjector implements PhaseListener {
private static final long serialVersionUID = 1L;
public PhaseId getPhaseId() {
return PhaseId.RENDER_RESPONSE;
}
public void beforePhase(PhaseEvent event) {
UIComponent oneui = JSFUtil.findComponent("applicationLayout1");
Configruation uiconfig = oneui.getConfiguration();
ComplexContainerTreeNode containerNode = new ComplexContainerTreeNode();
containerNode.setLabel("Cluster Applications");
Document docAppProfile = docColl.getFirstDocument();
while(docAppProfile != null)
{
ComplexLeafTreeNode children = new ComplexLeafTreeNode();
children.setComponent(oneui);
children.setLabel(docAppProfile.getItemValueString("appTitle"));
children.setHref(docAppProfile.getItemValueString("appURL"));
children.setImage(docAppProfile.getItemValueString("appLogoThumb"));
containerNode.addChild(children);
Document tempDoc = docColl.getNextDocument(docAppProfile);
docAppProfile = tempDoc;
}
uiConfig.addPlaceBarAction(containerNode);
}
public void afterPhase(PhaseEvent event) {
System.out.println("END PHASE " + event.getPhaseId());
}
}
撥打每的示例SSJS函數將所有頁面做太多或者,如推薦的這款小碼,把佈局到一個自定義的控制和使用無處不在。但一個階段的聽衆肯定會是一個有趣的練習 – stwissel 2012-08-14 01:45:31
你好託比,你有任何樣品代碼的方式注入項目到PhaseListener?請告訴我。謝謝。 – 2012-08-16 09:26:09
我添加了代碼作爲答案。 – 2012-08-16 11:51:37