uPortal 4 portlet, get IPerson attributes in portlet RenderRequest

13 views
Skip to first unread message

Lauren Anderson

unread,
Sep 17, 2020, 6:53:50 PM9/17/20
to uport...@apereo.org

Sorry to bring up the ugly JSR-286 portlet spec, but we’re still using uPortal 4. Do any of you know if it’s possible to get the IPerson attributes when you render the portlet view, and if so, how to do it? I’d like to use them in an API call for the portlet.

 

Some background: the queryAttributeMapping in personDirectoryContext.xml maps some attributes (byuId, personId) for the signed-in user that I’d like to access when I render the portlet, but I don’t know how to get them.

 

Lauren

 

Lauren Anderson

unread,
Sep 17, 2020, 11:48:18 PM9/17/20
to uport...@apereo.org

I figured it out. For anyone who cares to know, the RenderRequest.getAttribute(PortletRequest.USER_INFO) in the portlet controller has a Map of key/value pairs with the extra personal information I need. I just access it like this:

 

 

@RenderMapping

public ModelAndView showMainView(final RenderRequest request, final RenderResponse response) {

 

    /* Get the USER_INFO from portlet.xml, which gets it from personDirectoryContext.xml */

 

    final Map<String, String> userInfo = (Map<String, String>) request.getAttribute(PortletRequest.USER_INFO);

 

    /* Show all key/value pairs in USER_INFO ("javax.portlet.userinfo") */

 

    log.debug("---USER_INFO---");

    for (Map.Entry<String, String> entry : userInfo.entrySet()) {

        log.debug(entry.getKey() + "=" + entry.getValue());

    }

 

    /* Get the byuId from USER_INFO map. */

 

    final String byuId = userInfo.get("byuId");

    log.debug("byuId is " + byuId);

 

    ...lots of other code here...

}

 

 

 

Lauren

--
You received this message because you are subscribed to the Google Groups "uPortal Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to uportal-dev...@apereo.org.
To view this discussion on the web visit https://groups.google.com/a/apereo.org/d/msgid/uportal-dev/82828FA2-3C39-4C8D-A411-D3AE97A58F06%40byu.edu.

Benito Gonzalez

unread,
Sep 18, 2020, 10:40:52 PM9/18/20
to Lauren Anderson, uport...@apereo.org
Awesome!

Thanks for sharing the solution,
Benito

Reply all
Reply to author
Forward
0 new messages