如何执行具有show popup行为和action事件的commandButton

时间:2013-12-06 05:46:09

标签: jsf oracle-adf

//I'm having a command button like 
   <af:commandButton text="Validate"
                        binding="#{backingBeanScope.backing_Second.cb2}"
                        id="cb2"
                        action="#{backingBeanScope.backing_Second.cb2_ClickAction}">
                        <af:showPopupBehavior popupId="p11" />
 </af:commandButton>
//Popup dialog contains
<af:popup id="p11">
<af:dialog id="d2"
dialogListener="#{backingBeanScope.backing_Second.getAddressDialogListener}">
<af:panelLabelAndMessage label="Enter the Password for DataSource " id="plam13"/>
<af:inputText label="password" value="#{backingBeanScope.backing_Second.password}" id="it455"/>

</af:dialog>
</af:popup>
//Dialog listener in backing bean having
    public void  getAddressDialogListener(DialogEvent dialogEvent) {
    System.out.println("" + this.getPassword());
        SampleJdbc.DB_PASSWORD=this.getPassword();}
支持bean中的

cb2_ClickAction返回onestring,并使用此字符串重定向到下一页。 我的要求是,当我点击验证时,它会在弹出窗口中询问密码并获取该密码,然后调用cb2_ClickAction并重定向到下一页。它无效。

3 个答案:

答案 0 :(得分:6)

仅使用命令按钮显示弹出窗口

    <af:commandButton text="commandButton 1" id="cb1">
      <af:showPopupBehavior popupId="p1"/>
    </af:commandButton>
    <af:popup id="p1">
      <af:dialog id="d2" dialogListener="#{PopupBean.myDialogListner}"/>
    </af:popup>

并使用对话框侦听器验证密码并重定向

public void myDialogListner(DialogEvent dialogEvent) {
    if(dialogEvent.getOutcome() == DialogEvent.Outcome.ok){
        FacesContext fctx = FacesContext.getCurrentInstance();
        try {
            fctx.getExternalContext().redirect("untitled1.jspx");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

答案 1 :(得分:2)

行动应仅用于导航(=最佳做法,而不是规则)。 如何使用ActionListener事件并显示来自辅助bean的弹出窗口。代码示例here。 AL在Action之前触发,因此您可以评估用户操作并选择返回字符串以进行导航。

答案 2 :(得分:0)

Showpopup行为取消了动作事件。所以两者都不能并排。在您的情况下,尝试使用render kit类从actionlistener代码中执行弹出行为。

相关问题