Friday, 21 March 2014

Create CQ5 project using maven Command prompt

maven Archetype for the CQ5 project is multimodule-content-package-archetype

 cmd> mvn archetype:generate
 -DarchetypeRepository=http://repo.adobe.com/nexus/content/groups/public/
 -DarchetypeGroupId=com.day.jcr.vault
 -DarchetypeArtifactId=multimodule-content-package-archetype
 -DarchetypeVersion=1.0.2
 -DgroupId=my-group-id
 -DartifactId=myproject
 -Dversion=1.0-SNAPSHOT
 -Dpackage=com.mycompany.myproject
 -DappsFolderName=myproject
 -DartifactName="My Project"
 -DcqVersion="5.6.1"
 -DpackageGroup="My Company"

 (before execute the command, verify did you install maven into your system).
 It ask the conformation for create the project. Press y

Thursday, 6 March 2014

Table creation using css (display:table) property

<html><head>
    <style type="text/css">
        body {
            font-family:verdana;
            font-size:12px;
margin: 0;
        }
     
        .parent_new {
            border:1px solid red;
            width:100%;          
            display: table;
border: none;
text-align: center;

        }
        .row_level
        {
            display:table-row;
        }
        .cell-level {
            display:table-cell;
         
vertical-align:middle;
padding: 10px;
        }
       .left{
   border-right:1px solid red;
border-bottom:1px solid red;
  }
  .right{
   border-left:1px solid red;
border-bottom:1px solid red;
  }
        .clr { clear:both; }
       
.colsspan{
position:absolute;
left:0px;
right:0px;
border:1px solid red;

}
    </style>
</head>
<body>
    <div class="parent_new">
        <div class="row_level">
        <div class="cell-level left">float left div here only static content
        </div>
        <div class="cell-level right">
            float right div dynamic content here<br>
            float right div dynamic content here<br>
            float right div dynamic content here<br>
            float right div dynamic content here<br>
            float right div dynamic content here<br>
            float right div dynamic content here<br>
            float right div dynamic content here<br>
            float right div dynamic content here<br>
         </div>
        </div>
       <div class="row_level">
        <div class="cell-level colsspan">float left div here only static content
        </div>
     
        </div>
        <div class="clr"></div>
       
    </div>

</body></html>


Thursday, 16 January 2014

How to get the vanity url to absolute path in CQ5?


  1. Open http://localhost:4502/system/console default username,password is admin/admin
  2. Select the Sling Resource Resolver tab
  3. Give your vanity path into the text field and click resolve.
  4. If the path is valid it print the path and type and it's super resource type



Friday, 20 December 2013

Configure the CQ5 local instance as a repository for maven

1. Pom.xml
<repositories>
        <repository>
            <id>localinstance</id>
            <name>CQ 5.5 localinstance</name>
            <url>http://localhost:4502/maven/repository</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
 </repositories>

2. Settings.xml
Settings.xml is under  C:\Users\username\.m2

<servers>
  <server>
      <id>localinstance</id>
      <username>admin</username>
      <password>admin</password>
</server>
  </servers>


3. Download and Install the package in CQ5


Tuesday, 12 November 2013

Some Useful Data structure interview questions

Remove the leave Node

struct Node * romoveLeafList(struct Node * root){
    if(root==NULL) return NULL;
    if(root->left==NULL && root->right==NULL){
        return NULL;
    }
    root->left=romoveLeafList(root->left);
    root->right=romoveLeafList(root->right);
    return root;
 
}


Remove all the Node which has sum is less than k 

struct Node * sumofnode(struct Node *root, int k, int *sum)
{
    if(root==NULL)return NULL;
    int leftsum=*sum+root->data;
    int rightsum=leftsum;
    root->left=sumofnode(root->left,k,&leftsum);
    root->right=sumofnode(root->right,k,&rightsum);
    *sum=leftsum>rightsum?leftsum:rightsum;
    if(*sum<k)
    return NULL;
    return root;
}

Wednesday, 6 November 2013

Compile and Run java program using another java program (Java Reflection)

CompileRun.java
import java.io.*;
import java.lang.reflect.*;
public class CompileRun
{
 public static void main(String arg[])throws Exception
 {
  System.out.println(“Helo”);
  new com.sun.tools.javac.Main().compile(new String[]
{“HelloWorld.java”});
  Class c=Class.forName(“HelloWorld”);
  Object o=c.newInstance();
  Object ar[]=new Object[]{};
  Class cl[]=new Class[]{};
  Method m=c.getDeclaredMethod(“print”,cl);
  m.invoke(o,ar);
 
 
 }
}

HelloWorld.java 
public class HelloWorld
{
 public void print()
 {
  System.out.println(“Hello World”);
 }
}
Classpath
1)  %classpath%;Q:\SDE7_Tomcat6_JDK6\Java\jdk1.6.0_24\lib\*
2) javac CompileRun.java
3) java -cp “Q:\SDE7_Tomcat6_JDK6\Java\jdk1.6.0_24\lib\*;.” CompileRun

Tuesday, 5 November 2013

Ajax call & json object creation from the response using CQ5

javascript

var response = CQ.utils.HTTP.get("resourcepath.selector.json");
if (CQ.HTTP.isOk(response)){ 
var myObject =CQ.HTTP.eval(response);
alert(myObject.name);
}

selector.json.jsp
{"name":"vimal"}