使用UIComponent.getId()区分按钮操作

来源:互联网 发布:盒子助手软件 编辑:程序博客网 时间:2024/03/29 15:31

环境:ADF, JSF

在开发中,经常会使用自定义的Popup和Dialog,Dialog中的按钮通常也不是默认的。不同的按钮会有不同的操作,可以使用下面的代码,简单方便进行不同操作的区分:

<af:popup >    <af:dialog title="Confirm Change" type="none" >       <f:verbatim>Would you like to save the change?</f:verbatim>      <f:facet name="buttonBar">         <af:panelGroupLayout layout="horizontal" halign="center">           <af:commandButton text="Yes" id="yes" actionListener="#{sharedPopup.handleDialog}" partialSubmit="true"/>           <af:commandButton text="No" id="no" actionListener="#{sharedPopup.handleDialog}" partialSubmit="true"/>                    </af:panelGroupLayout>      </f:facet>    </af:dialog></af:popup>......public void handleDialog(ActionEvent event) {    UIComponent source = (UIComponent)event.getSource();     if (source.getId().equals("no")) {        xxx xxxx    } else {        xxx xxxx    }      RichPopup popup = getPopup(); // popup binding    popup.hide();}



原创粉丝点击