4 Replies Latest reply on Sep 9, 2005 9:34 AM by lorneagle

    Hyperlink to external page displayed in portlet?

    lorneagle

      Hi all

      I'd like to know how i can create a hyperlink to an external website (like google) which will be display in the portlet. I am new to portlets and searched forums and google finding no solution.

      Thx in advance

        • 1. Re: Hyperlink to external page displayed in portlet?

          you can use a iframe to do that. create an iframe portlet, and use a preference to set the URI for instance.

          • 2. Re: Hyperlink to external page displayed in portlet?
            lorneagle

            Okay thx.

            I have a similar question:

            I try to link from a .jsp to an other .jsp all included in a .war.

            Link in .jsp

             <a href=<portlet:renderURL portletMode="view">
             <portlet:param name="link" value="/testlink.jsp"/>
             </portlet:renderURL>>Testlink</a>


            Portlet
            protected void doView(RenderRequest renderRequest, RenderResponse renderResponse) throws PortletException, IOException {
            
            renderResponse.setContentType("text/html");
            
            String uri = renderRequest.getPreferences().getValue("displayedPage","/index.jsp");
            
            String title = renderRequest.getPreferences().getValue("showTitle","Testtitle");
            
            String link = renderRequest.getParameter("link");
            
            if(link!=null){
             this.getPortletContext().getRequestDispatcher(link).include(renderRequest, renderResponse);
            }else{
             this.getPortletContext().getRequestDispatcher(uri).include(renderRequest, renderResponse);
            }
            }



            It works but if i follow that link and then go back and press refresh i get the testlink.jsp instead of the index.jsp. So there must be a different way to create simple links. Can you give me a hint pls?

            Thx



            • 3. Re: Hyperlink to external page displayed in portlet?

              I believe the reason why you see the testlink.jsp again after the refresh is due to the behavior of render parameters. Render paramters are persisted for the life time of the users session, or until you set a new value for the same paramter. In other words: when your refresh triggers a doView() call, the request.getParameter("link") still returns the testlink.jsp

              • 4. Re: Hyperlink to external page displayed in portlet?
                lorneagle

                That's what i guessed. I change the value and it works. Thank you :)

                Is there any "better" way to link .jsp-pages? I ask because there are very few simple code samples on the internet and i don't want to produce "bad" code.