B4J Question [ABMaterial] Which is the fastest to retrive a component?

mindful

Active Member
Licensed User
Is there any difference regarding performance between ABMContainer.Component("comp_id") and ABMContainer.ComponentRowCell(1, 1, "comp_id").

Basically my question is: Is it better to use ComponentRowCell if our row position and cell position which contain the component do not change ?
 

Harris

Expert
Licensed User
Longtime User
Is there any difference regarding performance between ABMContainer.Component("comp_id") and ABMContainer.ComponentRowCell(1, 1, "comp_id").

Basically my question is: Is it better to use ComponentRowCell if our row position and cell position which contain the component do not change ?
Never knew ComponentRowCell existed?

Seems to me you are referring the the same ID, regardless of where it exists - so long as it is a valid component ID (main page, input form or other).
 
Upvote 0

mindful

Active Member
Licensed User
Seems to me you are referring the the same ID, regardless of where it exists - so long as it is a valid component ID (main page, input form or other).
Yes but I was wondering if I use ComponentRowCell will the retrive action be faster.
I am thinking that maybe Container.Component goes through all the rows and cells in its grid until it finds the component id where Container.ComponentRowCell goes directly to a row and cell and retrives the component - therefore in some cases (a lot of rows, cells and components in a container) ComponentRowCell should be a faster way of retrieving a component.

But if @alwaysbusy coded ABMaterial to keep a 'map' of all components inside a container and retrives the component directly from the map using it's component id it will not make any major difference regarding the speed and performance.
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
Will indeed not make a big difference and probably be even slower. It is more like a leftover from an experiment (should be cleaned when I find the time). In B4J you simply use logic numeric values for the row and cell (e.g. Cell(1,2)), but internally they can be quite complex IDs (holding parents, arrays, etc) because in the HTML they need to be unique.

The container holds a map with the complex row and cell each component is located in.

e.g. key: compA, value: a pair object with Row = complexRowID, Cell = complexCellID

So if you do Component("compA"):
1. it get the pair object for compA first
2. gets the real row using complexRowID
3. get the real cell using complexCellID
4. gets the component

if you do ComponentRowCell(y,x):
1. build the complexRowID/complexCellID
2. gets the real row using complexRowID
3. get the real cell using complexCellID
4. gets the component

I always use the Component() method.
 
Upvote 0

mindful

Active Member
Licensed User
but internally they can be quite complex IDs (holding parents, arrays, etc) because in the HTML they need to be unique.
Regarding the unique id's in html if I have:
Container1 with id "cont1"
Container2 with id "cont2"
Located in the same row and cell on a page or in another container and each container has a label in it, do the 2 labels need to have different id's even if they have different parents which have different id ?

Something like:
cont1 has labelname
cont2 has labelname
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
you don't have to use different label names, ABMaterial takes care of this.

e.g. in you example

in the html the real ids for the labelname can be (this is just to explain it, names can be something different):
cont1labelname
cont2labelname

however, you can just keep using:
cont1.component("labelname")
cont2.component("labelname")

Once containers get nested, or added as an array component, names can be complex (in the html), while you can still use the 'simple' names.
 
Upvote 0

mindful

Active Member
Licensed User
Once containers get nested, or added as an array component, names can be complex (in the html), while you can still use the 'simple' names.
This is what I was hoping for, because when I nested components I created the Id something like ParentId & ComponentId ... And If I have 5 levels the html id and b4j id are very very long ..

So now I need to do some cleaning :))
 
Upvote 0
Top