嵌套组件的有效actionSource名称/目标



给定以下实现,在组合中设置的正确值是什么:actionSource@name或@targers,以便我的actionSource引用a4j:commandButton@id="yes"

<composite:implementation>
    <a4j:commandButton value="Delete selected" execute="@this"
                       oncomplete="#{rich:component('confirmDeletePopup')}.show()"/>
    <rich:popupPanel id="confirmDeletePopup">
        <h:form id="confirmForm">
            <a4j:outputPanel id="confirmDeletePanel" styleClass="popup">
                <h:panelGroup rendered="#{not empty cc.attrs.deleteSelectedBean.selection}">
                    Are you sure?
                    <div class="popupButtons">
                        <a4j:commandButton value="Yes" id="yes"
                                           execute="@this" 
                                           action="#{cc.attrs.deleteSelectedBean.deleteSelected()}"
                                           oncomplete="#{rich:component('confirmDeletePopup')}.hide(); return false"/>
                        <h:commandButton styleClass="yesNo"
                                         value="No" immediate="true">
                            <rich:componentControl target="confirmDeletePopup" operation="hide" />
                        </h:commandButton>
                    </div>
                </h:panelGroup>
                <h:panelGroup rendered="#{empty cc.attrs.deleteSelectedBean.selection}">
                    First choose what you want to delete!
                    <div class="popupButtons">
                        <h:commandButton value="Cancel" immediate="true">
                            <rich:componentControl target="confirmDeletePopup" operation="hide" />
                        </h:commandButton>
                    </div>
                </h:panelGroup>
            </a4j:outputPanel>
        </h:form>
    </rich:popupPanel>
</composite:implementation>

编辑:到目前为止,我尝试了name="yes":

<composite:interface>
    <composite:attribute name="deleteSelectedBean" type="pl.aw.presentation.common.DeleteSelectedEntitiesBean"/>
    <composite:attribute name="render" />
    <composite:actionSource name="yes"/>
</composite:interface>

尝试引用actionSource如下:

与监听器的关系如下:

public class OrganizationListBean {
    //...
    public ActionListener getDeleteListener() {
        return new ActionListener() {
            @Override
            void processAction(ActionEvent event) throws AbortProcessingException {
                System.out.println("listener run");
            }
        }
    }
}

但是代码没有被执行。

我也试过添加(由Intellij Idea自动完成)targets="confirmDeletePopup:confirmForm:confirmDeletePanel:yes",但后来我得到

java.lang.IllegalArgumentException: confirmDeletePopup
        at javax.faces.component.UIComponentBase.findComponent(UIComponentBase.java:612) [jboss-jsf-api_2.1_spec-2.1.18.Final.jar:2.1.18.Final]
        at com.sun.faces.facelets.tag.composite.AttachedObjectTargetImpl.getTargets(AttachedObjectTargetImpl.java:96) [jsf-impl-2.1.29-03.jar:2.1.29-03]

我使用JBoss EAP 6.1。

文档看起来很清楚:

  • targets -按钮id(s)
  • name -按钮的id,以防你没有设置targets,否则它只是一个标识符

所以你设置name="yes"

相关内容

  • 没有找到相关文章

最新更新