2 Replies Latest reply on May 10, 2006 7:39 AM by louise_za

    Links within portlets

    louise_za

      Hi all

      I would like to have a portlet that contains a list of items displayed as links. Then, when a user click on a link, the item's attributes are shown. My problem is with the URL format to use when creating the link. I have tried many variations but can't get the data to post back to my portlet class. I have seen how the same result can be achieved with the submission of a form, but have not seen anything on variables passed via the URL of a page. Here are some excerpts from my code:

      public void processAction(ActionRequest aRequest, ActionResponse aResponse) throws PortletException, PortletSecurityException, IOException
       {
       String id = aRequest.getParameter("id");
       if(id == null)
       {
       id = "(null)";
       }
       System.out.println("The value of the id: " + id);
      
       aResponse.setRenderParameter("id", id);
       aResponse.setPortletMode(PortletMode.VIEW);
       }


      and in the jsp:

      <a href="Analysis?id=1234" target="_self">Item 1</a>


      Analysis is the name of the portal that the portlet is part of. Is there anyone that can help?

        • 1. Re: Links within portlets

          You have to use the actionURL or renderURL tag. Its in the spec.

          • 2. Re: Links within portlets
            louise_za

            Thanks Roy. It works now. Hopefully this will help someone else:

            Include the following lines in your jsp file:

            <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
            <portlet:defineObjects/>
            ...
            ...
            <portlet:actionURL windowState="normal" portletMode="view" var="theActionUrl">
            <portlet:param name="id" value="1234"/>
            </portlet:actionURL>
            
            <a href="<%= theActionUrl %>" target="_self">Item 1</a>

            This will then post a variable called 'id' with value '1234' via the URL. The above code (first post) in the processAction method will handle this variable and make it available in you page. This works for posting variables via URL parameters to the same jsp page.