第二次调用操作时,JSF 2视图范围bean未更新

时间:2012-03-05 10:06:21

标签: jsf-2 facelets

我有一个视图范围的arrayList作为bean。这用于显示dataTable的可编辑列。当最初显示页面并且我尝试更新表内容时,更新工作正常,但是当我尝试更新任何列时,第二次更改的值不会反映在arrayList bean中(使用break在action方法中验证点)。 action方法也是具有视图范围的托管bean。

 <managed-bean>
    <managed-bean-name>financialListBean</managed-bean-name>
    <managed-bean-class>java.util.ArrayList</managed-bean-class>
    <managed-bean-scope>view</managed-bean-scope>
</managed-bean>

以下是dataTable的代码

        <h:form id="myform">
    <h:dataTable id="financialListBean1"
    value="#{financialListBean}" var="varfinancialListBean"
    styleClass="dataTableEx" headerClass="headerClass"
    footerClass="footerClass"
    rowClasses="rowClass1, rowClass2"
    columnClasses="columnClass1" border="0" cellpadding="2"
    cellspacing="0">
    <h:column id="columnEx17">
    <h:selectBooleanCheckbox styleClass="inputRowSelect"
    id="rowSelect3" 
    value="#{varfinancialListBean.rowSelected}"></h:selectBooleanCheckbox>
    <f:facet name="header"></f:facet>
    </h:column>
    <h:column id="amount1column">
    <f:facet name="header">
    <h:outputText styleClass="outputText" value="Amount"
    id="amount1text"></h:outputText>
    </f:facet>
    <h:inputText styleClass="small8Input" id="amount1"
    value="#{varfinancialListBean.amount}" onkeypress="return only5DigitsEntry(this, event);" onkeyup="return checkRequiredFieldsForUpdateFinancialBtn(this.form, event);">
    </h:inputText>
    </h:column>
    <h:column id="type1column">
    <h:selectOneMenu styleClass="selectOneMenu" id="menu1" value="#{varfinancialListBean.type}">
    <f:selectItem itemLabel="M" itemValue="M" />
    <f:selectItem itemLabel="Y" itemValue="Y" />
    <f:selectItem itemLabel="Z" itemValue="Z" />
    <f:selectItem itemLabel="O" itemValue="O" />
    <f:selectItem itemLabel="S" itemValue="S" />
    </h:selectOneMenu>
    <f:facet name="header">
    <h:outputText styleClass="outputText" value="Type"
    id="type1text"></h:outputText>
    </f:facet>
    </h:column>
    <h:column id="recDate1column">
    <f:facet name="header">
    <h:outputText styleClass="outputText"
    value="Recieve Date" id="recDate1text"></h:outputText>
    </f:facet>
    <h:inputText styleClass="outputText" id="recDate1"
    value="#{varfinancialListBean.recDate}" 
    onclick="getClock($(this).attr('id'))" > 
    <f:convertDateTime pattern="MMM d, yyyy"/>
    </h:inputText>
    </h:column>
    </h:dataTable>
    <h:commandButton type="submit"
    value="Update Financial Information"
    styleClass="commandExButton" id="updateFinancialBtn"
    action="#{pc_SocialServicesView.doFinancialUpdateBtnAction}">
    <f:param name="mrn" value="#{pc_SocialServicesView.mrn}" />
    </h:commandButton>
    </h:form>

行动方法:

public String doFinancialUpdateBtnAction() {

    System.out.println("I am at doFinancialUpdateBtnAction");


    try{
        if(mrn.length()==0){
            mrn=getFacesContext().getExternalContext().getRequestParameterMap().get("mrn");
        }
             setFinancialListBean(dba.updateFinancialAsistance
      (getFinancialListBean(), mrn));
        setErrorMsgBean("Updated successfully ...");
        doInit(mrn);
    }catch (Exception e) {
     System.out.println("There is an exception at      doFinancialUpdateBtnAction");
        Log.out.error("Error in doFinancialUpdateBtnAction: "+e);
        setErrorMsgBean("No record was updated ...");
        e.printStackTrace();
    }

    return "";
}

0 个答案:

没有答案