From 945e864245b43443749cc1edeafeba0096f3ef1f Mon Sep 17 00:00:00 2001 From: Bernd Bohmann Date: Thu, 5 Dec 2024 17:33:21 +0100 Subject: [PATCH] feat(sheet): Invoke renderResponse when decode lazyUpdate to render Response immediate issue: TOBAGO-2371 (cherry picked from commit 1b71c70ec5a969d411becff3dc03f23b812a415b) --- .../internal/component/AbstractUISheet.java | 15 +++++++++- .../renderkit/renderer/SheetRenderer.java | 1 + .../080-sheet/90-lazy/Sheet_Lazy.xhtml | 29 +++++++++++++++++-- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java index 3cd4602c58..1f12984ee4 100644 --- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java +++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java @@ -23,6 +23,7 @@ import org.apache.myfaces.tobago.component.Pageable; import org.apache.myfaces.tobago.component.Visual; import org.apache.myfaces.tobago.event.PageActionEvent; +import org.apache.myfaces.tobago.event.SheetAction; import org.apache.myfaces.tobago.event.SheetStateChangeEvent; import org.apache.myfaces.tobago.event.SheetStateChangeListener; import org.apache.myfaces.tobago.event.SheetStateChangeSource; @@ -348,7 +349,8 @@ public void processValidators(FacesContext context) { @Override public void processUpdates(final FacesContext context) { - process(context, isReadonlyRows(), (fc, uic) -> uic.processUpdates(fc)); + process(context, isReadonlyRows() || isLazyUpdate(context), + (fc, uic) -> uic.processUpdates(fc)); final SheetState sheetState = getSheetState(context); if (sheetState != null) { @@ -689,6 +691,17 @@ private int getRowIndexFromSubtreeId(String sourceId, char separatorChar, int cl return -1; } + private boolean isLazyUpdate(FacesContext facesContext) { + final String sourceId = facesContext.getExternalContext().getRequestParameterMap().get("jakarta.faces.source"); + final String clientId = getClientId(facesContext); + + final String sheetClientIdWithAction = + clientId + UINamingContainer.getSeparatorChar(facesContext) + Pageable.SUFFIX_PAGE_ACTION + SheetAction.lazy; + + return sheetClientIdWithAction.equals(sourceId); + } + + public void init(final FacesContext facesContext) { sort(facesContext, null); layoutHeader(); diff --git a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java index 849c966ddf..4db367853d 100644 --- a/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java +++ b/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/renderkit/renderer/SheetRenderer.java @@ -150,6 +150,7 @@ public void decodeInternal(final FacesContext facesContext, final T component) { if (requestParameterMap.containsKey(key)) { component.setLazyUpdate(true); component.setLazyFirstRow(Integer.parseInt(requestParameterMap.get(key))); + facesContext.renderResponse(); } } diff --git a/tobago-example/tobago-example-demo/src/main/webapp/content/080-sheet/90-lazy/Sheet_Lazy.xhtml b/tobago-example/tobago-example-demo/src/main/webapp/content/080-sheet/90-lazy/Sheet_Lazy.xhtml index 783b825a02..5510938f0d 100644 --- a/tobago-example/tobago-example-demo/src/main/webapp/content/080-sheet/90-lazy/Sheet_Lazy.xhtml +++ b/tobago-example/tobago-example-demo/src/main/webapp/content/080-sheet/90-lazy/Sheet_Lazy.xhtml @@ -20,13 +20,15 @@ + xmlns:ui="http://xmlns.jcp.org/jsf/facelets" + xmlns:f="http://xmlns.jcp.org/jsf/core"> + - + @@ -41,5 +43,26 @@ + + + + + + + + + + + + + + + + + + +