datatable inline editing doesn't update other rows

UI Components for JSF
Post Reply
pfaces123
Posts: 8
Joined: 04 Apr 2011, 16:37

04 Apr 2011, 17:09

I am trying to use datatable inline editing which has checkbox as one of the columns, the req is user is supposed to select only one checkbox. I have code in backing bean for rowEditListener which iterates through the list and set boolean value to false for remainng elements. Backing bean values are updated successfully but after update, however previous checkbox remains checked during rendering. How to display values of other updated rows using inline editing ?

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

04 Apr 2011, 19:30

There is onRowEditUpdate you can use to update whole datatable. By default row edit event only updates edited row.

pfaces123
Posts: 8
Joined: 04 Apr 2011, 16:37

04 Apr 2011, 19:51

Below is the code, I tried onRowEditUpdate="rpTable"
specifying datatable id but didn't work, I still see previous checkbox selected.
<p:dataTable id="rpTable"
var="rp"
value="#{bean.routePointList}"
rowEditListener="#{bean.onRowRPEdit}"
onRowEditUpdate="rpTable"
rowIndexVar="rowIx">

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

04 Apr 2011, 20:13

Try 3.0 snapshot or update a wrapper component of datatable like a parent outputPanel.

pfaces123
Posts: 8
Joined: 04 Apr 2011, 16:37

04 Apr 2011, 20:35

When I tried to use the parent panel, the list is gone for some reason. Only one editied row is displayed that too in input edit mode

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

05 Apr 2011, 14:35

You can't use the onRowEditUpdate attribute to update the entire table because the DataTableRenderer only renders the edited row on a row edit.

I wanted to update the footer on row edit so I created a patch to do so. See this thread:

http://primefaces.prime.com.tr/forum/vi ... f=3&t=6063

pfaces123
Posts: 8
Joined: 04 Apr 2011, 16:37

06 Apr 2011, 04:48

is there any solution to update other rows of the datatable when using inline editing. We are using inline editing all over our project and we need this feature to update other rows when one row is edited. If you can find the fix for this, please reply.

:x

User avatar
bumble.bee
Posts: 723
Joined: 29 Sep 2010, 21:39
Location: United States

06 Apr 2011, 14:57

Closing your eyes and pretending you didn't just read the last post? :)

Again, you can't use PrimeFaces' inline row editing out-of-the-box to update the entire table.

You can write some code though. The referenced thread in my previous post even provides some code changes to get you started - even to naively do what you are asking.

However, if you read the (entire) thread referenced you'll see that a big problem you'll encounter is that PrimeFaces' inline row editing allows mutliple rows to be open for editing simultaneously. Each row has its own independent controls for submitting and canceling edits. Think about what this means -- if you make changes such that any given row edit updates the entire table and you have multiple rows open for editing then what do you expect to happen? Cancel all other open row edits? Submit all other open row edits? You may be better off abandoning the one-row-at-a-time inline row editing that comes with PrimeFaces and just making an entire table at-a-time solution yourself. Or - you'll need to prevent multiple rows open for editing at a time.

Philipp
Posts: 23
Joined: 13 Oct 2011, 10:16

13 Oct 2011, 10:20

Hi,

I am having this issue, too. However, I cannot modify the PrimeFaces-source to get it solved and I didn't even manage to refresh the whole table because the table is inside a composite and I can't access the ID of its parent.

Anyway, there might be another possibility to solve the problem in my case and I was wondering if this is possible:
If I could refresh the whole content of a row (including a cell-editors "input"-part) before the row edit *starts*, this would also solve the problem.

Can I perform an update of the row on edit start?

Thank you for your help,

Philipp
Glassfish 3.1.2, PrimeFaces 3.4.2

krahe
Posts: 52
Joined: 09 Nov 2011, 19:13
Location: Rockford, Michigan, USA
Contact:

19 Dec 2011, 23:51

I encountered this problem, too. In my case, if the user updates a value in a particular row of the table, I want to automatically update the values in two other rows. What I did is specify a rowEditListener to determine if the value on which the other two values depends gets updated, and specified a panelGroup that contains my form's buttons as the onRowEditUpdate value to show a special button that will refresh the dataTable in that case. Here is the relevant markup from my .xhtml file:

Code: Select all

<p:dataTable id="assessmentDataTable" var="dataItem" value="#{assessmentDataBean.assessmentData}"
                    rowEditListener="#{assessmentDataBean.onEditRow}" onRowEditUpdate="buttons">
...
</p:dataTable>

<h:panelGroup id="buttons">
...
    <p:commandButton id="refreshtargetmetrics" styleClass="button" value="Update Target Metrics"
                     action="#{assessmentDataBean.updateTargetMetrics}" immediate="true"
                     rendered="#{assessmentDataBean.targeEnergyUsageEdited}" update="assessmentDataTable buttons" />
</h:panelGroup>
And here is my backing bean code:

Code: Select all

protected boolean targeEnergyUsageEdited;

public boolean isTargeEnergyUsageEdited()
{
    return targeEnergyUsageEdited;
}

public void updateTargetMetrics()
{
    //  We don't need to do anything in here except reset the flag, because the page will
    //  be updating the table and refreshing the panelGroup that contains this button.
    targeEnergyUsageEdited = false;
}

public void onEditRow( RowEditEvent aEvent )
{
    UIComponent lComp = aEvent.getComponent();
    if ( lComp instanceof DataTable )
    {
        DataTable lDataTable = (DataTable)lComp;
        Object lRowData = lDataTable.getRowData();
        if ( lRowData instanceof AssessmentDataEntry )
        {
            AssessmentDataEntry lEntry = (AssessmentDataEntry)lRowData;
            //  If this is the value we're watching for, update the dependent values and throw
            //  the switch that shows the special Update Target Metrics button
            if ( lEntry.getDataClass().equals( DataClass.ENERGY_USAGE_SF.toValue() ) &&
                 lEntry.getKey1().equals( cTargetKey ) )
            {
                double lTargetEnergyUsage = lEntry.getDataValue();
                updateTargetDataElements( lTargetEnergyUsage );  // updates values in the List that is the source of the values in the dataTable
                targeEnergyUsageEdited = true;
            }
        }
    }
}

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 61 guests