Monday, 15 July 2013

Liferay Portlet as facebook application



The easy step to configure your portlet as facebook app.

  • Goto facebook create a sample application. for example we create a 'hareshliferay' application.


  • Create a Portlet and drop it on a Portal Page.  
  • Now goto right top corner 'Configuration' menu.
  • Click on 'Sharing' tab, and than click on child tab 'Facebook' , copy and paste API Key from Facebook application.And add canvas page URL and click on 'save'   button. It generate a Callback URL, And Save.


  • Copy the callback URL and specify in facebook application,in Canvas URL under the app on facebook tab, And Save
.


  • Click on 'App Details' Menu.fill mandatory information and save than go for 'Submit App Detail Page' , if successfully done than it's showing approval status as 'Live'. Click on 'Web Preview' , it show a Facebook application page.






  • Now click on 'Go to App'.your Liferay portlet is rendered as facebook app. Simply you can add "Facebook Api" in your portlet to do some facebook specific function.



Tuesday, 9 July 2013

Create your own Portlet Container

Create your own Portlet Container

1. Download portlet-container-configurator.jar from
2. Get fresh Copy of Tomcat6.0

Configuration

Now from the jar you can configure your server to Portlet-containter in two way
  1. Using GUI
  2. From Command Line

1. From GUI

java -jar portlet-container-configurator.jar


  • You can choose container from select menu, select Tomcat6. (you can select GlassFish, Tomcat5, etc ,as shown in screen)
  • Set the Ant Home path
  • Same as Set Container Home Directory for Tomcat
    • C:\Apache-tomcat-6.0.35\
  • Domain Directory
    • C:\Apache-tomcat-6.0.35\webapps

Click on the “Ok” button.


2. From Command Line

java -jar portlet-container-configurator.jar <webcontainer-install-dir> <domain-dir/webapps> <ContainerName> <ANT_HMOE>




<webcontainer-install-dir>
  • location of installed WebContainer, ex: C:\Apache-tomcat-6.0.35\

<domain-dir/webapps>
  • path upto webapps folder, ex: C:\Apache-tomcat-6.0.35\webapps

<ContainerName>
  • container can be one of tomcat, tomcat6, jetty, weblogic. Here in our case it is tomcat6.
java -jar portlet-container-configurator.jar C:\Apache-tomcat-6.0.35 C:\Apache-tomcat-6.0.35\webapps tomcat6 C:\ANT\


Now Goto the WebContainer(tomcat6/bin) and restart/start the server.

Hit the URL in Browser

You can see two tab in portlet container driver. Portles and Admin







From Admin tab User can deploy Portlet as well configure the portles and create a New portlet window.
One can also assing role to portlets.

By Default portlet container store the data in file system, you can configure Database for saving data.

Just change the configuration file 'DriverConfig.properties' located at

C:\apache-tomcat-6.0.35\portlet-container\config\ DriverConfig.properties


The Default configuration is


persistenceType=file


# Specify the properties if the persistence type is database


jdbc.url=jdbc:derby:portletdriver;create=true
jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
jdbc.user=
jdbc.password=
change to

persistenceType=database
# For MySQL
jdbc.url=jdbc:mysql://localhost/portletdriver
jdbc.driver=com.mysql.jdbc.Driver
jdbc.user=root
jdbc.password=root

Wednesday, 26 December 2012

Why need to use ‘serialVersionUID’ in Serializable class



Class SerializeTest , Here we serialize - deserialized the class.


Why need to use ‘serialVersionUID’.


If you doesn’t write serialVersionUID in your class if interface Serializable is implemented than Eclipse tool gives warning

The serializable class SerializeTest does not declare a static final  serialVersionUID field of type long

If you not add SerialVersionUID for you class serialization runtime add Id with associate class.

By java doc

 ‘’ Note - It is strongly recommended that all serializable classes explicitly declare serialVersionUID values, since the default serialVersionUID computation is highly sensitive to class details that may vary depending on compiler implementations, and can thus result in unexpected serialVersionUID conflicts during deserialization, causing deserialization to fail. ‘’



Now you understand why to add serialVersionUID while creating Serializable class for persist.


For Test Create a class to Serialize and then read the same class.



public class SerializeTest implements Serializable{

      private static final long serialVersionUID = 1L;
     
      private int test;
     
      public int getTest() {
            return test;
      }
     
      public void setTest(int test) {
            this.test = test;
      }
}



For Writing a Serializable class

SerializeTest t = new SerializeTest();
t.setTest(10);

try {
      OutputStream file = new FileOutputStream("serializeTest.ser");
      OutputStream buffer = new BufferedOutputStream(file);
      ObjectOutput output = new ObjectOutputStream(buffer);
      try {
            output.writeObject(t);
      } finally {
            output.close();
      }
} catch (IOException ex) {
      ex.printStackTrace();
}



For Reading a Serializable class


try {
InputStream file = new FileInputStream("serializeTest.ser");
      InputStream buffer = new BufferedInputStream(file);
      ObjectInput input = new ObjectInputStream(buffer);
      try {
SerializeTest t = (SerializeTest) input.readObject();
            System.out.println("SerializeTest.test : "+ t.getTest());        

      } finally {
            input.close();
      }
} catch (ClassNotFoundException ex) {
      ex.printStackTrace();
} catch (IOException ex) {
      ex.printStackTrace();
}


Expected Result is
SerializeTest.test : 10

Now, If you change the ‘serialVersionUID’ of class SerializeTest another value like
private static final long serialVersionUID = 2L;


and now try to read the same object using above read code.

You get the below result.

java.io.InvalidClassException: SerializeTest; local class incompatible: stream classdesc serialVersionUID = 1, local class serialVersionUID = 2
     




Wednesday, 19 December 2012

Resolve jQuery Conflicts for diff jQuery Plugins

 
 
jQuery Provide " noConflict " to resolve conflict for different version of jQuery
 
For Example if  you app use ,
 
a plugins that have jquery Version 1.5
 
and another plugins that have jquery Version 1.8
 
Now both you use in same page ,it's create conflicts.
 
you can resolve it by  jQuery Method "noConflict"
 
 
Reference : 
 
1). http://api.jquery.com/jQuery.noConflict/ 

2). http://stackoverflow.com/questions/10978770/how-to-resolve-two-jquery-conflict
 

Thursday, 19 July 2012

html form validation using jquery


Dynamically the whole form can validate by jquery,
Just only add some custom attribute in html tag and call the javascript function,the function validate whole page in one call,you doesn't need to write extra script.
Also the script run for multi level form in html.



* Phone Number  
* Address  
* Password  
* Date  
* Birth Date  
 
* Employee   
* Resume  
* Password  
* Email  
* Sex
Male
Female
  
* Job Type  
* Sepcialization
Java
Php
  

Infinidb _CpNoTf_ problem

infinidb table with a varchar column insert string as a '_CpNoTf_' while using Cpimport. The Problem is occured if inserted string ...