2012-08-13 7 views
5

プレースバー(extlib oneuiアプリケーションレイアウト)でアクションを動的に追加したい。XPages extlib oneui layout - プレースバーアクションを動的に追加する方法

いくつかの設定文書にはいくつかのURLが格納されています。これらのURLに基​​づいて、基本的な子ノードを持つコンテナノードを作成したいと考えています。すべての子ノードはリストから1つのURLを使用します。 コンテナノードを作成し、子ノードを動的に追加する方法はありますか?任意のサンプルSSJS/Java/CSJSのコードですか?

答えて

1

すばやい返信ありがとうございます。これは私にとって非常に有益な情報です。

私はXSnippetコードといくつかの逆のenggに基づいて見つけた別の方法。

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コードに変換され、パフォーマンスが向上し、アプリケーションで一度だけ読み込まれるようにシリアライズされます。

もう一度ご協力いただきありがとうございます。

4

は245

ページ上のXPages拡張ライブラリのマニュアルで説明されて繰り返しノード(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> 
0

もう1つのことは、PhaseListenerを使用して、レンダーレスポンスの前にコンテナノードにアイテムを注入することです。それで、あなたはあなたのすべてのページのための単一の場所でそれを制御することができました。

+0

は、すべてのページに対してもそうか、推奨されているように、カスタムコントロールにレイアウトを入れて、どこにでもあることを使用します。しかし、位相リスナーは面白い演習になります – stwissel

+0

こんにちはToby、PhaseListenerにアイテムを挿入する方法のサンプルコードがありますか?私にお知らせください。ありがとう。 –

+0

答えとしてコードを追加しました。 –

1

基本的には上記のコードと同じコードですが、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関数を呼び出す
関連する問題