6 Replies Latest reply on Mar 9, 2007 6:54 PM by ghyoju

    Passing parameters in an URL

    adamw

      Hello,
      I have some trouble passing parameters through URL.
      If I make a renderURL (in a JSP, with an appropriate tag) and add inside the tag some <portlet:param ...> then I see the parameters through request.getParameter() (where request is of class JBossRenderRequest). Moreover, these parameters stay in the session. (Of course it can't have anything to do with the tag, it's just that the URL is a render URL and looks like this:
      http://localhost:8080/portal/index.html?ctrl:id=window.demo.SomeName&ctrl:type=render&ctrl:windowstate=maximized&param1=value1))
      Here, request.getURL() returns null.

      When I try make a link to another page, something like:
      http://localhost:8080/portal/index.html?ctrl:id=page.default.pageXXX&param1=value1
      In this case, there are no paramters available through request.getParameter(). However, request.getURL() returns the URL and I have to parse the parameters myself.

      Moreover, what I have observed, is that parameters work only the easy way (that is, are accessible through request.getParameter()) when ctrl:type is render. With ctrl:type=nav it doesn't work, the behaviour is the same as with the page URL.

      Now, should it be so? Is there another way to always access the URL parameters in a uniform way?

        • 1. Re: Passing parameters in an URL

          Julien can explain this in more detail, but the short is: yes, this is expected.
          The Portlet Spec demands that the request params are only available to the PortletRequest, if they were added to a RenderURL or ActionURL in the Protlet that will receive that request. In other words: Portlets are not allowed to see the HttpServletRequest's parameters.

          does that make sense ?
          ...I tried ;)

          • 2. Re: Passing parameters in an URL
            adamw

            Yes, it is logical :).
            So there's no way to pass some parameters to portlets while constructing an URL to another page?

            • 3. Re: Passing parameters in an URL

              there's always a way ;) In this case it's just not a standard way. You can always look at the way the portal is building URLs, it's no secret. The issue is that this can change with any version.....

              • 4. Re: Passing parameters in an URL
                adamw

                You mean parsing request.getURL()? Or maybe looking at request.getPortletSession()? All I want to do is to create a link to a page with some parameters that I can read in portlets.

                • 5. Re: Passing parameters in an URL
                  felderr

                  did someone find out what Holzner meant. A smal code sample would have been great!

                  The PortletSession does not return any parameters nor attributes. Parsing the Url isn't realy the convenient way to getting parameters (stepping back to stone age?)

                  • 6. Re: Passing parameters in an URL
                    ghyoju

                    Hi,

                    I understand that form variables are not passed to the portlets and one need to pass the variables using renderURL tag.

                    <portlet:renderURL><portlet:param name="variableName" value="variableValue"/></portlet:renderURL>

                    The question I have is how do I set this variable to the value I get from a textBox or hidden variable or a java script variable using the renderURL tag.


                    Thank you very much.