B4J Question [BANano] [SOLVED] How to achieve re-usable Abstract Designer Layouts?

Mashiane

Expert
Licensed User
Longtime User
Ola

With SPA (Single Page Applications), each element needs to have a unique identifier. The addition of the AutoID property adds the benefit of re-usable layouts as the identifier for each element is automatically generated. Thanks again Alain for that.

My question though is around the use of creating various layout blocks that you can use (not only for listviews) across the app. For example, you want to create DialogBox component via the abstract designer which you can use on pageA, pageC and pageD but it should have unique identifiers can you want to later relate to.

Lets assume you have an abstract designer layout like this.

<v-tooltip>
<v-badge>
<v-btn>
<v-icon></v-icon>
</v-btn>
</v-badge>
<v-tooltip>

You want to create this layout hopefully once and then use it across your pages. Lets call the layout name TooltipBadgeButtonIcon. With the AutoID turned on, each element within this structure will receive a unique id.

To change an attribute for the v-icon via code for example, you need to execute BANano.GetElement(?) However the generated ID is unique and you don't know it.

So each page that needs the TooltipBadgeButtonIcon abstract designer layout, one can just use the BANano.LoadLayout call and load it, either wanting to append it to some already existing layout or add a new one.

I was thinking of LoadLayoutArray as that at least each id you specify can be unique and the other "children" will receive xxx_2, xxx_3, this however means that where one needs to access each id, they have to know it before hand and how does one keep track of the many identifier names that will be available when layouts are loaded multiple times for different pages to achieve different things.

So what is the best approach? or rather just create these as custom views and at least that ensures you can use loadlayout and get unique identifiers that one might need.

For example, if I have 20 pages that will use a layout, with this structure as part of it. If I have not defined this structure as a custom view...

<v-tooltip>
<v-badge>
<v-btn>
<v-icon></v-icon>
</v-btn>
</v-badge>
<v-tooltip>

I need to create 20 such structures and because I need unique id names as I might need to access these, assign events to them etc.

#Thoughts..
 
Top