Dynamic Portlet Title JSR 168 - Websphere

This is a discussion on Dynamic Portlet Title JSR 168 - Websphere ; Does anybody know how to set dynamic portlet title?, if so, can you please share code snippets?...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Dynamic Portlet Title JSR 168

  1. Dynamic Portlet Title JSR 168

    Does anybody know how to set dynamic portlet title?, if so, can you please share code snippets?





  2. Re: Dynamic Portlet Title JSR 168

    One way is this:

    http://www-128.ibm.com/developerwork...0612_rick.html

    Following thread gives you a rease why it is not possible for JSR168
    portlets directly:

    http://groups.google.de/group/ibm.so...417a8d3c3904a9

    Andreas
    Hannover / Germany

  3. Re: Dynamic Portlet Title JSR 168

    Thank you very much. I appreciate your help.

    There was one small problem if you follow RenderResponse.setTitle(String title) method, because this method transferred the title to request attribute "com.ibm.portal.portlet.Constants.DYNAMIC_TITL E". Pbm is, if you added more than one instance of the same portlet in the same page, the same title will be applied to all the portlets.

    Here is the alternate solution.

    Edit your control.jsp and replace title tag with the following,
    <span id="title.<portal-skinortletID/>"><portal-skinortletTitle><portal-fmtroblem bundle="nls.problem"/></portal-skinortletTitle></span>,

    Add the following script to your JSP (Portlet view jsp).
    <script type="text/javascript">
    var dynamicTitle = "<%=portletTitle%>";
    var titleElement = document.getElementById("title.<%=portletID%>");
    if (titleElement != null) {
    if (dynamicTitle != "" && dynamicTitle != "null")
    titleElement.innerHTML = dynamicTitle;
    }
    </script>

    Here is the method to find Portlet ID (I am not sure this is the rightway to get Portlet ID),
    private static String getPortletID(RenderRequest request) throws Exception {
    String portletId = "";
    try {
    HttpServletRequest httpRequest = (HttpServletRequest)request;
    RunData rundata = RunData.from(httpRequest);
    LayoutNode layoutnode = (LayoutNode) rundata
    .getAttribute("com.ibm.wps.composition.element");
    com.ibm.portal.ObjectID objectid;
    if (layoutnode == null)
    throw new IllegalStateException("PortletIDTag: Control cannot be found!");
    objectid = layoutnode.getObjectID();
    if (objectid != null)
    portletId = IdentificationMgr.getIdentification().serialize(ob jectid, false);
    } catch (Exception e) {
    System.out.println("Exceptin in getPortlet ID");
    }
    return portletId;
    }



+ Reply to Thread