Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Problem with portlet support...

  1. #1
    Join Date
    Sep 2004
    Posts
    346

    Default Problem with portlet support...

    User attribute are retreived in portlets by the following command:

    Code:
    Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO);
    Because webflow copies the request attributes into the request rather than using the PortletRequest directly there is a problem (at least with jetspeed2)

    The problem is that when above command is executed it executes special code. There is no actual request attribute in the request.

    So a workaround needs to be found for this.

    perhaps a method on requestContext that will determine if the actual request is a portlet and call the getAttribute on that instead. Maybe there it a completely better way of course...

    I created JIRA

    http://opensource.atlassian.com/proj...rowse/SPR-1030

  2. #2
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    You can do this by getting the actual PortletRequest in your action:

    Code:
    RequestContext context = ...
    PortletRequest request = ((PortletEvent)context.getSourceEvent()).getRequest();
    Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO);
    If you want to keep your action code independent of the Portlet API, you could do something similar in a FlowExecutionListener.

    Erwin

  3. #3
    Join Date
    Sep 2004
    Posts
    346

    Default Seems unintuitive....

    Seems unintuitive.... since every other request param is done in a different way however please provide an example on how to do this with FlowExecutionListener and describe how it keeps this stuff separate from my code..

  4. #4
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    Doing it in a listener makes it more pluggable. If you want to reuse your flow in a servlet and portlet environment, you can plug in the correct listener in each case and the flow itself remains protocol independent.

    A listener could e.g. do it in the "requestSubmitted" hook:

    Code:
    public void requestSubmitted(RequestContext context) {
       if (!context.getFlowContext().isActive()) return;
       PortletRequest request = ((PortletEvent)context.getSourceEvent()).getRequest(); 
       Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO); 
       context.getFlowScope().setAttribute("userInfo", userInfo);
    }
    Erwin

  5. #5
    Join Date
    Sep 2004
    Posts
    346

    Default Wouldn't it be more intuitive to check req for instanceof

    Wouldn't it be more intuitive to check req for instanceof in the case of that attribute and do that automatically since in general that is how that attribute will be used?

    I don't see how listener accomplishes anything interesting since I could do the same by chaining together actions... It still means however that my code is portlet specific which is the general idea of what this framework was trying to avoid (and I might add, has done a good job so far)

  6. #6
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    The main benefit of the listener is pluggability. E.g. you could take it out and reuse the flow in a servlet situation without any changes to the actual flow definition and actions.

    Erwin

  7. #7
    Join Date
    Sep 2004
    Posts
    346

    Default Ok... I see what you mean...

    Ok... I see what you mean... however I still think it's unintuitive and the jetspeed2 guys also think so but if you want to go this way I guess we'll have to live with it. :-(

    Otherwise you guys are doing great work so hopefully we can agree on this point to disagree.. :-)

  8. #8
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    I'm not following.

    What exactly are you suggesting?

    Wouldn't it be more intuitive to check req for instanceof in the case of that attribute and do that automatically since in general that is how that attribute will be used?
    Could you clarify that a bit?

    Erwin

  9. #9
    Join Date
    Sep 2004
    Posts
    346

    Default Here is clarification....

    In requestContext instead of going to map to retrive an attribute of

    PortletRequest.USER_INFO if context.getSourceEvent() is instanceof
    PortletEvent then execute the following command to retreive value

    PortletRequest request = ((PortletEvent)context.getSourceEvent()).getReques t();
    Map userInfo = (Map)request.getAttribute(PortletRequest.USER_INFO );


    I don't understand why the copy to the map was done in the first place why couldn't you do the same kind of thing for servlets as well

  10. #10
    Join Date
    Sep 2004
    Location
    Leuven, Belgium
    Posts
    1,853

    Default

    Maybe I'm just thick, but I'm still not getting what you're suggesting. Are you suggesting putting some code in RequestContext.getAttribute() that checks if the source event is a PortletEvent and if the request parameter is "USER_INFO" that it then pulls that info from the PortletRequest? If so, that's not possible since the RequestContext is completely protocol independent, and should remain that way.

    I guess an alternative would be to do it in the PortletEvent itself, when it extracts all parameters from the PortletRequest.

    Erwin

Similar Threads

  1. Replies: 2
    Last Post: Sep 28th, 2005, 11:12 PM
  2. When is Spring 1.3 Release - Portlet Support?
    By deviprasadk in forum Architecture
    Replies: 3
    Last Post: Sep 12th, 2005, 11:25 PM
  3. Replies: 3
    Last Post: Sep 7th, 2005, 03:15 AM
  4. Replies: 0
    Last Post: Apr 13th, 2005, 10:07 AM
  5. Problem with Jasper Reports support
    By rodney.gallart in forum Web
    Replies: 8
    Last Post: Jan 28th, 2005, 07:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •