在ui中重复创建p:pickList:repeat不会调用ajax传输事件

时间:2016-02-16 15:28:48

标签: jsf jsf-2 primefaces

以下是根据p:pickList对象在ui:repeat内创建Analysis的代码:

<ui:repeat value="#{section.questions}" var="question" varStatus="qStatus">
    <h:form id="questionForm#{qStatus.index+1}">

    <p:fieldset style="border:none; " rendered="#{question.questionType.titleId eq 'OrderList'}">
        <div class="ui-grid-row">
            <div class="ui-grid-col-12 questionText">
                <strong>#{qStatus.index+1}.</strong>
                <h:outputText value="#{ question.questionText}" />
            </div>
        </div>
        <div class="ui-grid-row">
            <div class="ui-grid-col-12">

                <p:pickList id="orderQuestionPickList#{qStatus.index+1}" styleClass="dutyPickList" responsive="true" showTargetControls="true"
                            value="#{analysisBean.sampleDualList}" var="option" itemLabel="#{option.text}" itemValue="#{option}" converter="#{itemConverter}"  >
                    <f:facet name="sourceCaption">Tüm Şıklar</f:facet>
                    <f:facet name="targetCaption">Seçilen Şıklar</f:facet>

                    <p:ajax event="transfer" listener="#{analysisBean.onPickListTransfer}" />

                </p:pickList>
            </div>
        </div>
    </p:fieldset>

    </h:form>
</ui:repeat>

和豆:

public void onPickListTransfer(TransferEvent event) {
    System.out.println("asd");
    int totalItemsNumber = 0;

    DualListModel<Option> dualListModel = (DualListModel<Option>) getDualListOfOptions(new ArrayList<Option>());
    if (dualListModel != null) {
        totalItemsNumber = dualListModel.getTarget().size();
    }

}

当我在ui:repeat之外添加选项列表时,它会成功调用onPickListTransfer,但ui:repeater内的选项列表不会调用。

我该如何解决这个问题? Primefaces 5.3,Seam 2.3.1

1 个答案:

答案 0 :(得分:0)

解决方案是使用<f:param name="skipValidation" value="true"/>

<p:pickList id="orderQuestionPickList#{qStatus.index+1}" styleClass="dutyPickList" responsive="true" showTargetControls="true"
                        value="#{analysisBean.sampleDualList}" var="option" itemLabel="#{option.text}" itemValue="#{option}" converter="#{itemConverter}"  >
                <f:facet name="sourceCaption">Tüm Şıklar</f:facet>
                <f:facet name="targetCaption">Seçilen Şıklar</f:facet>

                <f:param name="skipValidation" value="true"/>

                <p:ajax event="transfer" listener="#{analysisBean.onPickListTransfer}" />

            </p:pickList>