Primefaces数据表将数据传递给辅助bean

时间:2014-08-08 13:07:46

标签: session primefaces datatable

我们正在使用primefaces 5.有一个带有一个输出文本列的数据表和一个带有文本字段的数据表。我们希望将数据从datatable传递给backing bean。如果bean的范围是请求,那么datatable的值不会传递给辅助bean。如果bean的范围是session,那么datatable的值将传递给辅助bean。但是如果我们将bean的范围保持为session,那么当我们回到同一页面时,表单上的值就会被保留。

以下是我们的代码

    <h:form id="createForm" prependId="false">
    <p:messages id="errorMsgs"></p:messages>
    <p:panelGrid columns="1">
    <p:accordionPanel style="align:top;margin" prependId="false">
    <p:tab title="MainTab">
    <p:panelGrid columns="4" cellpadding="5">                                           
    <p:outputLabel for="id" value="Expense Items List: "/>
    <p:selectOneMenu id="id" style="width:250px" value="#{managedBean.expenseDetails.id}" required="true" requiredMessage="ExpenseDetails are required" filter="true" filterMatchMode="startsWith" >
    <p:ajax event="change" process="@this" listener="#{managedBean.getTEIList}" update="aTEModelList"/>
    <f:selectItem itemLabel="Select" itemValue="" noSelectionOption="true" />
    <f:selectItems value="#{managedBean.expenseDetailsModelList}" var="expenseDetails" itemLabel="#{expenseDetails.loadexpenseDetailsList}" itemValue="#{expenseDetails.id}" />
    </p:selectOneMenu>      
    <p:dataTable id="aTEModelList" var="aTEModelList" 
    value="#{managedBean.aTEModelList}" rowKey="#{expenseDetailsSearchResult.id}" >
    <p:column width="20%" >
    <f:facet name="header">
    <h:outputText value="Expense Short Description" />
    </f:facet>
    <h:outputText id="expenseShortDesc" value="#{aTEModelList.expenseShortDescription}" />
    </p:column>
    <p:column width="20%" >
    <f:facet name="header">
    <h:outputText value="Actual Expense Value" />
    </f:facet>
    <h:inputText id="actualexpenseDetailsExpense" value="#{aTEModelList.actualExpense}" />
    </p:column>
    </p:dataTable>
    </p:panelGrid>
    </p:tab>
    </p:accordionPanel>
    </p:panelGrid>
    <f:facet name="footer">
    <p:panelGrid columns="5">
    <p:commandButton id="submitButton" action="#{managedBean.addExpenseDetails}" value="Submit" ajax="false"  onclick="return validateForm();"></p:commandButton>
    </p:panelGrid>
    </f:facet>
    </h:form>

0 个答案:

没有答案