无需在JSF中使用ViewScoped / KeepAlive即可提交数据表详细信息

时间:2013-11-18 18:02:34

标签: richfaces jsf-1.2

我正在研究JSF 1.2和RichFaces 3.3.1 GA。

我有一个页面在rich:dataTable中显示100行,用户将编辑行并提交页面。我将bean保留在请求范围内,因为不需要Ajax功能(因此我不使用ViewScoped / keepalive方法。)

我的问题是,在提交数据之后,我没有将dataTable值作为支持bean中的ArrayList获取。

我的JSF页面:

<h:form name="myform">
    Name : <h:inputText id="displayName" value="#{myBean.displayName}">
    <h:dataTable id="domainList" value="#{myArcBean.domainList}" var="dataItem">
        <f:facet name="header">
            <h:outputText value="Name" />
        </f:facet>
        <f:facet name="header">
            <h:outputText value="Password" />
        </f:facet>
        <f:facet name="header">
            <h:outputText value="Department" />
        </f:facet>
        <rich:column>
            <h:inputText id="name" value="#{dataItem.name}"/>
        </rich:column>
        <rich:column>
            <h:inputText id="password" value="#{dataItem.password}"/>
        </rich:column>
        <rich:column>
            <h:inputText id="department" value="#{dataItem.department}"/>
        </rich:column>
    </h:dataTable>
    <h:commandButton value="Save" type="submit" action="#{myArcBean.submit}" />
</h:form>

我的支持豆:

public class MyArcBean  {

    private String dispalyName;
    private MyDomain mydomain = new MyDomain();
    private String[] list = new String[3];
    private List<MyDomain> domainList =  null;
    ArcUser loggedInUser = null;
    private HtmlInputHidden addCount = new HtmlInputHidden();

    public MyArcBean() {
    }

    public String loadData() {
        if(domainList==null)
            domainList = new ArrayList<MyDomain>();
        mydomain.setName("Munivel");
        mydomain.setDepartment("Houston");
        mydomain.setPassword("password");
        loadDataList();
        this.dispalyName="testName";
        return "MyArc";
    }

    public String submit() {
        System.out.println("The Name--->"+this.getDomainList());
        return "MyArc";
    }

    public void loadDataList() {
        domainList.add(new MyDomain("Muni","IT","password")); 
        domainList.add(new MyDomain("Vel","IT","password")); 
        domainList.add(new MyDomain("Hii","IT","password")); 
    }

    public HtmlInputHidden getAddCount() {
        return addCount;
    }

    public void setAddCount(HtmlInputHidden addCount) {
        this.addCount = addCount;
    }

    public HtmlDataTable getResReqRoleTable() {
        return resReqRoleTable;
    }

    // and standard getters and setters for:
    // dispalyName, mydomain, list and domainList
}

在页面加载时,我正在调用loadData方法。它加载domainList值并将值显示为dataTable。单击提交按钮后,我没有从支持Bean获取domainList值。我只获得displayName属性值。

0 个答案:

没有答案