5

I want to add actions dynamically in PlaceBar (extlib oneui application layout).

We have couple of urls stored in some configuration documents. Based on these URLs I want to create Container node having Basic Child nodes in it. Every child node use one URL from list. How I can create container node and add child nodes to it dynamically? any sample SSJS/Java/CSJS code for this?

Thank you..

Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
Prashant Arkal
  • 308
  • 2
  • 13

4 Answers4

4

Have a look at the Repeat Node (xe:repeatTreeNode) which is described in the XPages Extension Library book on page 245.

Here's a very simple example (taken directly from the book):

<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>
Per Henrik Lausten
  • 21,331
  • 3
  • 29
  • 76
1

Thank you for the quick reply. This is very useful information for me.

Another way I found out based on XSnippet code and some reverse engg. from java code in xpage as follow :

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);

This is sample code only. Converted this is into java code and serialized to improve performance and load it only once in application.

Thank you again for help.

Prashant Arkal
  • 308
  • 2
  • 13
1

basically its the same code you listed above, but in Java. and then this small code in the faces-config.xml file

<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());
    }

}
Toby Samples
  • 2,168
  • 14
  • 15
0

Another thing you can do is use a PhaseListener to inject the Items into your Container Node before render response. Then you could control it in a single place for all of your pages.

Toby Samples
  • 2,168
  • 14
  • 15
  • Calling a SSJS function in Per's example would do too for all pages or, as recommended, put the layout into a custom control and use that everywhere. But a phase listener for sure would be an interesting exercise – stwissel Aug 14 '12 at 01:45
  • Hello Toby, do you have any sample code for the way to inject items into PhaseListener? please let me know. Thanks. – Prashant Arkal Aug 16 '12 at 09:26