-
Type:
New Feature
-
Resolution: Done
-
Priority:
Normal
-
Affects Version/s: 10.0.0
-
Component/s: None
-
Security Level: Jimmy
-
None
-
None
User Story
As a developer, I need to use features from UiAgent.getCurrent() during the initial rendering phase of stateless richlet.
Expected uses: Update to existing iComponent tree, mapping actions to existing iComponents, triggering async operation
Acceptance Criteria
Can obtain UiAgent.getCurrent() during richlet initial rendering phase
Details
Uses cases for UiAgent updates during page load: - Can select and modify iComponents generated from a 3rd party class or library example: /* generates iComponents from zul, zul uses the provided IDs for buttons This is easier than mapping the actions in zul Doesn't currently work during richlet "first load", since UiAgent is not available. */ Map argMap = new HashMap<>(); argMap.put("addId", addId); argMap.put("submitId", submitId); Iterable<? extends IAnyGroup> zulCreatedComponents = Immutables.createComponents("~./zul/templates/orderButtons.zul",argMap); IDiv updatedDiv = IDiv.DEFAULT.withChildren(zulCreatedComponents); IButton addBtn = (IButton)ISelectors.findById(updatedDiv, addId); IButton submitBtn = (IButton)ISelectors.findById(updatedDiv, addId); UiAgent.getCurrent().replaceWith(Locator.ofId(addId), addBtn.withAction(this::addItem)); UiAgent.getCurrent().replaceWith(Locator.ofId(submitId), submitBtn.withAction(this::doSubmit)); UiAgent.getCurrent().replaceWith(Locator.of(div), updatedDiv); - Can run async during initial load ex: Clients.log("render page skeleton and display load indicator"); UiAgent.getCurrent().runAsync(u ->{ Clients.log("pull large database stuff after initial load"); data = db.loadStuff(); u.smartUpdate(...) });