首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >XPages extlib oneui布局-如何动态添加位置栏动作

XPages extlib oneui布局-如何动态添加位置栏动作
EN

Stack Overflow用户
提问于 2012-08-14 01:33:15
回答 4查看 1.4K关注 0票数 5

我想在PlaceBar (extlib oneui应用程序布局)中动态添加动作。

我们在一些配置文档中存储了几个urls。基于这些URL,我想创建容器节点,其中包含基本的子节点。每个子节点使用列表中的一个URL。如何动态创建容器节点并添加子节点?这里有没有SSJS/Java/CSJS示例代码?

谢谢。。

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2012-08-16 11:03:21

感谢您的快速回复。这对我来说是非常有用的信息。

我发现的另一种方式是基于XSnippet代码和一些反向工程。来自xpage中的java代码,如下所示:

代码语言:javascript
运行
复制
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代码并序列化以提高性能,并且只在应用程序中加载一次。

再次感谢您的帮助。

票数 1
EN

Stack Overflow用户

发布于 2012-08-14 04:05:21

看看重复节点(xe:repeatTreeNode),它在第245页的XPages扩展库一书中进行了描述。

下面是一个非常简单的例子(直接取自本书):

代码语言:javascript
运行
复制
<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>
票数 4
EN

Stack Overflow用户

发布于 2012-08-16 19:51:24

它基本上和你上面列出的代码是一样的,但是是用Java写的。然后faces-config.xml文件中的这段小代码

代码语言:javascript
运行
复制
<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());
    }

}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11939335

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档