henningn commented on a change in pull request #28: TOBAGO-2021: Sheet should
be able to lazy load rows by scroll events
URL: https://github.com/apache/myfaces-tobago/pull/28#discussion_r387644714
##########
File path:
tobago-theme/tobago-theme-standard/src/main/resources/META-INF/resources/tobago/standard/tobago-bootstrap/_version/js/tobago-sheet.js
##########
@@ -90,24 +93,89 @@ Tobago.Sheet.prototype.reloadWithAction = function(source,
action) {
console.debug("reload sheet with action '" + action + "'"); // @DEV_ONLY
var executeIds = this.id;
var renderIds = this.id;
-// if (this.behaviorCommands && this.behaviorCommands.reload) {
-// if (this.behaviorCommands.reload.execute) {
-// executeIds += " " + behaviorCommands.reload.execute;
-// }
-// if (this.behaviorCommands.reload.render) {
-// renderIds += " " + this.behaviorCommands.reload.render;
-// }
-// }
+ var lazy = jQuery(Tobago.Utils.escapeClientId(this.id)).data("tobago-lazy");
+
jsf.ajax.request(
action,
null,
{
"javax.faces.behavior.event": "reload",
execute: executeIds,
- render: renderIds
+ render: renderIds,
+ onevent: lazy ? Tobago.Sheet.lazyResponse : undefined,
+ onerror: lazy ? Tobago.Sheet.lazyError: undefined
});
};
+Tobago.Sheet.lazyResponse = function(event) {
+ if (event.status === "complete") {
+ var updates = event.responseXML.querySelectorAll("update");
+ for (var i = 0; i < updates.length; i++) {
+ var update = updates[i];
+ var id = update.getAttribute("id");
+ if (id.indexOf(":") > -1) { // is a JSF element id, but not a technical
id from the framework
+ console.debug("[tobago-sheet][complete] Update after jsf.ajax
complete: #" + id); // @DEV_ONLY
+
+ var sheet = document.getElementById(id);
+ sheet.id = id + "::lazy-temporary";
+
+ var page = Tobago.findPage();
+ page.get(0).insertAdjacentHTML("beforeend", "<div id='" + id +
"'></div>");
+ var sheetLoader = document.getElementById(id);
+ }
+ }
+ } else if (event.status === "success") {
Review comment:
formatting code
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services