Foren
Velocity OR operation not stopping when true
Alex Burgazzoli, geändert vor 7 Jahren.
Velocity OR operation not stopping when true
New Member Beiträge: 4 Beitrittsdatum: 06.01.17 Neueste Beiträge
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, geändert vor 7 Jahren.
RE: Velocity OR operation not stopping when true
Expert Beiträge: 252 Beitrittsdatum: 06.04.12 Neueste Beiträge
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