Primefaces模态对话框不提交表单

时间:2014-02-05 16:53:55

标签: primefaces jsf-2.2

首先,我的项目预设: - JSF 2.2(Mojarra) - PrimeFaces 3.5

我的问题是:

我在所有行中都有一个带有selectBooleanCheckBox的数据表。当我选择我希望用某些信息更新的项目时,我点击按钮显示一个带有一个inputMask的模态和一个提交它的按钮。在我的managedBean中,我获得了之前由selectBoolean复选框选择的所有项目,并在项目中应用了信息。

错误与提交有关。在我向managedBean提交值的地方,标记的项目不会出现,但如果将其放在模态视图之外,则可以正常工作。

这是一段代码:

<ui:composition>
    <ui:define>
        <p:layout>
            <p:layoutUnit id="west">
            ...
            </p:layoutUnit>
            <p:layoutUnit id="center">
                <h:form id="pg_tabs">
                    <p:commandButton id="btn_ros_form" 
                        rendered="#{p:ifAnyGranted('ROLE_PROJECT_MANAGER')}"
                        icon="ui-icon-pencil"
                        onclick="modal_ros.show();"
                        value="#{msg['research.button.apply.ros']}"
                        type="button" />
                     .
                     .
                     .
                    <p:tabView>
                        <p:tab>
                            <ui:include src="pages/dataTablePiece.xhtml"/>
                        </p:tab>
                        .
                        .
                        .
                    </p:tabView>

                    <p:dialog id="dialog_ros_date" 
                    header="#{lmsg['research.dialog.ros.date.header']}" 
                    widgetVar="modal_ros" 
                    modal="true" 
                    appendToBody="true">
                    <h:panelGrid columns="2" cellpadding="3">
                        <h:outputText value="#{msg['research.filter.ROSDate']}" />
                        <p:inputMask value="#{research.ros}" 
                            mask="99/99/9999" />

                        <p:commandButton id="btn_apply_ros_date"
                            actionListener="#{research.changeROSDate}"
                            ajax="true"
                            update="#{p:component('pg_tabs')}"
                            value="#{msg['research.button.apply']}" />

                        <p:commandButton id="btn_clear_ros_date"
                            ajax="true"
                            update="#{p:component('pg_tabs')}"
                            actionListener="#{research.clearROSDate}"
                            value="#{msg['research.button.cleanROS']}" />
                    </h:panelGrid>  
                </p:dialog>
                </h:form>
            </p:layoutUnit>
        </p:layout>
    </ui:define>
</ui:composition>

这是包含的页面“dataTablePiece.xhtml”:

<p:dataTable id="dt_pro_man" 
        var="item" 
        value="#{research.items}" 
        paginator="true" 
        paginatorPosition="bottom" 
        rows="15"
        rowKey="#{item.itemId}"
        stickyHeader="true" >

        <p:column rendered="#{not p:ifGranted('ROLE_SUPPLIES')}">
            <f:facet name="header">
                <p:selectBooleanCheckbox value="#{research.allSelected}">
                    <p:ajax update="dt_pro_man" listener="#{research.selectAll}" />
                </p:selectBooleanCheckbox>
            </f:facet>
            <p:selectBooleanCheckbox value="#{item.selected}" update="dt_pro_man" immediate="true" />
        </p:column>

        <p:column sortBy="#{item.nrSc}">
            <f:facet name="header">
                <h:outputText value="#{msg['import.table.sc.number']}" />
            </f:facet>
            <h:outputText value="#{item.nrSc}" />
        </p:column>
        .
        .
        .
        <!-- other columns -->
<p:datatable>

Finnaly,我的managedBean方法:

public void changeROSDate(ActionEvent event){
        Date newRosDate;
        try {
            SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
            newRosDate = sdf.parse(ros);
            List<Item> selectedItems = getSelected(items);
            if(Assert.isNotNullOrEmpty(selectedItems)){
                for(Item item : selectedItems){
                    if (newRosDate.after(item.getDtRegistration())) {
                        item.setDtLimit(newRosDate);
                        service.save(item, StatusType.Included);
                    } else {
                        Faces.errorMessage(i18n.getMessage("research.mb.error.ros.before.registration"));
                        return;
                    }
                }
                Faces.infoMessage(i18n.getMessage("research.mb.success.update.items"));

            }else {
                Faces.infoMessage((i18n.getMessage("research.mb.info.select.one.item")));
            }
        } catch (Exception e) {
            Faces.errorMessage(i18n.getMessage("research.mb.error.update.item"));                   
        } 
}

如果您需要更多代码或更多详情,请告诉我。

感谢您的帮助,对不起的英语感到抱歉。

0 个答案:

没有答案
相关问题