我想在PlaceBar (extlib oneui应用程序布局)中动态添加动作。
我们在一些配置文档中存储了几个urls。基于这些URL,我想创建容器节点,其中包含基本的子节点。每个子节点使用列表中的一个URL。如何动态创建容器节点并添加子节点?这里有没有SSJS/Java/CSJS示例代码?
谢谢。。
发布于 2012-08-16 11:03:21
感谢您的快速回复。这对我来说是非常有用的信息。
我发现的另一种方式是基于XSnippet代码和一些反向工程。来自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代码并序列化以提高性能,并且只在应用程序中加载一次。
再次感谢您的帮助。
发布于 2012-08-14 04:05:21
看看重复节点(xe:repeatTreeNode),它在第245页的XPages扩展库一书中进行了描述。
下面是一个非常简单的例子(直接取自本书):
<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>发布于 2012-08-16 19:51:24
它基本上和你上面列出的代码是一样的,但是是用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());
}
}https://stackoverflow.com/questions/11939335
复制相似问题