Monday, 24 June 2013

Extending WebSphere Portal Personalization engine using Application Objects

To my understand,

This custom application object works based on user attributes which are accessable through PUMA.
We call this attributes, in java class user defined methods which return boolean.
Based on method return, pages/portlets shows or hide.

Sample Code
-----------
import java.io.Serializable;
import java.util.*;
import com.ibm.websphere.personalization.RequestContext;
import com.ibm.websphere.personalization.applicationObjects.*;

// class name will be used in application object
public class PersonalizationAppObject implements SelfInitializingApplicationObject, Serializable{

--variable declaration--

// for object intialization
public void init(RequestContext context){
--context--
--user--
--Attributes--
}
--setting session-- // to access environment

public boolean getCountry(){ // method name refers as an attribute
        if(--condition--){
            return true;
        }
        return false;
    }
}

Implementation
--------------
1. Get required jar files(pznauthor.jar, pzncommon.jar, pznquery.jar, pznresources.jar, psnruntime.jar) from "\pzn\prereq.pzn\lib" and add jar files to classpath.
2. Create a java class implementing "SelfInitializingApplicationObject".
3. Initialize this object using init() method.
4. Write a user defined method where we access environment using context path.
5. And based on user attribute this method return true/false.
6. Make a jar file of the generated java class file and copy that into "\pzn\prereq.pzn\collections".
7. Restart the portal server.
8. To add the application object to personalization engine.
9. Create new Application Object providing session attribute(same has specified in class) and class name.
10. Now create Visibility Rule for page/portlet.
11. Click on attribute link and select your Application Object.attribute (here attribute is method name specified in class)
12. If attribute returns true, page shows or else hide.

Ref Url : http://www-10.lotus.com/ldd/portalwiki.nsf/dx/Extending_WebSphere_Portal_Personalization_engine_using_Application_Objects

No comments:

Post a Comment