Topic
  • 21 replies
  • Latest Post - ‏2009-11-11T22:37:58Z by nitsvault
SystemAdmin
SystemAdmin
3918 Posts

Pinned topic Dynamic menu using JSP component

‏2008-10-22T07:28:16Z |
Hi,
I am rendering menu component using JSP component.
The jsp code is as follows:

<%@ taglib uri="/WEB-INF/tld/wcm.tld" prefix="wcm" %>
<wcm:initworkspace user="<%= request.getUserPrincipal() %>"/>
<%RenderingContext context = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);
String currentPath = context.getPath();

String subPath1 = currentPath.substring(currentPath.indexOf("/")+1);
String subPath2 = subPath1.substring(subPath1.indexOf("/"),subPath1.lastIndexOf("/"));

String currentLibrary ="Sample WCM";
Map myparams = new HashMap();
myparams.put("sitearea", currentLibrary+subPath2);
%>
<wcm:setExplicitContext path="<%=currentPath%>" requestParameters="<%=myparams%>"/>
<wcm:libraryComponent name="menu" library="Sample WCM" />

In the menu component Design menu search result I have written the following code:

<placeholder tag="titlelink"/>

But it is not working.
I am getting 404 error.

Please help me in this issue.
Updated on 2009-11-11T22:37:58Z at 2009-11-11T22:37:58Z by nitsvault
  • EricMorentin
    EricMorentin
    95 Posts

    Re: Dynamic menu using JSP component

    ‏2008-10-22T09:25:19Z  
    Which part is giving you a 404? does the menu render at all? or are you seeing a problem with the setExplicitContext call?

    If the menu is rendering does the referenced content have a authoring to presentation template mapping?

    What do you see in the portal logs?
  • SystemAdmin
    SystemAdmin
    3918 Posts

    Re: Dynamic menu using JSP component

    ‏2008-10-22T10:46:32Z  
    Which part is giving you a 404? does the menu render at all? or are you seeing a problem with the setExplicitContext call?

    If the menu is rendering does the referenced content have a authoring to presentation template mapping?

    What do you see in the portal logs?
    Menu is rendering but when I am clicking the titlelink it is giving 404 error.

    The referenced content has presentation and authoring template map.

    This is the error I am getting when I am clicking on content title link.

    Error 404: SRVE0190E: File not found: /category.jsp/Sample WCM/unilever/skincleaningandcare/testcontent2
  • metkhoo
    metkhoo
    138 Posts

    Re: Dynamic menu using JSP component

    ‏2008-10-22T11:22:26Z  
    Hi,
    It appears to me that the current context is the problem here. By setting it explicitly the menu seems to think internal memory URL's should be generated with the explicitly set context.

    At the start of the code, you appear to have a current rendering context in the "context" object. My question to you is : why are you using

    <wcm:setExplicitContext path="<%=currentPath%>" requestParameters="<%=myparams%>"/>

    ?
    Best regards
    /Marcus
  • SystemAdmin
    SystemAdmin
    3918 Posts

    Re: Dynamic menu using JSP component

    ‏2008-10-22T11:36:12Z  
    • metkhoo
    • ‏2008-10-22T11:22:26Z
    Hi,
    It appears to me that the current context is the problem here. By setting it explicitly the menu seems to think internal memory URL's should be generated with the explicitly set context.

    At the start of the code, you appear to have a current rendering context in the "context" object. My question to you is : why are you using

    <wcm:setExplicitContext path="<%=currentPath%>" requestParameters="<%=myparams%>"/>

    ?
    Best regards
    /Marcus
    Yes you are true no need of setting explicit context.

    Now I have removed it used the following code:

    <wcm:initworkspace user="<%= request.getUserPrincipal() %>"/>
    <%RenderingContext context = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);
    String currentPath = context.getPath();
    String subPath1 = currentPath.substring(currentPath.indexOf("/")+1);
    String subPath2 = subPath1.substring(subPath1.indexOf("/"),subPath1.lastIndexOf("/"));
    String subPath3 = subPath2.substring(subPath2.lastIndexOf("/"));
    String currentLibrary ="Sample WCM";
    Map myparams = new HashMap();
    myparams.put("sitearea", currentLibrary+subPath2);
    %>
    <wcm:libraryComponent name="menu" library="Sample WCM" />
    Still I am getting the same error.
  • EricMorentin
    EricMorentin
    95 Posts

    Re: Dynamic menu using JSP component

    ‏2008-10-22T11:39:33Z  
    Yes you are true no need of setting explicit context.

    Now I have removed it used the following code:

    <wcm:initworkspace user="<%= request.getUserPrincipal() %>"/>
    <%RenderingContext context = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);
    String currentPath = context.getPath();
    String subPath1 = currentPath.substring(currentPath.indexOf("/")+1);
    String subPath2 = subPath1.substring(subPath1.indexOf("/"),subPath1.lastIndexOf("/"));
    String subPath3 = subPath2.substring(subPath2.lastIndexOf("/"));
    String currentLibrary ="Sample WCM";
    Map myparams = new HashMap();
    myparams.put("sitearea", currentLibrary+subPath2);
    %>
    <wcm:libraryComponent name="menu" library="Sample WCM" />
    Still I am getting the same error.
    Which version of WCM are you using?
  • SystemAdmin
    SystemAdmin
    3918 Posts

    Re: Dynamic menu using JSP component

    ‏2008-10-22T11:42:17Z  
    Which version of WCM are you using?
    portal version is 6.0.0.0
  • EricMorentin
    EricMorentin
    95 Posts

    Re: Dynamic menu using JSP component

    ‏2008-10-22T11:46:21Z  
    portal version is 6.0.0.0
    What are the contents of your \PortalServer\version\wcm.component file
  • SystemAdmin
    SystemAdmin
    3918 Posts

    Re: Dynamic menu using JSP component

    ‏2008-10-22T11:59:16Z  
    What are the contents of your \PortalServer\version\wcm.component file
    The content of <wps-root>\version\wcm.component file is

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE component PUBLIC "componentId" "component.dtd">
    <component build-date="2006/07/18 at 9:00:06 EST" build-version="Build 298.0" name="Web_Content_Management" spec-version="6.0"/>
  • EricMorentin
    EricMorentin
    95 Posts

    Re: Dynamic menu using JSP component

    ‏2008-10-22T11:59:37Z  
    What are the contents of your \PortalServer\version\wcm.component file
    Are you rendering in a portlet or direct to WCM?

    What is the HTML being produced? (get this from IE)
  • SystemAdmin
    SystemAdmin
    3918 Posts

    Re: Dynamic menu using JSP component

    ‏2008-10-22T12:18:00Z  
    Are you rendering in a portlet or direct to WCM?

    What is the HTML being produced? (get this from IE)
    I am rendering in Web Content Viewer portlet which is placed on a portal page.

    I am calling that jsp using jsp component.

    I have attached the page source.
  • EricMorentin
    EricMorentin
    95 Posts

    Re: Dynamic menu using JSP component

    ‏2008-10-22T12:26:48Z  
    I am rendering in Web Content Viewer portlet which is placed on a portal page.

    I am calling that jsp using jsp component.

    I have attached the page source.
    I would highly recommend upgrading to 6.0.1.4 (It will make it easier for me to help as well)

    http://www-01.ibm.com/support/docview.wss?uid=swg24020016

    It honestly looks like you are hitting a bug in the JSP component (I can not reproduce this on the 6.1.0.1 version of WCM, I will try and find a 6.0.x build somewhere to try)
  • SystemAdmin
    SystemAdmin
    3918 Posts

    Re: Dynamic menu using JSP component

    ‏2008-10-22T12:43:09Z  
    I would highly recommend upgrading to 6.0.1.4 (It will make it easier for me to help as well)

    http://www-01.ibm.com/support/docview.wss?uid=swg24020016

    It honestly looks like you are hitting a bug in the JSP component (I can not reproduce this on the 6.1.0.1 version of WCM, I will try and find a 6.0.x build somewhere to try)
    Thank you very much .
    I will upgrade and I will do it.
  • SystemAdmin
    SystemAdmin
    3918 Posts

    Re: Dynamic menu using JSP component

    ‏2008-11-07T09:22:10Z  
    Thank you very much .
    I will upgrade and I will do it.
    Hi,
    I have upgraded WCM to version 6.0.1.2 and portal server to version 6.0.1.1.
    Still I am getting the same problem.

    Please help me if you find any solution.
    thanks & regards,
    Kishore Kumar Reddipalli
    IBM Certified Application Developer
    IBM Certified Solution Developer
  • metkhoo
    metkhoo
    138 Posts

    Re: Dynamic menu using JSP component

    ‏2008-11-11T09:02:18Z  
    Hi,
    I have upgraded WCM to version 6.0.1.2 and portal server to version 6.0.1.1.
    Still I am getting the same problem.

    Please help me if you find any solution.
    thanks & regards,
    Kishore Kumar Reddipalli
    IBM Certified Application Developer
    IBM Certified Solution Developer
    Hi,
    Is there any reason you can't upgrade to 6.0.1.4?
    /Marcus
  • SystemAdmin
    SystemAdmin
    3918 Posts

    Re: Dynamic menu using JSP component

    ‏2008-11-12T05:30:12Z  
    • metkhoo
    • ‏2008-11-11T09:02:18Z
    Hi,
    Is there any reason you can't upgrade to 6.0.1.4?
    /Marcus
    I have upgraded my portal server and WCM to 6.0.1.4.

    The problem is still coming.

    The code I am using in the JSP in which I am passing sitearea dynamically and rendering menu is below:

    <wcm:initworkspace user="<%= request.getUserPrincipal() %>"/>
    <%RenderingContext context = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);
    String currentPath = context.getPath();
    String lrp=context.getLibraryRelativePath();
    int i=lrp.lastIndexOf("/");
    String sublrp=lrp.substring(0,i);
    String currentLibrary =context.getLibrary().getName();
    Map myparams = new HashMap();
    myparams.put("sitearea", currentLibrary+sublrp); %>
    <wcm:setExplicitContext path="<%=currentPath%>" requestParameters="<%=myparams%>"/>
    <wcm:libraryComponent name="newsmenu" library=currrentLibrary />

    Please help in solving this issue

    Regards,
    Kishore
  • SystemAdmin
    SystemAdmin
    3918 Posts

    Re: Dynamic menu using JSP component

    ‏2008-11-12T13:36:42Z  
    I have upgraded my portal server and WCM to 6.0.1.4.

    The problem is still coming.

    The code I am using in the JSP in which I am passing sitearea dynamically and rendering menu is below:

    <wcm:initworkspace user="<%= request.getUserPrincipal() %>"/>
    <%RenderingContext context = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);
    String currentPath = context.getPath();
    String lrp=context.getLibraryRelativePath();
    int i=lrp.lastIndexOf("/");
    String sublrp=lrp.substring(0,i);
    String currentLibrary =context.getLibrary().getName();
    Map myparams = new HashMap();
    myparams.put("sitearea", currentLibrary+sublrp); %>
    <wcm:setExplicitContext path="<%=currentPath%>" requestParameters="<%=myparams%>"/>
    <wcm:libraryComponent name="newsmenu" library=currrentLibrary />

    Please help in solving this issue

    Regards,
    Kishore
    Hi Marcus,
    If i remove the tag <wcm:setExplicitContext path="<%=currentPath%>" requestParameters="<%=myparams%>"/>
    from the above code it is working fine.

    But I was unable to pass query string to the menu.

    It would be great if you provide me the way to pass a query string to the menu.

    Regards,
    Kishore
  • SystemAdmin
    SystemAdmin
    3918 Posts

    Re: Dynamic menu using JSP component

    ‏2008-11-19T06:40:16Z  
    • metkhoo
    • ‏2008-11-11T09:02:18Z
    Hi,
    Is there any reason you can't upgrade to 6.0.1.4?
    /Marcus
    Hi Marcus,
    I got the solution to pass query dynamically to menu.
    The code is as below:

    <wcm:initworkspace user="<%= request.getUserPrincipal() %>"/>
    <%RenderingContext context = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);
    String currentPath = context.getPath();
    String lrp=context.getLibraryRelativePath();
    String sublrp=lrp.substring(0,lrp.lastIndexOf("/"));
    String currentLibrary =context.getLibrary().getName();
    Map myparams=context.getRequestParameters();
    myparams.put("sitearea", currentLibrary+sublrp);
    context.setRequestParameters(myparams); %>
    <wcm:libraryComponent name="menu" library=currrentLibrary />

    The problem is with the tag <wcm:setExplicitContext path="<%=currentPath%>" requestParameters="<%=myparams%>"/>
    Now I have removed that ,after removing I was unable to set parameters so instead of getting Map object from java.util.HashMap() .I got it from the context.getRequestParameters();

    Which resolved my issue.
    Now I am able to pass the query to menu dynamically.

    Thank you for your help.
    Your suggestions helped me a lot.

    Thank You.........

    Regards,
    Kishore
  • SystemAdmin
    SystemAdmin
    3918 Posts

    Re: Dynamic menu using JSP component

    ‏2008-12-04T06:37:13Z  
    • metkhoo
    • ‏2008-11-11T09:02:18Z
    Hi,
    Is there any reason you can't upgrade to 6.0.1.4?
    /Marcus
    Hi,

    Finally I got a way to send parameter dynamically to menu.
    The code is as follows:

    <%RenderingContext context = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY); %>
    <wcm:initworkspace user="<%= request.getUserPrincipal() %>"/>
    <% String currentPath = context.getPath();

    //Getting the library relative path(Ex : /Library/Site/Sitearea/Content)
    String lrp=context.getLibraryRelativePath();
    String sublrp=lrp.substring(0,lrp.lastIndexOf("/"));
    String currentLibrary =context.getLibrary().getName();

    Map myparams=context.getRequestParameters();
    myparams.put("sitearea", currentLibrary+sublrp);
    context.setRequestParameters(myparams); %>

    //Rendering the menu
    <wcm:libraryComponent name="menu" library=currrentLibrary />

    Regards,
    Kishore
  • kenny_yen
    kenny_yen
    6 Posts

    Re: Dynamic menu using JSP component

    ‏2009-10-15T00:22:16Z  
    Hi there, just wondering if you got any idea how to pass parameter from menu component to JSP component?
  • SystemAdmin
    SystemAdmin
    3918 Posts

    Re: Dynamic menu using JSP component

    ‏2009-10-15T12:46:31Z  
    • kenny_yen
    • ‏2009-10-15T00:22:16Z
    Hi there, just wondering if you got any idea how to pass parameter from menu component to JSP component?
    Can you elobarate what is your requirement exactly?
  • nitsvault
    nitsvault
    14 Posts

    Re: Dynamic menu using JSP component

    ‏2009-11-11T22:37:58Z  
    Can you elobarate what is your requirement exactly?
    Hi Kishore,
    i have the similar requirement, pass parameter to menu component and render the menu component.
    i have following code and two libraries 1. content library and 2nd is Design library.
    but when i execute the following code it always gives me content library but my component is inside the design librabry
    and in workspace i am setting the design library only.
    if you know anything i will really appreciate that.

    Thanks
    -Nits

    workspace.setCurrentDocumentLibrary(workspace.getDocumentLibrary(libName ));
    rcjsp = (RenderingContext)request.getAttribute(Workspace.WCM_RENDERINGCONTEXT_KEY);
    docSortByIds = workspace.findByName(DocumentTypes.LibraryComponent,libComponent);

    String currentPath = rcjsp.getPath();
    out.println("currentPath is :--->>> "+currentPath);
    String lrp=rcjsp.getLibraryRelativePath();
    String sublrp=lrp.substring(0,lrp.lastIndexOf("/"));
    String currentLibrary =rcjsp.getLibrary().getName();
    out.println("currentLibrary :-> "+currentLibrary);

    Map myparams=rcjsp.getRequestParameters();
    String strIndustry = "/Vault+WCM+Design+Library/industries_taxonomy/industries/law";
    myparams.put("industryId", strIndustry);
    rcjsp.setRequestParameters(myparams);