Created
February 9, 2016 20:24
-
-
Save yupadhyay/da0bc42a931278c81577 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Initialize a variable | |
<sly data-sly-test.pagePath="${currentPage.path}"/> | |
<sly data-sly-test.someString='test'/> | |
<sly data-sly-use.SomeOtherObject="${'TopNavHelperUse' @ test='test'}"> | |
<sly class="sightly-topnav" data-sly-use.topnav="${'Topnav' @ pageNumber='5', someString=someString, pageObject=currentPage, helperString=SomeOtherObject.test}"/> | |
${topnav.totalPage} ${topnav.someOtherString} ${topnav.pagePath} ${topnav.helperTest} | |
#Here is Output | |
15 test and test2 /sometestPath testtest5 | |
#Here is Java Class Example | |
import com.adobe.cq.sightly.WCMUse; | |
import java.util.HashMap; | |
import java.util.Iterator; | |
import java.util.LinkedList; | |
import java.util.List; | |
import java.util.Map; | |
import com.day.cq.commons.Filter; | |
import com.day.cq.wcm.api.Page; | |
import com.day.cq.wcm.api.PageFilter; | |
public class Topnav extends WCMUse { | |
public int getTotalPage(){ | |
return Integer.parseInt(get("pageNumber",String.class))+10; | |
} | |
public String getSomeOtherString(){ | |
return get("someString",String.class)+" and test2"; | |
} | |
public String getPagePath(){ | |
return get("pageObject",Page.class).getPath(); | |
} | |
public String getHelperTest(){ | |
return get("helperString",String.class) + "test5"; | |
} | |
} | |
#Other Class | |
public class TopNavHelperUse extends WCMUse { | |
public String getTest(){ | |
return get("test",String.class); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment