Developer forum

Forum » Development » Order of parameters in configurable add-in with base class

Order of parameters in configurable add-in with base class

Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

I have a configurable add-in with a few parameters that serves as a base class. The parameters have AddInParameterOrder attributes with a value from 1 to 5 I then have a few concrete classes that inherit this base class. I applied AddInParameterOrder attributes to their parameters as well, with values like 5, 6 and 7. Yet when the add-in is rendered, I see the child class parameters first (correctly ordered) followed by the base class parameters.

This leads to a messy and confusing UI for the user. Is there a way to sort them across the class hierarchy?

Thanks!


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I just realize the parameters are NOT sorted on AddInParameterOrderl; just on the order in which the appear in the code. The issue with the base and child class remains though,.....

And BTW: I am building StatisticsProviders for Ecommerce.

 
Martin Vang
Martin Vang
Reply

Hi Imar,

The code would be nice, so bear with me if I'm suggesting something silly: Do you have [AddInUseParameterOrdering(true)] on the class?

BR

Martin

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi Martin,

Thanks for your swift reply. I hadn't tried that attribute yet. I just did, but the results are worse now. On one provider I get this:

Base property
Child property
​Base property
Child property

​And on another one I lose one of the properties altogether (??)

Attached you find the code for the base and two child classes. They should show up under Ecommerce | Statistics | Custom. I've compiled them against 9.4.2

Thanks!

 
Martin Vang
Martin Vang
Reply

That was a good little mystery. :)

Solution: If you multiple all your ordering-numbers by 10, things should work.

Explaination:

The ordering uses a semi-cryptic logic, where it does the following:

1. Count the number of properties in the class (config.addin properties)

2. Read the ordering number

3. Use 1+2 as the ordering

This means, that if you do not specify an ordering, the order you write the properties IN THE FILE determines which order the fields are rendered in. So base-class has 1,2,3,4 as "implicit" ordering numbers for each property. Lets look at the inherited class.

Class BaseA {

Property 1

Property 2 

}

Class B extends BaseA{

Property A

Property B

Property 1 <--- Inherited from BaseA

Property 2 <--- Inherited from BaseA

}

So when you set property 1 to have ordering 1, property 2 to 2 and propery A to 3, you get the following

Property a = 3 (ordering number) + 1 (position in file) = 4

property 1 = 1 (ordering number) +3 (position in file) = 4

Multiplying by 10 is an easy fix, as you have less than 10 properties in total.

Property a = 30 (ordering number) + 1 (position in file) = 31

property 1 = 10 (ordering number) +3 (position in file) = 13

Hope this helps and that the explaination makes sense.

BR

Martin

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

It made perfect sense after I did this: https://im-01.gifer.com/Cefy.gif ;-)

Thanks Martin, it's working great now.

Imar

 

You must be logged in to post in the forum