3 Replies Latest reply on Jan 4, 2006 1:02 PM by Michael Caughey

    Posting to ActionURL

    Michael Caughey Newbie

      I've been looking through the documentation, searching with Google and looking at the poral wiki, but I cannot find an anwser to this simple question.

      JB Portal 2.2, JBAS 4.0.3SP1

      I have a form on a JSP what do I do to post to the ActionURL of a portlet?

      I have a page /portal/portal/ppoc/list when the user selects a column in the personList portlet I want to post to the action url for that portlet. In the processAction() routine for that portlet I will do something.

      I've been reading the book by APress, "Building Portals with the JavaPortlet API". It refers to a portlet.tld which provides a number of JSP tags that do some of this for you. I believe they are using Pluto. Does anything like this exists for JBoss Portal?

      Thanks,
      Michael

        • 1. Re: Posting to ActionURL
          Bradley Smith Master

          You use the JSR168 portlet tag library to achieve this.

          Here is an example using the actionURL tag, some JSTL (<c:set..>) and JSP 2.0 to create a link for a portlet form:

          <c:set var="editLinkURL"><portlet:actionURL><portlet:param name="action" value="editLink"/></portlet:actionURL></c:set>
          
          ...
          
          <form action="${editLinkURL}" method="post">
          ...
          </form>
          


          Hope that helps.

          • 2. Re: Posting to ActionURL
            Michael Caughey Newbie

            Thanks for the quick response.

            Here's what I did:

            <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
            <%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
            
            <c:set var="listLinkURL">
             <portlet:actionURL>
             <portlet:param name="action" value="PersonList" />
             </portlet:actionURL>
            </c:set>
            
            <script>
             function postPersonForm(id){
             document.viewPersonForm.value = id;
             document.viewPersonForm.submit();
             }
            </script>
            
            <form id="view-person" name="viewPersonForm" action="${listLinkURL}" method="POST">
             <input type="hidden" name="id" />
            </form>
            
            <table border="0" width="200">
             <tr>
             <td>
             Lastname, Firstname
             </td>
             </tr>
             <c:forEach items="${PersonsList}" var="person">
             <tr>
             <td>
             <a href="javascript:postPersonForm(${person.id});">
            
             <c:out value="${person.lastName}" />
             ,
             <c:out value="${person.firstName}" />
             </a>
             </td>
             </tr>
             </c:forEach>
            </table>
            
            
            


            I got an error att he top of my JSP in regards to the portlet tag lib, the error doesn't say anything useful but it is related tothe taglib entry. Also I have an erro next to the <portlet:actionURL> tag which indicates that it cannot find the actionURL tag in the portlet TLD.

            Thanks,
            Michael

            • 3. Re: Posting to ActionURL
              Michael Caughey Newbie

              Well there may be errors on the JSP page, but ti does work.

              NOTE that in the example above there was a bug

              <script>
               function postPersonForm(id){
               document.viewPersonForm.id.value = id;
               document.viewPersonForm.submit();
               }
              </script>
              


              Just thought i'd note that for the record. It didn;t impact the issue at hand.


              So the only question i have is how do I fix the errors tha Eclipse is reporting?

              -Michael