Foros de discusión
Velocity OR operation not stopping when true
Alex Burgazzoli, modificado hace 7 años.
Velocity OR operation not stopping when true
New Member Mensajes: 4 Fecha de incorporación: 6/01/17 Mensajes recientes
Hi, I'm a bit new working with velocity and I'm attempting to create an if/or condition where:
User role is A or B or C = Icon 1 is displayed
User role is D or E or F = Icon 2 is displayed
The problem I am running into is that users can be in multiple roles:
If user role is A & C = Icon 1 is displaying twice rather than just once because it continues through all conditions regardless of it returns true or false
Does anyone have a solution to this? Am I going about this completely wrong?
User role is A or B or C = Icon 1 is displayed
User role is D or E or F = Icon 2 is displayed
The problem I am running into is that users can be in multiple roles:
If user role is A & C = Icon 1 is displaying twice rather than just once because it continues through all conditions regardless of it returns true or false
Does anyone have a solution to this? Am I going about this completely wrong?
#foreach($role in $user.getRoles())
#if( $role.getName().toUpperCase() == "A" || $role.getName().toUpperCase() == "B" || $role.getName().toUpperCase() == "C" )
<<<<<< Icon 1 >>>>>>
#end
#end
#foreach($role in $user.getRoles())
#if( $role.getName().toUpperCase() == "D" || $role.getName().toUpperCase() == "E" || $role.getName().toUpperCase() == "F" )
<<<<<< Icon 2 >>>>>>
#end
#end
Byrån Zaugg, modificado hace 7 años.
RE: Velocity OR operation not stopping when true
Expert Mensajes: 252 Fecha de incorporación: 6/04/12 Mensajes recientes
If you want to stop looping, you can use the #break directive.
See: http://velocity.apache.org/engine/1.7/user-guide.html#foreach-loop
See: http://velocity.apache.org/engine/1.7/user-guide.html#foreach-loop