0

ボタンをクリックして、他の2つのボタンのクリックを「アクティブ化」したいと思います。このccjsをonclickイベントに入れました:

document.getElementById("#{id:button28}").click();document.getElementById("#{id:button29}").click();

しかし、ボタン28だけがクリックされます!次に、コードのこのpart1をonclickイベントの下に置き、part2をonmousedownイベントの下に置いてみました。次に、彼が実際に仕事をする前に、このボタンを2回クリックする必要があります。

これまでのコード:

<xp:button value="Save" id="button26">
<xp:eventHandler event="onclick" submit="false">
    <xp:this.script>
        <xp:executeClientScript>
    <xp:this.script><![CDATA[document.getElementById("#{id:button29}").click();
    ></xp:this.script>
        </xp:executeClientScript>
    </xp:this.script></xp:eventHandler></xp:button><xp:button id="button29" value="button29">
    <xp:eventHandler
    event="onclick" submit="true" refreshMode="partial"
    id="eventHandler21" refreshId="outsidePanel5">
        <xp:this.action>
            <xp:actionGroup>
                <xp:executeScript>
                <xp:this.script><![CDATA[#{javascript:sessionScope.put("test","");// and some more code}]]>
                </xp:this.script>
                </xp:executeScript>
            </xp:actionGroup>
        </xp:this.action>
    <xp:this.onComplete><![CDATA[document.getElementById("#{id:button28}").click();]]></xp:this.onComplete>
    </xp:eventHandler></xp:button><xp:button value="button28" id="button28">
    <xp:eventHandler event="onclick" submit="true" refreshMode="partial" refreshId="outsideMogelijkheid">
        <xp:this.action>
            <xp:executeScript
                    script="#{javascript://some code}">
            </xp:executeScript>
        </xp:this.action>
    </xp:eventHandler></xp:button>
4

2 に答える 2

1

SSJS を別のボタンで実行する場合は、CSJS でボタンをトリガーするのではなく、実際にプログラムで eventHandler を呼び出すことができます。CSJS と SSJS を常に切り替えているわけではないため、これはパフォーマンスも向上します。次のコードが機能するはずです。

var eventHandler:com.ibm.xsp.component.xp.XspEventHandler = getComponent("button29");
eventHandler.getAction().invoke(facesContext, null);
eventHandler = getComponent("button28");
eventHandler.getAction().invoke(facesContext, null);
于 2012-08-22T19:41:25.083 に答える
0

これらのボタンが SSJS コードを実行する場合、最初のボタンの onComplete イベントで 2 番目のボタンをクリックするコードを追加する必要があります。

http://xpagesblog.com/XPagesHome.nsf/Entry.xsp?documentId=0574D334CB03EACF852578CB00667F54

部分的な更新でのみ機能する わけではない onComplete の追加の動作例

<xp:button value="Save" id="button26">
<xp:eventHandler event="onclick" submit="false">
    <xp:this.script><![CDATA[document.getElementById("#{id:button29}").click()]]>
</xp:this.script>
    </xp:eventHandler></xp:button>
<xp:button id="button29" value="button29">

<xp:eventHandler event="onclick" submit="true"
    refreshMode="partial" refreshId="computedField1">

    <xp:this.action><![CDATA[#{javascript:viewScope.test="Almost Done"}]]>
</xp:this.action>
    <xp:this.onComplete>
<![CDATA[document.getElementById("#{id:button28}").click();]]>
</xp:this.onComplete>
    <xp:this.onError><![CDATA[alert("error")]]></xp:this.onError>
</xp:eventHandler></xp:button>

<xp:button value="button28" id="button28">
    <xp:eventHandler event="onclick" submit="true" 
refreshMode="partial" refreshId="computedField1">

        <xp:this.script><![CDATA[alert("Button 28")]]></xp:this.script>
        <xp:this.action>
            <xp:executeScript>
                <xp:this.script><![CDATA[#{javascript:viewScope.test="Done"}]]>
</xp:this.script>
            </xp:executeScript>
        </xp:this.action></xp:eventHandler>
</xp:button>
<xp:br></xp:br>
<xp:text escape="true" id="computedField1" value="#{viewScope.test}"></xp:text>
于 2012-08-22T09:38:12.837 に答える