Sheet: loosing data when working fast, possible bug?
See original GitHub issueDescribe the bug
Some of our users work fast in a sheet, all changes look ok, possitive growl feedback, but after F5 a lot of changes are reverted.
client side I do <p:ajax event="change" update="@none" listener="#{perceelSheetController.cellChangeEvent}"
serverside I have a sessionscoped bean, that stores updates, handles errors and applies client update logic.
Serverside I tried synchronizing, locking. Clientside I tried eliminating other events than change, updating the whole sheet in onchange seems to help but leads to a hard to fix scrolling problem.
I cannot yet exactly pinpoint the problem, not even after extensice debugging client and server, but it looks like a client side problem where the browser sends data before everything that should be completed is completed.
Do some other users of sheet experience problems like this? Could I overlook something crucial?
Reproducer
Sorry, no reproducer yet
PrimeFaces Extensions version
11.0.2
JSF implementation
Mojarra
JSF version
2.3
Affected browsers?
firefox
Steps to reproduce the behavior
No response
Expected behavior
updates applied and saved
Sample XHTML
<pe:sheet id="sheet" widgetVar="sheetWidget" value="#{perceelSheetController.percelen}" var="row" rowStyleClass="#{row.id == null ? 'nieuw' : ''}"
rowKey="#{perceelSheetController.getRowKey(row.id)}" showRowHeaders="true"
resizableCols="true" resizableRows="true" filteredValue="#{perceelSheetController.filtering.filtered}"
readOnly="#{not accessController.mayEdit()}">
<p:ajax event="change" update="@none" listener="#{perceelSheetController.cellChangeEvent}"
onerror="window.setTimeout(function() {focusFirstSheetError('sheetWidget');}, 200);"/>
<p:ajax event="cellSelect" update="@none" listener="#{perceelSheetController.cellSelectEvent}" disabled="#{perceelSheetController.isChangeErrors()}"/>
Sample Bean
public void cellChangeEvent(final SheetEvent event) {
.
# I show only the last bit of what this function does because calling update ajax().update( might cause the problem?
.
JsfUtil.addSuccessMessage("Saved " + percs.stream().map(p -> perceelConverter.getAsString(null, null, p)).collect(Collectors.joining()));
List<String> pfupdates = new ArrayList<>(3);
if (gemStatusChange) pfupdates.add("menuform");
if (nieuwPerceel) {
PrimeFaces.current().executeScript("sc();");
} else {
pfupdates.add("buttons");
}
if (!pfupdates.isEmpty()) PrimeFaces.current().ajax().update(pfupdates);
}
Issue Analytics
- State:
- Created a year ago
- Comments:11 (11 by maintainers)
Yes, therefore cellselect event is
async=true
, change event isasync=false
, change method is synchronized, jpa and optimistic locking garantee data integrity, this probably fixes the issue (awaiting testers)This issue I solved like this: