当前位置: 代码迷 >> JavaScript >> 触发/模拟通过ClientListerner以编程方式单击事件
  详细解决方案

触发/模拟通过ClientListerner以编程方式单击事件

热度:23   发布时间:2023-06-06 09:46:59.0

到目前为止,我已按照文档设法获得了按钮的click事件。 我现在正在努力的是以编程方式触发ADF组件的click事件。

源代码如下:

<af:showDetailItem id="pane1" text="Panel Label 1" disclosed="true">
    <af:commandButton text="commandButton 1" id="cb1">
        <af:clientListener method="showNext" type="action" />
    </af:commandButton>
</af:showDetailItem>

<af:showDetailItem id="pane2" text="Panel Label 2">
    <af:commandButton text="commandButton 2" id="cb2">
        <af:clientListener method="showNext" type="action" />
    </af:commandButton>
</af:showDetailItem>

<af:showDetailItem id="pane3" text="Panel Label 3">
    <af:commandButton text="commandButton 3" id="cb3">
        <af:clientListener method="showNext" type="action" />
    </af:commandButton>
</af:showDetailItem>

使用Javascript

function showNext(evt){        
   var src = evt.getSource();
   var showDetailItemNode = src.getParent(); // targets the showDetailItem tag     
   /* how do I trigger the click event of this node */
}

所以我基本上想要实现的是,当点击按钮#cb1时,我想模拟showDetailItem#pane1的click事件,依此类推......

<af:serverListner> 

是一个标记,您可以将其与<af:clientListner>一起使用,以将您的事件传播到托管bean。更重要的是,您还可以将上述标记与<af:showDetailItem>相关联。 希望能帮助到你 。

如果您想在客户端上使用JavaScript完全操纵手风琴,您需要利用ADF Faces的JavaScript API。 特别是这两个: : 和

您可以遍历手风琴组件的子节点,以找出当前公开的showDetailItem。 然后将其设置为disclosure = false,并为下一个设置为true。

  相关解决方案