cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing objects in IPortalComponentProfile in a bean

former_member81750
Active Participant
0 Kudos

Hello Everyone

Is it possible to access to the objects in IPortalComponentProfile inside a bean. For example let's say I create a java.sql.Connection object in the doInitialization() method of a class created using JSPDynPage wizard of EP SP5 PDK. I store it in the profile object. Then I want to access it from a bean.

Regards

Pankaj

Accepted Solutions (0)

Answers (1)

Answers (1)

Oliver5
Advisor
Advisor
0 Kudos

Yes it is possible.

You can access every profile of Portal Component.

You have to tell the bean, the name of the Portal Compont on which you want to access the Profile.

But take care of user specific attributes. just try it out.

Oliver

former_member81750
Active Participant
0 Kudos

Oliver,

Thanks for the reply. I am able to access profile from any component using the code because I have access to request in the component

IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();

IPortalComponentContext context = request.getComponentContext();

IPortalComponentProfile profile = context.getProfile();

But I don't have the request object inside a bean. So again I am not sure how would I access the profile.

Regards

Pankaj

former_member81750
Active Participant
0 Kudos

Anyone has answer to this, please

Pankaj

Former Member
0 Kudos

The easiest way is probably to look a bit more on your "architecture".

The bean will normally just be a data container, and it should be the responsibility of the bean-creator class to fill in the data in the bean (since it has access to the request).

The bean should not have a reference to the request as the request is only valid for a limited amount of time, while a bean stored in the profile could potenially exist for a long time.

former_member81750
Active Participant
0 Kudos

Thanks Dagfinn for the insight. I did a bit of rethinking and changed the code so that bean doesn't actually need reference to request->context->profile etc.

I have created a bean for HTMLB table with a DefaultTableViewModel as its model. Initially I looked at the example code from PDK. For simplicity reasons they populated the table model inside the bean.Laze me just extended the example and tried to do the same. Then I wanted to open the DB connection only once in the life cycle of my component. So I saved the connection in profile and wanted to access it from bean. But now in my present code I am setting the table bean model from DynPageComponent itself and there I do have access to the saved db connection.

Cheers

Pankaj

former_member81750
Active Participant
0 Kudos

Thanks Dagfinn for the insight. I did a bit of rethinking and changed the code so that bean doesn't actually need reference to request->context->profile etc.

I have created a bean for HTMLB table with a DefaultTableViewModel as its model. Initially I looked at the example code from PDK. For simplicity reasons they populated the table model inside the bean.Lazy me just extended the example and tried to do the same. Then I wanted to open the DB connection only once in the life cycle of my component. So I saved the connection in profile and wanted to access it from bean. But now in my present code I am setting the table bean model from DynPageComponent itself and there I do have access to the saved db connection.

Cheers

Pankaj