문제

This is my xhtml code containing a datatable using row expansion. Using primefaces 4.0, jsf mozarra 2.2.4

<p:dataTable id="myTable" value="#{myBean.lazyModel}" var="dd"
    rowKey="#{dd.hashCode()}" paginator="true"
    selection="#{myBean.myModel.selectedRecords}" rows="#{myBean.pageSize}"
    paginatorPosition="top"
    paginatorTemplate="{CurrentPageReport}  {FirstPageLink}   
                       {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}             {RowsPerPageDropdown}"
    rowsPerPageTemplate="5,10,20,50,100" widgetVar="dataTable"
    currentPageReportTemplate="(Number of Records: {totalRecords})"
    lazy="true">  
     <p:ajax event="rowToggle" listener="#{myBean.onRowToggle}" process="@this"/>
<p:column>
    <p:rowToggler />
</p:column>

<p:column selectionMode="multiple" id="select" />

<p:column id="cpn" headerText="#{messages['cpn']}"
    filterMatchMode="contains" sortBy="#{dd.cpn}" filterBy="#{dd.cpn}">
    <p:inputText id="cpnid" value="#{dd.cpn}" />
</p:column>
<p:column id="user" headerText="#{messages['user']}"
    filterMatchMode="contains" sortBy="#{dd.number}"
    filterBy="#{dd.number}">
    <p:inputText id="addid" value="#{dd.number}" />
</p:column>
   :
   :    
<p:rowExpansion id="rowExpansion">
    <p:panelGrid>
        <p:row>
            <p:column>
                <h:outputText value="#{messages['name']}" />
            </p:column>

            <p:column>
                <p:inputText id="name" name="txtBox" value="#{dd.name}" />
            </p:column>

            <p:column>
                <h:outputText value="#{messages['ageGroup']}" />
            </p:column>

            <p:column id="agecol">
                <p:selectOneMenu id="agegrp" value="#{dd.agegrp}">
                    <f:selectItem itemLabel="21-25" itemValue="21-25" />
                    <f:selectItem itemLabel="26-30" itemValue="26-30" />
                </p:selectOneMenu>
            </p:column>
        </p:row>
    </p:panelGrid>
    </p:rowExpansion>
 </p:dataTable>   

Now I expanded a row and entered name and selected age group and collapsed the row. If I reexpand the same row I couldn't see the values I have entered. When I debugged on collapsing the row The name field and age grp fields setters are called with null parameters.

If I remove the ajax rowToggle event then there is no request is sent to the server on row collapse.

All the examples I found are showing only static data on row expansion.

Is there any way to process data user entered on row collapse?

Any help is highly appreciated.

올바른 솔루션이 없습니다

다른 팁

I had the same problem. Do you use this datatable in a dialog?

Try set dynamic=false in parent dialog. Dynamic dialog may override your ajax request

Try to add <p:ajax partialSubmit="true" /> inside each input forms

Just remove sortBy from child table. It's works to me.

Or, In xhtml file (MasterDataTable):

<p:ajax event="rowToggle" listener="#{superView.ontoggle()}" />

On View file:

public void ontoggle() {
    UIComponent table = FacesContext.getCurrentInstance().getViewRoot().findComponent("form:MasterDataTable:ChildDataTable");
    if (table != null) {
        table.setValueExpression("sortBy", null);
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top