Case (if then else) in a display tag text

Hi All

I’d like to be able to that, but it does not work. Am I doing something wrong or is it not supported (yet)?

%%numberOfPersonsRoles%% %%numberOfPersonsRoles > 1 ? i18n.getI18NMessage(‘hades.bas.lbl.roles’) : i18n.getI18NMessage(‘hades.bas.lbl.role’)%%

Regards,

nope, isn’t supported
you can use a calculation to do this.
Then do %%myCalc%%

The calc is exactly what I want to avoid, hence the requirement to do it like my proposal.

mboegem:
nope, isn’t supported
you can use a calculation to do this.
Then do %%myCalc%%

Or just use method

Can you elaborate a bit more please? I don’t know what you mean, method call within display tag?

Harjo:
Or just use method

Hi Robert,

You can use a method to set the text property of the label (it doesn’t even have to have a dataprovider).
Of course you want to do this the moment any of the display data changes like on a onRecordSelection.

Hope this helps.

Indeed, what Robert explains, is exactly what I mean,

but why wouldn’t you use a calculation?
Servoy never allowed any calculation inside a display tag.
But let’s assume Servoy implements this, than they have to use the same technique as the calculations does.

And I believe this is the perfect example of doing this inside a calculation.
I assume %%numberOfPersonsRoles% is already a calculation or aggregate, so this will be cashed!
Yes the calculation will fire a lot, but this example does not give any roundtrips to the server, or new queries!

When using related data, than you have to be careful using calculation, or you have to know the impact, what you are doing!

Harjo:
so this will be cashed!

how much money? :-)

Thanks all of you, yeahhh, lot of cash, ohhh, quite a pleasure :-)

The reason I am careful with calcs is that we have already a lot of needed calcs in the application and they don’t make it faster ;-)

@Robert: Thanks for the hint, yes, that’s also a possibility. Although I still think my proposal would be the most elegant (with the least overhead)

@Harjo: Yes, numberOfPersonsRoles is an aggregate. I don’t think Servoy would need an additional calc, as my example with the short form of if then else also only needs the aggregate numberOfPersonsRoles (which exists already). And, as an advantage, the code would be well readable at the “right” place :-)

You guys see it differently?

mboegem:

Harjo:
so this will be cashed!

how much money? :-)

Haha, my spellingchecker did accept that :-)

Calculations belong to calculations or methods Not inside tags