cancel
Showing results for 
Search instead for 
Did you mean: 

Iterating true an Enumeration

Former Member
0 Kudos
74

Hey people!

Im using the method getProperties() in my AbstractPortalComponent. This method returns an enumeration of the properties name. When im iterating true the Enumeration, i get so much extra values out from the loop.

public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)

{

IPortalComponentContext context = request.getComponentContext();

IPortalComponentProfile profile = context.getProfile();

Enumeration e = (Enumeration) profile.getProperties();

while(e.hasMoreElements()) {

String name = profile.getProperty(e.nextElement()

.toString());

response.write(name);

}

}

Am I missing a casting or something? When im running it in the portal in a view, i get the whole pcd url, information about the broswer, pixels, the time and so on.

Accepted Solutions (1)

Accepted Solutions (1)

former_member182372
Active Contributor
0 Kudos

Hi Kristoffer,

To "filter" your own custom properties I would suggest you to use some prefixes in property names, like "MY_OWN_PROPERTY_1".

Than it can looks like:


public void doContent(IPortalComponentRequest request, IPortalComponentResponse response)
{
  IPortalComponentContext context = request.getComponentContext();
  IPortalComponentProfile profile = context.getProfile(); 

  Enumeration e = profile.getProperties();

  while(e.hasMoreElements()) {
    String nameOfProperty = e.nextElement().toString();
    if(nameOfProperty.startsWith("MY_OWN_PROPERTY")) {
      String name = profile.getProperty( nameOfProperty ); 
      response.write(name); 
    }
  }
}

Best regards, Maksim Rashchynski.

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

You can try this to get property name and value...

IPortalComponentContext context = request.getComponentContext();

IPortalComponentProfile profile = context.getProfile();

Enumeration e = (Enumeration) profile.getProperties();

while(e.hasMoreElements()) {

IProperty ip = (IProperty)e.nextElement();

String name = ip.getName();

String value = ip.getValue();

response.write("Name:"name"Value:"+value);

}

Hope this helps.

Regards,

Uma

Former Member
0 Kudos

Thanx for your answere.

I have tried to cast is as a property, but there is no such type. Not IProperty or Property.

getProperty is just a method in the IPortalComponentProfile..

former_member182372
Active Contributor
0 Kudos

It returns an Enumeration of the properties name not any IProperty or Property.