Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Accessing Personalization custom application object from a portlet

241 views
Skip to first unread message

just...@axa-equitable.com

unread,
Nov 25, 2008, 2:49:07 PM11/25/08
to
Is there a way to access a Pzn Application Object from within a custom portlet through some API? I was able to implement a custom Application Object and deployed it successfully. Visibility rules are working as expected using the application object, but the issue is if I wanted to update or change some attributes inside my application object from my portlet code, how exactly do I get a handle on it?

From what I understand, the Pzn Engine runs in the /wps context and most likely stores the application object on init in the HttpSession in that context. Therefore, since my deployed portlet is its own web application, it will have its own context (ie. /wps/PA_fubar). So is there any way to programmatically access the Pzn Engine context and affect objects during runtime?

Thanks for any insight anyone may have.

Dennis te Lintelo

unread,
Nov 26, 2008, 5:48:15 AM11/26/08
to
Just as PZN can get to the application object, also your portlet can.

Attached you will find a simple example of an application object, and below the code you can use in your portlet.

MySelectionBean bean = new MySelectionBean();
bean.setValue("some value");

Have Fun!!

Dennis te Lintelo

unread,
Nov 26, 2008, 5:50:17 AM11/26/08
to
Ok, attachements don't work....here is the code of the application object...

package beans;

import com.ibm.websphere.personalization.RequestContext;
import com.ibm.websphere.personalization.applicationObjects.SelfInitializingApplicationObject;
import java.io.Serializable;

public class MySelectionBean implements SelfInitializingApplicationObject,Serializable {

private static final long serialVersionUID = -8133816174182658933L;

public void init(RequestContext rc) {
rc.setSessionAttribute("MySelectionBean", this );

}

public MySelectionBean() {
}

public String getInsuranceType() {
return SessionData.getInsuranceType();
}

public void setInsuranceType(String insuranceType) {
SessionData.setInsuranceType(insuranceType);
}

private static class SessionData {
private static SessionData sessionData;
private static String insuranceType;

public static String getInsuranceType() {
return insuranceType;
}

public static void setInsuranceType(String insuranceType) {
SessionData.insuranceType = insuranceType;
}
private SessionData() {
insuranceType="";
}
public SessionData getInstance() {
if (sessionData==null) {
sessionData=new SessionData();
}
return sessionData;
}

}
}

Have Fun!

just...@axa-equitable.com

unread,
Nov 26, 2008, 8:59:59 AM11/26/08
to
Thanks for your reply Dennis. I had a question about the above code. Because you're storing the SessionData as a static variable of the MyBean class, won't there only be one SessionData object for all of your users?

Dennis te Lintelo

unread,
Nov 26, 2008, 9:29:37 AM11/26/08
to
To my understanding it is for the current user. So there is one SessionData object for each user.

piyush...@gmail.com

unread,
Dec 12, 2008, 5:56:03 AM12/12/08
to
Hey how to set this application object as a business rule.
when i am trying to set it, i get an error : EJPVP99999E: The
application object class 'MySelectionBean' could not be located.
Specify a valid class for this application object. What values do we
need to provide under Class Name and Session Key. Please help...
Thanks in advance.
0 new messages