2 Replies Latest reply on Feb 23, 2009 8:13 AM by jssteux

    How to access query parameters in portlet.doView()

    rashmitambe

      Hello

      I am trying to access a porlet in browser by typing in:

      http://localhost:8080/portal/auth/portal/myportal/TestApp/TestPortletWindow?category=cat1

      I would like to extract the request parameter "category" in doView(). However "request.getParameter("category");

      returns null. any idea why?[/url]

        • 1. Re: How to access query parameters in portlet.doView()
          theute

          Look at shared parameters (feature of JBoss Portal 2.7/EPP 4.3) if you really want to do this. This is explained in the reference guide.

          You won't access the http request parameter like this, this would bring collisions risks.
          (Say you add another portlet on the page with the category parameter which is something else). This is why the spec defines render parameters.

          • 2. Re: How to access query parameters in portlet.doView()
            jssteux

            Here is an example that works in jbp 2.6.7. It can be used in an interceptor (such as PageCustomizeInterceptor)



            // Retrieve portal object
            PortalObject portal = objContainer.getContext().getDefaultPortal();
            PortalObject gestionPerso = portal.getChild("gestionEspacePerso");
            PortalObject windowPerso gestionPerso.getChild("GestionEspacePersoPortletWindow");

            // Set parameters
            PortletParametersStateString parameters = new PortletParametersStateString();
            parameters.setValue("init", "true");

            // Perform a render URL on the target window
            InvokePortletWindowRenderCommand renderCmd = new InvokePortletWindowRenderCommand(windowPerso.getId(),
            Mode.VIEW, null, parameters);

            URLContext urlContext = cmd.getControllerContext().getServerInvocation().getServerContext()
            .getURLContext();

            String url = cmd.getControllerContext().renderURL(renderCmd, urlContext,URLFormat.newInstance(true, true));

            // forwards the url cmd.getControllerContext().getServerInvocation().setAttribute(Scope.REQUEST_SCOPE,
            "org.jboss.portal.header.MY_URL", url);