Skip to content

Commit

Permalink
feat(sheet): Invoke renderResponse when decode lazyUpdate to render R…
Browse files Browse the repository at this point in the history
…esponse immediate

issue: TOBAGO-2371

(cherry picked from commit 1b71c70)
  • Loading branch information
bohmber committed Dec 5, 2024
1 parent 5d535fe commit 945e864
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@
<ui:composition template="/main.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:tc="http://myfaces.apache.org/tobago/component"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:f="http://xmlns.jcp.org/jsf/core">
<ui:param name="title" value="Lazy Loading Large Data"/>

<tc:sheet value="#{sheetController.hugeSolarList}" id="sheet" var="luminary"
rows="20" markup="small" lazy="true"
lazyRows="20" markup="small" lazy="true" readonlyRows="true"
showRowRange="none" showDirectLinks="none" showPageRange="none">
<tc:style maxHeight="500px"/>
<tc:column label="Name">
<tc:column label="Name" sortable="true">
<tc:out value="#{luminary.name}" labelLayout="skip"/>
</tc:column>
<tc:column label="Orbit">
Expand All @@ -41,5 +43,26 @@
<tc:column label="Year">
<tc:out value="#{luminary.discoverYear}" labelLayout="skip"/>
</tc:column>
<tc:row id="sample0">
<f:ajax render=":page:mainForm:detail" execute="sheet" listener="#{sheetController.selectSolarObject}" id="columnEventAjax"/>
</tc:row>
<!--tc:column label="Action">
<tc:button label="Button" actionListener="#{sheetController.selectSolarObject}"/>
</tc:column-->
</tc:sheet>


<tc:box id="detail" label="Details" >
<tc:panel rendered="#{sheetController.selectedSolarObject != null}">
<tc:in id="name" label="Name" value="#{sheetController.selectedSolarObject.name}" readonly="true"/>
<tc:in label="Number" value="#{sheetController.selectedSolarObject.number}" readonly="true"/>
<tc:in label="Orbit" value="#{sheetController.selectedSolarObject.orbit}" readonly="true"/>
<tc:in label="Distance" value="#{sheetController.selectedSolarObject.distance}" readonly="true"/>
<tc:in label="Period" value="#{sheetController.selectedSolarObject.period}" readonly="true"/>
<tc:in label="Obliquity" value="#{sheetController.selectedSolarObject.incl}" readonly="true"/>
<tc:in label="Eccentricity" value="#{sheetController.selectedSolarObject.eccen}" readonly="true"/>
<tc:in label="Discoverer" value="#{sheetController.selectedSolarObject.discoverer}" readonly="true"/>
<tc:in label="Discover Year" value="#{sheetController.selectedSolarObject.discoverYear}" readonly="true"/>
</tc:panel>
</tc:box>
</ui:composition>

0 comments on commit 945e864

Please sign in to comment.