Access portlet.tld from within a Theme - Websphere

This is a discussion on Access portlet.tld from within a Theme - Websphere ; Scenario: From within my login portlet, I want to place some information in Session (Application_Scope). I have proven that the code is placed in Application_Scope. I then want to retrieve this information from within a theme. Why do I want ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: Access portlet.tld from within a Theme

  1. Access portlet.tld from within a Theme

    Scenario:

    From within my login portlet, I want to place some information in Session (Application_Scope). I have proven that the code is placed in Application_Scope.

    I then want to retrieve this information from within a theme. Why do I want to do this? Because I need to alter a link in a theme depending upon some information found in the Session.

    *****************
    From within my theme, I try to retrieve the renderRequest object to retrieve the data, but I then find that the page fails to compile because renderRequest is not found on the page:

    {code}
    JSPG0093E: Generated servlet error from file: /themes/html/SeanTest/Default.jsp
    /opt/IBM/WebSphere/AppServer/profiles/wp_profile/temp/wpsqa/WebSphere_Portal/wps/wps.war/themes/html/SeanTest/_Default.java:1661: cannot resolve symbol
    symbol : variable renderRequest
    location: class com.ibm._jsp._Default
    String domain = (String) renderRequest.getPortletSession().getAttribute("USER_DOMAIN_sean", 1);
    {code}

    That makes sense b/c I have not included the following at the top of the page.

    {code}{code}

    As I am compiling this, I think to myself, where in the world is it going to find that URI reference?

    And there lies my question: How can I include the portlet.tld to where my theme can have access to it?

    Any suggestions/links/comments would be appreciated.

    Thanks,
    Sean

  2. Re: Access portlet.tld from within a Theme

    I have tried to duplicate the logic in my JSP:

    {code}
    RenderRequest renderRequest = (RenderRequest) request.getAttribute("javax.portlet.request");
    RenderResponse renderResponse = (RenderResponse) request.getAttribute("javax.portlet.response");

    out.write("\nrequest ===== " + renderRequest);
    out.write("\nresponse ++++ " + renderResponse);

    {code}

    However, both values retrieved are null when they come out of the request. I also tried to pull them out of the Session, but that did not work either.

    {code}
    RenderRequest renderRequest = (RenderRequest) request.getSession().getAttribute("javax.portlet.request");
    RenderResponse renderResponse = (RenderResponse) request.getSession().getAttribute("javax.portlet.response");

    out.write("\nrequest ===== " + renderRequest);
    out.write("\nresponse ++++ " + renderResponse);
    {code}

    Any other suggestions?

  3. Re: Access portlet.tld from within a Theme

    I have also retrieved all of the attributeNames, and I do not see attributes for either the renderRequest or renderResponse. (As expected)

    {code}
    for(Enumeration e = request.getAttributeNames(); e.hasMoreElements(); ){
    String attName = (String)e.nextElement();
    out.println("
    " + attName);
    }

    {code}

    I obviously do not understand the "Theme Lifecycle" because I would have expected to see the renderRequest and renderResponse attributes on the request.

    Any help would be appreciated.

  4. Re: Access portlet.tld from within a Theme

    I don't think renderRequest,response will be available in Theme. Also what I think about APPLICATION_SCOPE's scope is across the PortletApplication(WAR).
    You can search on how to share values between Theme and Portlet.
    One option to do that is using Dyna Cache. The value you into the Dyna cache from your portlet is available in Theme.

  5. Re: Access portlet.tld from within a Theme

    Thanks for the response MahiM. I have done some cursory research on this solution, and it appears to be over-kill for what I am trying to accomplish.

    After thinking about my problem more, it really boils down to having access to some sort of session attribute within the theme, which is set within a portlet.

    I thought about creating a database table, which basically maintains a key-value pair of what I need. I would then insert the data into the database from within my portlet, and then create a tag for my theme to use in order to retrieve the data.

    Is there a better way?

  6. Re: Access portlet.tld from within a Theme

    Hi seanlon11,

    I'm trying to do the similar thing here. I need to get portletRequest and portletResponse in the theme.

    Because I'm using the FriendlyURLFactory to generate a friendly URL, but it requires portletRequest and portletResponse.

    Any help would be appreciate.

    Cheers,

+ Reply to Thread