Label expression with condition [message #1695825] |
Tue, 19 May 2015 10:30  |
Eclipse User |
|
|
|
Hello,
In a column, I would like to change the column label according to the eobject features: if there is a string, I want to show something, otherwise, show a generic label. So, I was looking for putting a "if" condition in the label expression. Unfortunately, my expression is not interpreted and my code is pasted in the column.
The condition I put is the following:
[ if (self.goalReference->isEmpty()) ]
no reference
[else]
[self.goalReference.name]
[/if]
This condition/code works using the interpreter. But when I put it in the coilumn expression, it does not work
Any idea how to do that?
Thanks.
|
|
|
Re: Label expression with condition [message #1695842 is a reply to message #1695825] |
Tue, 19 May 2015 13:19   |
Eclipse User |
|
|
|
Hello,
It seems weird that this expression works in the interpreter as an
acceleo expression should be surrounded by [ /]. Anyway, Acceleo
provides the service "if" and should be used in a single expression as
follows:
[if(self.goalReference->isEmpty()) then '' else self.goalReference.name
endif/]
Note that if goalReference is a multivalued reference (as you use the
operation ->isEmpty) "self.goalReference.name" will return the
concatenation of the name of each referenced elements.
Regards,
Steve
Le 19/05/2015 16:30, Julien Delange a écrit :
> Hello,
>
> In a column, I would like to change the column label according to the
> eobject features: if there is a string, I want to show something,
> otherwise, show a generic label. So, I was looking for putting a "if"
> condition in the label expression. Unfortunately, my expression is not
> interpreted and my code is pasted in the column.
>
> The condition I put is the following:
> [ if (self.goalReference->isEmpty()) ]
> no reference
> [else]
> [self.goalReference.name]
> [/if]
>
> This condition/code works using the interpreter. But when I put it in
> the coilumn expression, it does not work
>
> Any idea how to do that?
>
> Thanks.
--
Steve Monnier - Obeo
Need professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05524 seconds