This is an automated email from the ASF dual-hosted git repository.

harbs pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/royale-docs.git


The following commit(s) were added to refs/heads/master by this push:
     new 048ae84  added info about accessing beads
048ae84 is described below

commit 048ae84031d5c2da33dfb8ccf1610ce403308a99
Author: Harbs <[email protected]>
AuthorDate: Mon Jan 3 13:31:23 2022 +0200

    added info about accessing beads
---
 features/strands-and-beads.md | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/features/strands-and-beads.md b/features/strands-and-beads.md
index 3253a3e..07b9abc 100644
--- a/features/strands-and-beads.md
+++ b/features/strands-and-beads.md
@@ -115,6 +115,15 @@ alertView.content.addBead(verticalLayout);
 ```
 See a full example of the code above in the [Customization through the Royale 
API](https://royale.apache.org/customization-through-the-royale-api/){:target='_blank'}
 example.
 
+### Accessing a bead from a strand
+There are many cases where you need to find a specific bead without 
necessarily knowing the implementation. The two most common cases are accessing 
a strand's view and model.
+
+For these two cases, any class which implements `IStrandWithModelAndView` or 
inherits from `UIBase` (which is pretty much every visual component) has direct 
access to the `view` and `model` getters on the strand. These getters should 
always be used for views and models. 
+
+Sometimes, a component might have more than one model and you might not be 
sure if the one you want is the main one. In that case you should use the 
`getModelByType(strand,classOrInterface)` function in the 
`org.apache.royale.html.util` package. It will find the correct bead in the 
most efficient way it can.
+
+For other bead types, you can use `strand.getBeadByType(classOrInterface)`. It 
will find the bead you need from the beads which belong to the strand. You can 
use this for views although it's less efficient than accessing the view 
directly. You _should not_ use this for models because models are only loaded 
the first time they are accessed and if you use 
`strand.getBeadByType(IBeadModel)` you will get null if the model has not yet 
been accessed.
+
 ## Creating a bead
 
 The following piece of code shows the most basic bead structure to use when 
you create a bead:

Reply via email to