Hi All,
In sightly file, I have a set of conditions as below, based on which certain processing happens :
1]<div class="item " data-sly-test="${condition2 || condition1 || condition3}">
2]<div class="item " data-sly-test="${condition2 || condition3}">
3]<div class="item " data-sly-test="${condition1}">
Condition #1 is occuring 3 times, Condition #2 : 2 times and Condition #3 : 1 time.
a] Can someone please let me know what exactly does these conditions imply. Explanation on this will be helpful.
b] If I have to re-create the same thing in Java, how would I do that.
Any thoughts/pointers on this will be helpful.
Solved! Go to Solution.
I don't know that I really understand what you'e asking for, but here's an attempt to answer for you:
These would be the same as writing the following in Java. They're simply OR statements - if any of your conditions are true/not null/not empty, then the element will be rendered.
if (condition1 || condition2 || condition3) { //Do Something } if (condition2 || condition3) { //Do Something } if (condition1) { //Do Something }
If that doesn't answer for you, could you maybe try to ask the question a little more specifically?
Views
Replies
Total Likes
I don't know that I really understand what you'e asking for, but here's an attempt to answer for you:
These would be the same as writing the following in Java. They're simply OR statements - if any of your conditions are true/not null/not empty, then the element will be rendered.
if (condition1 || condition2 || condition3) { //Do Something } if (condition2 || condition3) { //Do Something } if (condition1) { //Do Something }
If that doesn't answer for you, could you maybe try to ask the question a little more specifically?
Views
Replies
Total Likes
Hi Leeasling,
Thank you for your reply.
In case, condition1 is true in the first and third if statement, then processing statements mentioned in both the if conditions will be run?
Views
Replies
Total Likes
They are separate condition expressions - as Lee pointed out. So:
if (condition1 || condition2 || condition3) {
//Do Something
}
if (condition2 || condition3) {
//Do Something
}
if (condition1) {
//Do Something
}
Each condition is a OR - not an AND. Therefore if condition 2 is true - then the 1 and 2 expression is executed.
Views
Replies
Total Likes
Right, with the way you currently have it configured, #1 and #3 would be output if condition1 is true.
Hi
As mentioned by Lee and Scott, they are 3 conditional statements.
if (condition1 || condition2 || condition3) {
//Do Something 1
}
if (condition2 || condition3) {
//Do Something 2
}
if (condition1) {
//Do Something 3
}
Case 1 :- Let condition1 = true, condition2 = False and condition3 - false.
So here "Do Something 1" and "Do Something 3" will be rendered.
Case 2 :- Let condition1 = false, condition2 = true and condition3 - false.
So here "Do Something 1" and"Do Something 2" will be rendered.
Note :- || is or operator, so any of the statement is if true then it will be true. i.e. 1 OR 0 OR 0 Or 0 Or 0..... = 1
Reference Link :- http://blogs.adobe.com/experiencedelivers/experience-management/sightly-intro-part-1/ (Sightly introduction)
I hope this will clear your doubt.
Thanks and Regards
Kautuk Sahni
Hi Kautuk,
Thank you for your reply.
One Doubt.
In "Case:2" that you have mentioned[i.e, condition1 = false, condition2 = true and condition3 - false],.
a] Will not "Do Something 2" and "Do Something 1" be executed?[because condition2 is satisfied in the first and second "if" condition]
Views
Replies
Total Likes
askdctm wrote...
Hi Kautuk,
Thank you for your reply.
One Doubt.
In "Case:2" that you have mentioned[i.e, condition1 = false, condition2 = true and condition3 - false],.
a] Will not "Do Something 2" and "Do Something 1" be executed?[because condition2 is satisfied in the first and second "if" condition]
Hi,
you are correct, i missed it.
I have edited that answer. Please check and verify it.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Hi Leeasling/Scott/Kautuk,
Thank you for your answers. It helped.
Views
Replies
Total Likes