Topic
  • 6 replies
  • Latest Post - ‏2008-11-05T16:33:50Z by mattster
mattster
mattster
31 Posts

Pinned topic P3PUserInfos

‏2008-11-04T16:35:10Z |
In JSR-168, you could use the following code to retrieve user information from a portlet:

Map m = (Map) req.getAttribute(RenderRequest.USER_INFO);
String firstName = (String) m.get("user.name.given");

In JSR-286, an enum called P3PUserInfos was introduced, which provides type safety, such that I can do the following:

Map m = (Map) req.getAttribute(RenderRequest.USER_INFO);
String firstName = (String) m.get(PortletRequest.P3PUserInfos.USER_NAME_GIVEN);

The JSR-168 code works in WPS, but the new JSR-286 code doesn't. Instead, firstName always equals null. Why is this? Is P3PUserInfos not supported by WPS?
Updated on 2008-11-05T16:33:50Z at 2008-11-05T16:33:50Z by mattster
  • jwbarnes
    jwbarnes
    3336 Posts

    Re: P3PUserInfos

    ‏2008-11-04T18:24:07Z  
    no that class is there, is the map populated?


    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0
    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0

    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM
  • mattster
    mattster
    31 Posts

    Re: P3PUserInfos

    ‏2008-11-04T18:33:09Z  
    • jwbarnes
    • ‏2008-11-04T18:24:07Z
    no that class is there, is the map populated?


    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0
    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0

    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM
    The Map appears to be populated, since the old JSR-168 code I listed works.
  • jwbarnes
    jwbarnes
    3336 Posts

    Re: P3PUserInfos

    ‏2008-11-04T20:35:27Z  
    • mattster
    • ‏2008-11-04T18:33:09Z
    The Map appears to be populated, since the old JSR-168 code I listed works.
    I checked into this and it looks like it is not doing the implicit toString()

    String firstName2 = (String) m.get(PortletRequest.P3PUserInfos.USER_NAME_GIVEN.toString()); %>
    This is the first name 2nd way = <%=firstName2 %>
    I did it as above and it works fine


    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0
    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0

    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM
  • mattster
    mattster
    31 Posts

    Re: P3PUserInfos

    ‏2008-11-04T21:57:20Z  
    • jwbarnes
    • ‏2008-11-04T20:35:27Z
    I checked into this and it looks like it is not doing the implicit toString()

    String firstName2 = (String) m.get(PortletRequest.P3PUserInfos.USER_NAME_GIVEN.toString()); %>
    This is the first name 2nd way = <%=firstName2 %>
    I did it as above and it works fine


    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0
    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0

    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM
    Thanks Jim. That worked!

    I hope IBM fixes that, since that was not at all obvious. I debugged the code after your posting; RAD 7.5 seemed to display the P3PUserInfos.USER_NAME_GIVEN constant as a String. It never occurred to me that I had to explicitly convert it to a String.
  • jwbarnes
    jwbarnes
    3336 Posts

    Re: P3PUserInfos

    ‏2008-11-05T16:23:10Z  
    • mattster
    • ‏2008-11-04T21:57:20Z
    Thanks Jim. That worked!

    I hope IBM fixes that, since that was not at all obvious. I debugged the code after your posting; RAD 7.5 seemed to display the P3PUserInfos.USER_NAME_GIVEN constant as a String. It never occurred to me that I had to explicitly convert it to a String.
    I talked with dev on this and it seems this is a errata in the spec and the toString must be called, and this will be pushed in the next errata for the spec

    Jim

    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0
    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0

    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM
  • mattster
    mattster
    31 Posts

    Re: P3PUserInfos

    ‏2008-11-05T16:33:50Z  
    • jwbarnes
    • ‏2008-11-05T16:23:10Z
    I talked with dev on this and it seems this is a errata in the spec and the toString must be called, and this will be pushed in the next errata for the spec

    Jim

    IBM Certified System Administrator -- WebSphere Portal V6.0, V5.1, V5.0
    IBM Certified Solution Developer -- WebSphere Portal V5.1, v6.0

    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM
    Thanks again Jim. That's helpful.